Skip to content

Commit c0d0cee

Browse files
committed
Don't check for platform details
1 parent f55cca4 commit c0d0cee

File tree

1 file changed

+22
-42
lines changed

1 file changed

+22
-42
lines changed

editors/code/src/main.ts

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { log, isValidExecutable, isRustDocument } from './util';
99
import { PersistentState } from './persistent_state';
1010
import { activateTaskProvider } from './tasks';
1111
import { setContextValue } from './util';
12-
import { exec, spawnSync } from 'child_process';
12+
import { exec } from 'child_process';
1313

1414
let ctx: Ctx | undefined;
1515

@@ -227,43 +227,30 @@ async function getServer(context: vscode.ExtensionContext, config: Config, state
227227
};
228228
if (config.package.releaseTag === null) return "rust-analyzer";
229229

230-
const platforms: { [key: string]: string } = {
231-
"ia32 win32": "x86_64-pc-windows-msvc",
232-
"x64 win32": "x86_64-pc-windows-msvc",
233-
"x64 linux": "x86_64-unknown-linux-gnu",
234-
"x64 darwin": "x86_64-apple-darwin",
235-
"arm64 win32": "aarch64-pc-windows-msvc",
236-
"arm64 linux": "aarch64-unknown-linux-gnu",
237-
"arm64 darwin": "aarch64-apple-darwin",
238-
};
239-
let platform = platforms[`${process.arch} ${process.platform}`];
240-
if (platform) {
241-
if (platform === "x86_64-unknown-linux-gnu" && isMusl()) {
242-
platform = "x86_64-unknown-linux-musl";
243-
}
244-
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
245-
const bundled = vscode.Uri.joinPath(context.extensionUri, "server", `rust-analyzer${ext}`);
246-
const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false);
247-
if (bundledExists) {
248-
let server = bundled;
249-
if (await isNixOs()) {
250-
await vscode.workspace.fs.createDirectory(config.globalStorageUri).then();
251-
const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer-${platform}${ext}`);
252-
let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
253-
if (exists && config.package.version !== state.serverVersion) {
254-
await vscode.workspace.fs.delete(dest);
255-
exists = false;
256-
}
257-
if (!exists) {
258-
await vscode.workspace.fs.copy(bundled, dest);
259-
await patchelf(dest);
260-
server = dest;
261-
}
230+
const ext = process.platform === "win32" ? ".exe" : "";
231+
const bundled = vscode.Uri.joinPath(context.extensionUri, "server", `rust-analyzer${ext}`);
232+
const bundledExists = await vscode.workspace.fs.stat(bundled).then(() => true, () => false);
233+
if (bundledExists) {
234+
let server = bundled;
235+
if (await isNixOs()) {
236+
await vscode.workspace.fs.createDirectory(config.globalStorageUri).then();
237+
const dest = vscode.Uri.joinPath(config.globalStorageUri, `rust-analyzer${ext}`);
238+
let exists = await vscode.workspace.fs.stat(dest).then(() => true, () => false);
239+
if (exists && config.package.version !== state.serverVersion) {
240+
await vscode.workspace.fs.delete(dest);
241+
exists = false;
242+
}
243+
if (!exists) {
244+
await vscode.workspace.fs.copy(bundled, dest);
245+
await patchelf(dest);
246+
server = dest;
262247
}
263-
await state.updateServerVersion(config.package.version);
264-
return server.fsPath;
265248
}
249+
await state.updateServerVersion(config.package.version);
250+
return server.fsPath;
266251
}
252+
253+
await state.updateServerVersion(undefined);
267254
await vscode.window.showErrorMessage(
268255
"Unfortunately we don't ship binaries for your platform yet. " +
269256
"You need to manually clone rust-analyzer repository and " +
@@ -288,13 +275,6 @@ async function isNixOs(): Promise<boolean> {
288275
}
289276
}
290277

291-
function isMusl(): boolean {
292-
// We can detect Alpine by checking `/etc/os-release` but not Void Linux musl.
293-
// Instead, we run `ldd` since it advertises the libc which it belongs to.
294-
const res = spawnSync("ldd", ["--version"]);
295-
return res.stderr != null && res.stderr.indexOf("musl libc") >= 0;
296-
}
297-
298278
function warnAboutExtensionConflicts() {
299279
const conflicting = [
300280
["rust-analyzer", "matklad.rust-analyzer"],

0 commit comments

Comments
 (0)