Skip to content

Commit 8fb19c7

Browse files
committed
Merge branch 'topic/arm64-darwin' into 'master'
Make vscode extension prioritize arm64 executable on darwin Closes #1263 See merge request eng/ide/ada_language_server!1459
2 parents b07fcd9 + ba8bef7 commit 8fb19c7

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

integration/vscode/ada/src/clients.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@ export function createClient(
1313
) {
1414
let serverExecPath: string;
1515

16-
if (process.arch == 'arm64' && process.platform == 'darwin') {
17-
// On arm64 darwin use the x64 darwin executable thanks to Apple Rosetta.
18-
serverExecPath = context.asAbsolutePath(`x64/darwin/ada_language_server`);
19-
} else {
20-
serverExecPath = context.asAbsolutePath(
21-
`${process.arch}/${process.platform}/ada_language_server`
22-
);
23-
}
24-
25-
if (process.platform == 'win32') {
26-
// Add the extension for the file lookup further below
27-
serverExecPath = `${serverExecPath}.exe`;
28-
}
29-
3016
// If the ALS environment variable is specified, use it as the path of the
3117
// server executable.
3218
if (process.env.ALS) {
@@ -39,6 +25,28 @@ export function createClient(
3925
);
4026
}
4127
} else {
28+
serverExecPath = context.asAbsolutePath(
29+
`${process.arch}/${process.platform}/ada_language_server`
30+
);
31+
32+
if (process.arch == 'arm64' && process.platform == 'darwin') {
33+
// On arm64 darwin check if the executable exists, and if not, try to
34+
// fallback to the x64 darwin executable thanks to Apple Rosetta.
35+
if (!existsSync(serverExecPath)) {
36+
// The arm64 executable doesn't exist. Try x86.
37+
const alternateExecPath = context.asAbsolutePath(
38+
`x64/${process.platform}/ada_language_server`
39+
);
40+
if (existsSync(alternateExecPath)) {
41+
// The x86 executable exists, use that instead.
42+
serverExecPath = alternateExecPath;
43+
}
44+
}
45+
} else if (process.platform == 'win32') {
46+
// Add the extension for the file lookup further below
47+
serverExecPath = `${serverExecPath}.exe`;
48+
}
49+
4250
if (!existsSync(serverExecPath)) {
4351
logErrorAndThrow(
4452
`This installation of the Ada extension does not have the Ada ` +

0 commit comments

Comments
 (0)