Skip to content

Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.

feat(build): build the D3D11 compositor addon for the target arch

Christian Schmittelaada31109736
diff --git a/crates/.cargo/config.toml b/crates/.cargo/config.toml
index cb1fd42fb..642cf6842 100644
--- a/crates/.cargo/config.toml
+++ b/crates/.cargo/config.toml
@@ -34,6 +34,12 @@ LIBCLANG_PATH = "C:\\Program Files\\LLVM\\bin"
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
+# Windows on ARM: meme raison que x86_64 ci-dessus. Le paquet arm64 vise des
+# machines Snapdragon ou le Redistribuable VC++ n'est pas plus garanti qu'ailleurs,
+# et scripts/before-pack.cjs applique la meme regle aux deux arches.
+[target.aarch64-pc-windows-msvc]
+rustflags = ["-C", "target-feature=+crt-static"]
+
# macOS : BtbN ne publie pas de build macOS (cf. scripts/fetch-ffmpeg.mjs), donc on
# laisse `crates/compositor/build.rs` chercher MAC_FFMPEG_DIR (env var explicite posée
# par la CI macOS ou par le dev local) ou un répertoire attendu sous `thirdparty/`.
diff --git a/scripts/build-windows-compositor-addon.mjs b/scripts/build-windows-compositor-addon.mjs
index cc40675d1..5a6da5df4 100644
--- a/scripts/build-windows-compositor-addon.mjs
+++ b/scripts/build-windows-compositor-addon.mjs
@@ -19,12 +19,31 @@ import fs from "node:fs";
import path from "node:path";
import { fileURLToPath } from "node:url";
import { findVcVarsAll, run as spawnStep } from "./msvcEnv.mjs";
+import { resolveTargetArch, resolveVcvarsArch, winBinDirName } from "./windows-helper-arch.mjs";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const ROOT = path.join(__dirname, "..");
const CRATES_DIR = path.join(ROOT, "crates");
const BUILD_OUT_DIR = path.join(ROOT, "electron", "native", "compositor-view", "build");
+// Same resolution order as build-windows-wgc-helper.mjs so a single --arch (or
+// OPENSCREEN_WIN_HELPER_ARCH) drives every Windows native artefact the packaged
+// app ships. Without this the addon was always built x64 and copied into
+// win32-x64/, so an arm64 package either missed it or shipped one the ARM64
+// runtime cannot load.
+const cliArch = (() => {
+ const eq = process.argv.find((a) => a.startsWith("--arch="));
+ if (eq) return eq.slice("--arch=".length);
+ const idx = process.argv.indexOf("--arch");
+ return idx !== -1 ? process.argv[idx + 1] : undefined;
+})();
+const TARGET_ARCH = resolveTargetArch({
+ cliArch,
+ envArch: process.env.OPENSCREEN_WIN_HELPER_ARCH,
+ hostArch: process.arch,
+});
+const VCVARS_ARCH = resolveVcvarsArch(process.arch, TARGET_ARCH);
+
// cwd defaults to crates/, not ROOT: cargo reads FFMPEG_DIR and LIBCLANG_PATH
// from crates/.cargo/config.toml, which only applies when it runs from there.
const run = (command, args, options = {}) =>
@@ -51,7 +70,7 @@ async function runInVsEnv(command) {
cmdPath,
[
"@echo off",
- `call "${vcvarsAll}" x64`,
+ `call "${vcvarsAll}" ${VCVARS_ARCH}`,
"if errorlevel 1 exit /b %errorlevel%",
command,
"exit /b %errorlevel%",
@@ -118,7 +137,7 @@ fs.copyFileSync(builtDll, dest);
// directory is searched for its dependencies. Colocating removes the PATH mechanism
// rather than repairing it. `buildCandidatePaths` already probes this location
// first, so no loader change is needed.
-const archBinDir = path.join(ROOT, "electron", "native", "bin", "win32-x64");
+const archBinDir = path.join(ROOT, "electron", "native", "bin", winBinDirName(TARGET_ARCH));
fs.mkdirSync(archBinDir, { recursive: true });
const archDest = path.join(archBinDir, "compositor_view.node");
fs.copyFileSync(builtDll, archDest);