forked from siddharthvaddem/openscreen
-
Notifications
You must be signed in to change notification settings - Fork 42
Feat/windows arm64 support #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
christian-wr
wants to merge
13
commits into
getopenscreen:main
Choose a base branch
from
christian-wr:feat/windows-arm64-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0d4dd3a
feat(build): add pure Windows helper arch-resolution module
42083e7
feat(build): make Windows WGC helper build arch-aware (x64/arm64, nat…
cb115d3
feat(build): add build:win:arm64 and build:native:win:arm64 scripts
e8f895e
build: include arch in Windows installer filename to avoid x64/arm64 …
f17a263
ci: build Windows x64 and arm64 installers via matrix
365652c
docs: document Windows arm64 native helper build and installer
edc73fd
fix(build): wipe WGC build dir on target-arch change to prevent stale…
fc933b3
build: normalize electron-builder.json5 to keep diff to the artifactN…
ec629d5
ci: fetch win32-arm64 sharp prebuilt for arm64 packaging (non-fatal)
b315d0d
Merge branch 'main' into feat/windows-arm64-support
EtienneLescot 9005d67
Merge branch 'main' into feat/windows-arm64-support
EtienneLescot b29f832
Merge branch 'main' into feat/windows-arm64-support
EtienneLescot 6e42f13
Merge branch 'main' into feat/windows-arm64-support
EtienneLescot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // Pure helpers that map a target CPU architecture to the parameters the Windows | ||
| // native-helper build needs. Kept side-effect free so it is unit-testable and | ||
| // importable from both the build script and Vitest. | ||
|
|
||
| export const SUPPORTED_ARCHES = ["x64", "arm64"]; | ||
|
|
||
| const ALIASES = new Map([ | ||
| ["x64", "x64"], | ||
| ["amd64", "x64"], | ||
| ["x86_64", "x64"], | ||
| ["arm64", "arm64"], | ||
| ["aarch64", "arm64"], | ||
| ]); | ||
|
|
||
| export function normalizeArch(value) { | ||
| if (value === undefined || value === null || value === "") { | ||
| return undefined; | ||
| } | ||
| return ALIASES.get(String(value).toLowerCase()); | ||
| } | ||
|
|
||
| export function resolveTargetArch({ cliArch, envArch, hostArch } = {}) { | ||
| for (const [label, raw] of [ | ||
| ["--arch", cliArch], | ||
| ["OPENSCREEN_WIN_HELPER_ARCH", envArch], | ||
| ]) { | ||
| if (raw !== undefined && raw !== null && raw !== "") { | ||
| const normalized = normalizeArch(raw); | ||
| if (!normalized) { | ||
| throw new Error( | ||
| `Invalid ${label} value "${raw}". Expected one of: ${SUPPORTED_ARCHES.join(", ")}.`, | ||
| ); | ||
| } | ||
| return normalized; | ||
| } | ||
| } | ||
|
|
||
| const host = normalizeArch(hostArch); | ||
| if (!host) { | ||
| throw new Error( | ||
| `Unsupported host architecture "${hostArch}". Pass --arch with one of: ${SUPPORTED_ARCHES.join(", ")}.`, | ||
| ); | ||
| } | ||
| return host; | ||
| } | ||
|
|
||
| export function resolveVcvarsArch(hostArch, targetArch) { | ||
| const host = normalizeArch(hostArch); | ||
| const target = normalizeArch(targetArch); | ||
| if (!host || !target) { | ||
| throw new Error(`Unsupported architecture pair host="${hostArch}" target="${targetArch}".`); | ||
| } | ||
| return host === target ? target : `${host}_${target}`; | ||
| } | ||
|
|
||
| export function winBinDirName(targetArch) { | ||
| const target = normalizeArch(targetArch); | ||
| if (!target) { | ||
| throw new Error(`Unsupported target architecture "${targetArch}".`); | ||
| } | ||
| return `win32-${target}`; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { describe, expect, it } from "vitest"; | ||
| import { | ||
| SUPPORTED_ARCHES, | ||
| normalizeArch, | ||
| resolveTargetArch, | ||
| resolveVcvarsArch, | ||
| winBinDirName, | ||
| } from "./windows-helper-arch.mjs"; | ||
|
|
||
| describe("normalizeArch", () => { | ||
| it("maps known aliases to canonical arches", () => { | ||
| expect(normalizeArch("x64")).toBe("x64"); | ||
| expect(normalizeArch("amd64")).toBe("x64"); | ||
| expect(normalizeArch("x86_64")).toBe("x64"); | ||
| expect(normalizeArch("arm64")).toBe("arm64"); | ||
| expect(normalizeArch("aarch64")).toBe("arm64"); | ||
| expect(normalizeArch("ARM64")).toBe("arm64"); | ||
| }); | ||
|
|
||
| it("returns undefined for empty or unknown values", () => { | ||
| expect(normalizeArch(undefined)).toBeUndefined(); | ||
| expect(normalizeArch("")).toBeUndefined(); | ||
| expect(normalizeArch("mips")).toBeUndefined(); | ||
| }); | ||
| }); | ||
|
|
||
| describe("resolveTargetArch", () => { | ||
| it("prefers the CLI arch over env and host", () => { | ||
| expect(resolveTargetArch({ cliArch: "arm64", envArch: "x64", hostArch: "x64" })).toBe("arm64"); | ||
| }); | ||
|
|
||
| it("falls back to env when no CLI arch", () => { | ||
| expect(resolveTargetArch({ envArch: "arm64", hostArch: "x64" })).toBe("arm64"); | ||
| }); | ||
|
|
||
| it("defaults to the host arch when nothing explicit is given", () => { | ||
| expect(resolveTargetArch({ hostArch: "arm64" })).toBe("arm64"); | ||
| expect(resolveTargetArch({ hostArch: "x64" })).toBe("x64"); | ||
| }); | ||
|
|
||
| it("throws on an invalid explicit arch", () => { | ||
| expect(() => resolveTargetArch({ cliArch: "mips", hostArch: "x64" })).toThrow(/Invalid/); | ||
| }); | ||
|
|
||
| it("throws on an unsupported host with no explicit arch", () => { | ||
| expect(() => resolveTargetArch({ hostArch: "ppc64" })).toThrow(/host/i); | ||
| }); | ||
| }); | ||
|
|
||
| describe("resolveVcvarsArch", () => { | ||
| it("returns native tokens when host equals target", () => { | ||
| expect(resolveVcvarsArch("x64", "x64")).toBe("x64"); | ||
| expect(resolveVcvarsArch("arm64", "arm64")).toBe("arm64"); | ||
| }); | ||
|
|
||
| it("returns cross tokens as <host>_<target>", () => { | ||
| expect(resolveVcvarsArch("x64", "arm64")).toBe("x64_arm64"); | ||
| expect(resolveVcvarsArch("arm64", "x64")).toBe("arm64_x64"); | ||
| }); | ||
| }); | ||
|
|
||
| describe("winBinDirName", () => { | ||
| it("builds the packaged bin folder name", () => { | ||
| expect(winBinDirName("x64")).toBe("win32-x64"); | ||
| expect(winBinDirName("arm64")).toBe("win32-arm64"); | ||
| }); | ||
| }); | ||
|
|
||
| it("exposes the supported arch list", () => { | ||
| expect(SUPPORTED_ARCHES).toEqual(["x64", "arm64"]); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To prevent host-architecture compilation conflicts on Windows ARM64 developer machines (where
npm run build:winmight compile the ARM64 helper instead of the x64 one required by the x64 packaged app), we should explicitly pass the--arch x64flag here: