From 5bc75a78852e3cc5be57ff88971c330a225bd5d9 Mon Sep 17 00:00:00 2001 From: Mani <12841290+krmanik@users.noreply.github.com> Date: Wed, 25 Jan 2023 16:35:11 +0530 Subject: [PATCH] Use a ninja variable for node binary (#2346) * Use a ninja variable for node binary * Update docs (dae) --- build/ninja_gen/src/node.rs | 18 +++++++++++++++++- docs/build.md | 4 ++++ docs/linux.md | 4 +--- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/build/ninja_gen/src/node.rs b/build/ninja_gen/src/node.rs index 9e2c43a30..df05e149d 100644 --- a/build/ninja_gen/src/node.rs +++ b/build/ninja_gen/src/node.rs @@ -114,6 +114,22 @@ pub fn setup_node( "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 {})?; for binary in binary_exports { @@ -148,7 +164,7 @@ impl BuildAction for EsbuildScript<'_> { } 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("entrypoint", &self.entrypoint); build.add_inputs("", inputs!["yarn.lock", ":node_modules", &self.deps]); diff --git a/docs/build.md b/docs/build.md index 86b98b065..b1f4dbeaf 100644 --- a/docs/build.md +++ b/docs/build.md @@ -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 profile build performance with https://discourse.cmake.org/t/profiling-build-performance/2443/3. + +## Packaging considerations + +See [this page](./linux.md). diff --git a/docs/linux.md b/docs/linux.md index 6b0e3afd7..aa2b325bb 100644 --- a/docs/linux.md +++ b/docs/linux.md @@ -77,9 +77,7 @@ There are a few things to be aware of: ## Packaging considerations 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, -to use it instead of the downloaded version. A similar approach could be done with node in the future; a PR would be -welcome. +PYTHON_BINARY, NODE_BINARY and/or PROTOC_BINARY to use locally-installed versions instead. If rust-toolchain.toml is removed, newer Rust versions can be used. Older versions may or may not compile the code.