Skip to content

Commit 91861e6

Browse files
committed
add WOW64 detection for installer
also future-proofs support for windows arm now I guess
1 parent f9a8387 commit 91861e6

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/installer.ts

+27-2
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,35 @@ async function fetchLatestTaggedRelease(channel: "stable" | "beta", timeout: num
252252
return ret;
253253
}
254254

255+
function getSystemArch(): string {
256+
if (process.arch == "x64")
257+
return "x86_64";
258+
else if (process.arch == "ia32")
259+
{
260+
if (process.platform == "win32")
261+
{
262+
// we might be on WOW:
263+
// https://ss64.com/nt/syntax-64bit.html
264+
// https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info
265+
if (process.env.PROCESSOR_ARCHITEW6432 === "AMD64" || process.env.PROCESSOR_ARCHITEW6432 === "IA64")
266+
return "x86_64";
267+
else if (process.env.PROCESSOR_ARCHITECTURE === "ARM64")
268+
return "arm64";
269+
else if (process.env.PROCESSOR_ARCHITECTURE === "ARM")
270+
return "arm";
271+
else
272+
return "x86";
273+
}
274+
else
275+
return "x86";
276+
}
277+
else
278+
return process.arch;
279+
}
280+
255281
function findFirstMatchingAsset(name: string | "nightly", assets: ReleaseAsset[]): ReleaseAsset | undefined {
256282
let os = <string>process.platform;
257-
let arch = process.arch == "x64" ? "x86_64" : process.arch == "ia32" ? "x86" : process.arch;
283+
let arch = getSystemArch();
258284

259285
if (os == "win32") {
260286
os = "windows";
@@ -499,7 +525,6 @@ export function compileServeD(ref?: string): (env: NodeJS.ProcessEnv) => Promise
499525
buildArgs.push("--compiler=" + dmdPath);
500526
}
501527
await compileDependency(outputFolder, "serve-d", "https://github.com/Pure-D/serve-d.git", [
502-
[dubPath, ["upgrade"]],
503528
[dubPath, buildArgs]
504529
], env, ref);
505530
var finalDestination = path.join(outputFolder, "serve-d", "serve-d" + (process.platform == "win32" ? ".exe" : ""));

0 commit comments

Comments
 (0)