Don't check for platform details
This commit is contained in:
@@ -9,7 +9,7 @@ import { log, isValidExecutable, isRustDocument } from './util';
|
|||||||
import { PersistentState } from './persistent_state';
|
import { PersistentState } from './persistent_state';
|
||||||
import { activateTaskProvider } from './tasks';
|
import { activateTaskProvider } from './tasks';
|
||||||
import { setContextValue } from './util';
|
import { setContextValue } from './util';
|
||||||
import { exec, spawnSync } from 'child_process';
|
import { exec } from 'child_process';
|
||||||
|
|
||||||
let ctx: Ctx | undefined;
|
let ctx: Ctx | undefined;
|
||||||
|
|
||||||
@@ -227,43 +227,30 @@ async function getServer(context: vscode.ExtensionContext, config: Config, state
|
|||||||
};
|
};
|
||||||
if (config.package.releaseTag === null) return "rust-analyzer";
|
if (config.package.releaseTag === null) return "rust-analyzer";
|
||||||
|
|
||||||
const platforms: { [key: string]: string } = {
|
const ext = process.platform === "win32" ? ".exe" : "";
|
||||||
"ia32 win32": "x86_64-pc-windows-msvc",
|
const bundled = vscode.Uri.joinPath(context.extensionUri, "server", `rust-analyzer${ext}`);
|
||||||
"x64 win32": "x86_64-pc-windows-msvc",
|
const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false);
|
||||||
"x64 linux": "x86_64-unknown-linux-gnu",
|
if (bundledExists) {
|
||||||
"x64 darwin": "x86_64-apple-darwin",
|
let server = bundled;
|
||||||
"arm64 win32": "aarch64-pc-windows-msvc",
|
if (await isNixOs()) {
|
||||||
"arm64 linux": "aarch64-unknown-linux-gnu",
|
await vscode.workspace.fs.createDirectory(config.globalStorageUri).then();
|
||||||
"arm64 darwin": "aarch64-apple-darwin",
|
const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer${ext}`);
|
||||||
};
|
let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
|
||||||
let platform = platforms[`${process.arch} ${process.platform}`];
|
if (exists && config.package.version !== state.serverVersion) {
|
||||||
if (platform) {
|
await vscode.workspace.fs.delete(dest);
|
||||||
if (platform === "x86_64-unknown-linux-gnu" && isMusl()) {
|
exists = false;
|
||||||
platform = "x86_64-unknown-linux-musl";
|
}
|
||||||
}
|
if (!exists) {
|
||||||
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
|
await vscode.workspace.fs.copy(bundled, dest);
|
||||||
const bundled = vscode.Uri.joinPath(context.extensionUri, "server", `rust-analyzer${ext}`);
|
await patchelf(dest);
|
||||||
const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false);
|
server = dest;
|
||||||
if (bundledExists) {
|
|
||||||
let server = bundled;
|
|
||||||
if (await isNixOs()) {
|
|
||||||
await vscode.workspace.fs.createDirectory(config.globalStorageUri).then();
|
|
||||||
const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer-${platform}${ext}`);
|
|
||||||
let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
|
|
||||||
if (exists && config.package.version !== state.serverVersion) {
|
|
||||||
await vscode.workspace.fs.delete(dest);
|
|
||||||
exists = false;
|
|
||||||
}
|
|
||||||
if (!exists) {
|
|
||||||
await vscode.workspace.fs.copy(bundled, dest);
|
|
||||||
await patchelf(dest);
|
|
||||||
server = dest;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
await state.updateServerVersion(config.package.version);
|
|
||||||
return server.fsPath;
|
|
||||||
}
|
}
|
||||||
|
await state.updateServerVersion(config.package.version);
|
||||||
|
return server.fsPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await state.updateServerVersion(undefined);
|
||||||
await vscode.window.showErrorMessage(
|
await vscode.window.showErrorMessage(
|
||||||
"Unfortunately we don't ship binaries for your platform yet. " +
|
"Unfortunately we don't ship binaries for your platform yet. " +
|
||||||
"You need to manually clone rust-analyzer repository and " +
|
"You need to manually clone rust-analyzer repository and " +
|
||||||
@@ -288,13 +275,6 @@ async function isNixOs(): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMusl(): boolean {
|
|
||||||
// We can detect Alpine by checking `/etc/os-release` but not Void Linux musl.
|
|
||||||
// Instead, we run `ldd` since it advertises the libc which it belongs to.
|
|
||||||
const res = spawnSync("ldd", ["--version"]);
|
|
||||||
return res.stderr != null && res.stderr.indexOf("musl libc") >= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function warnAboutExtensionConflicts() {
|
function warnAboutExtensionConflicts() {
|
||||||
const conflicting = [
|
const conflicting = [
|
||||||
["rust-analyzer", "matklad.rust-analyzer"],
|
["rust-analyzer", "matklad.rust-analyzer"],
|
||||||
|
|||||||
Reference in New Issue
Block a user