Use a ninja variable for node binary (#2346)

* Use a ninja variable for node binary

* Update docs (dae)
This commit is contained in:
Mani 2023-01-25 16:35:11 +05:30 committed by GitHub
parent 96a9dba67d
commit 5bc75a7885
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 4 deletions

View file

@ -114,6 +114,22 @@ pub fn setup_node(
"npm" => vec![if cfg!(windows) { "npm.cmd " } else { "bin/npm" }] "npm" => vec![if cfg!(windows) { "npm.cmd " } else { "bin/npm" }]
}, },
)?; )?;
let node_binary = match std::env::var("NODE_BINARY") {
Ok(path) => {
assert!(
Utf8Path::new(&path).is_absolute(),
"NODE_BINARY must be absolute"
);
path.into()
}
Err(_) => {
inputs![":extract:node:bin"]
}
};
let node_binary = build.expand_inputs(node_binary);
build.variable("node_binary", &node_binary[0]);
build.add("yarn", YarnSetup {})?; build.add("yarn", YarnSetup {})?;
for binary in binary_exports { for binary in binary_exports {
@ -148,7 +164,7 @@ impl BuildAction for EsbuildScript<'_> {
} }
fn files(&mut self, build: &mut impl build::FilesHandle) { fn files(&mut self, build: &mut impl build::FilesHandle) {
build.add_inputs("node_bin", inputs![":extract:node:bin"]); build.add_inputs("node_bin", inputs!["$node_binary"]);
build.add_inputs("script", &self.script); build.add_inputs("script", &self.script);
build.add_inputs("entrypoint", &self.entrypoint); build.add_inputs("entrypoint", &self.entrypoint);
build.add_inputs("", inputs!["yarn.lock", ":node_modules", &self.deps]); build.add_inputs("", inputs!["yarn.lock", ":node_modules", &self.deps]);

View file

@ -34,3 +34,7 @@ If you run into trouble with the build process:
- You can browse the build graph via e.g. `./ninja -- -t browse wheels` - You can browse the build graph via e.g. `./ninja -- -t browse wheels`
- You can profile build performance with - You can profile build performance with
https://discourse.cmake.org/t/profiling-build-performance/2443/3. https://discourse.cmake.org/t/profiling-build-performance/2443/3.
## Packaging considerations
See [this page](./linux.md).

View file

@ -77,9 +77,7 @@ There are a few things to be aware of:
## Packaging considerations ## Packaging considerations
Python, node and protoc are downloaded as part of the build. You can optionally define Python, node and protoc are downloaded as part of the build. You can optionally define
PYTHON_BINARY and PROTOC_BINARY as the full path to a Python binary and Protoc binary respectively, PYTHON_BINARY, NODE_BINARY and/or PROTOC_BINARY to use locally-installed versions instead.
to use it instead of the downloaded version. A similar approach could be done with node in the future; a PR would be
welcome.
If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions
may or may not compile the code. may or may not compile the code.