about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbinarycat <binarycat@envs.net>2025-07-22 12:21:14 -0500
committerbinarycat <binarycat@envs.net>2025-07-22 12:46:19 -0500
commit2d1fccd7a1fb713d0d2cea6cb33ad245a6b1f383 (patch)
treefe3e773c813bbe71a05a7633cbbe75c2ae57cb0c
parent35487a2e7c80012129c38f55c970109a1538c91f (diff)
downloadrust-2d1fccd7a1fb713d0d2cea6cb33ad245a6b1f383.tar.gz
rust-2d1fccd7a1fb713d0d2cea6cb33ad245a6b1f383.zip
pass build.npm from bootstrap to tidy and use it for npm install
-rw-r--r--src/bootstrap/src/core/build_steps/test.rs6
-rw-r--r--src/tools/tidy/src/ext_tool_checks.rs5
-rw-r--r--src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs5
-rw-r--r--src/tools/tidy/src/main.rs2
4 files changed, 14 insertions, 4 deletions
diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs
index 8344b0e03b4..1022faa0921 100644
--- a/src/bootstrap/src/core/build_steps/test.rs
+++ b/src/bootstrap/src/core/build_steps/test.rs
@@ -1113,6 +1113,12 @@ impl Step for Tidy {
             8 * std::thread::available_parallelism().map_or(1, std::num::NonZeroUsize::get) as u32
         });
         cmd.arg(jobs.to_string());
+        // pass the path to the npm command used for installing js deps.
+        if let Some(npm) = &builder.config.npm {
+            cmd.arg(npm);
+        } else {
+            cmd.arg("npm");
+        }
         if builder.is_verbose() {
             cmd.arg("--verbose");
         }
diff --git a/src/tools/tidy/src/ext_tool_checks.rs b/src/tools/tidy/src/ext_tool_checks.rs
index 911d4daae5c..8121eb057db 100644
--- a/src/tools/tidy/src/ext_tool_checks.rs
+++ b/src/tools/tidy/src/ext_tool_checks.rs
@@ -50,6 +50,7 @@ pub fn check(
     ci_info: &CiInfo,
     librustdoc_path: &Path,
     tools_path: &Path,
+    npm: &Path,
     bless: bool,
     extra_checks: Option<&str>,
     pos_args: &[String],
@@ -61,6 +62,7 @@ pub fn check(
         ci_info,
         librustdoc_path,
         tools_path,
+        npm,
         bless,
         extra_checks,
         pos_args,
@@ -75,6 +77,7 @@ fn check_impl(
     ci_info: &CiInfo,
     librustdoc_path: &Path,
     tools_path: &Path,
+    npm: &Path,
     bless: bool,
     extra_checks: Option<&str>,
     pos_args: &[String],
@@ -293,7 +296,7 @@ fn check_impl(
     }
 
     if js_lint || js_typecheck {
-        rustdoc_js::npm_install(root_path, outdir)?;
+        rustdoc_js::npm_install(root_path, outdir, npm)?;
     }
 
     if js_lint {
diff --git a/src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs b/src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs
index c1a62cedd33..7708b128e23 100644
--- a/src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs
+++ b/src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs
@@ -23,9 +23,8 @@ fn spawn_cmd(cmd: &mut Command) -> Result<Child, io::Error> {
 }
 
 /// install all js dependencies from package.json.
-pub(super) fn npm_install(root_path: &Path, outdir: &Path) -> Result<(), super::Error> {
-    // FIXME(lolbinarycat): make this obey build.npm bootstrap option
-    npm::install(root_path, outdir, Path::new("npm"))?;
+pub(super) fn npm_install(root_path: &Path, outdir: &Path, npm: &Path) -> Result<(), super::Error> {
+    npm::install(root_path, outdir, npm)?;
     Ok(())
 }
 
diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs
index 13b20f33bd0..11ee2ae688d 100644
--- a/src/tools/tidy/src/main.rs
+++ b/src/tools/tidy/src/main.rs
@@ -29,6 +29,7 @@ fn main() {
     let concurrency: NonZeroUsize =
         FromStr::from_str(&env::args().nth(4).expect("need concurrency"))
             .expect("concurrency must be a number");
+    let npm: PathBuf = env::args_os().nth(5).expect("need name/path of npm command").into();
 
     let root_manifest = root_path.join("Cargo.toml");
     let src_path = root_path.join("src");
@@ -182,6 +183,7 @@ fn main() {
             &ci_info,
             &librustdoc_path,
             &tools_path,
+            &npm,
             bless,
             extra_checks,
             pos_args