Skip to content

Commit fd52922

Browse files
committed
Fix: support cross-platform build in CI.
1 parent 6671eac commit fd52922

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

builder/src/main.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct TypeScriptBuildOptions {
121121
static VSCODE_PATH: &str = "../extensions/VSCode";
122122
static CLIENT_PATH: &str = "../client";
123123
static BUILDER_PATH: &str = "../builder";
124+
static NAPI_TARGET: &str = "NAPI_TARGET";
124125

125126
// Code
126127
// ----
@@ -623,6 +624,12 @@ fn run_extensions_build(
623624
if dist {
624625
napi_args.push("--release");
625626
}
627+
// See if this is a cross-platform build -- if so, add in the specified target.
628+
let target;
629+
if let Ok(tmp) = env::var(NAPI_TARGET) {
630+
target = tmp;
631+
napi_args.extend(["--target", &target]);
632+
}
626633
run_script("npx", &napi_args, VSCODE_PATH, true)?;
627634

628635
// The main build for the extension.
@@ -707,6 +714,10 @@ fn run_postrelease(target: &str) -> io::Result<()> {
707714
"aarch64-apple-darwin" => "darwin-arm64",
708715
_ => panic!("Unsupported platform {target}."),
709716
};
717+
// `vsce` will invoke this program's `ext_build`; however, it doesn't provide a way to pass the target when cross-compiling. Use an environment variable instead.
718+
unsafe {
719+
env::set_var(NAPI_TARGET, target);
720+
}
710721
run_script(
711722
"npx",
712723
&[

0 commit comments

Comments
 (0)