From 2d1fccd7a1fb713d0d2cea6cb33ad245a6b1f383 Mon Sep 17 00:00:00 2001 From: binarycat Date: Tue, 22 Jul 2025 12:21:14 -0500 Subject: [PATCH] pass build.npm from bootstrap to tidy and use it for npm install --- src/bootstrap/src/core/build_steps/test.rs | 6 ++++++ src/tools/tidy/src/ext_tool_checks.rs | 5 ++++- src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs | 5 ++--- src/tools/tidy/src/main.rs | 2 ++ 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 8344b0e03b487..1022faa09218f 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 911d4daae5cd2..8121eb057db5b 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 c1a62cedd331e..7708b128e23d8 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 { } /// 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 13b20f33bd0f7..11ee2ae688d84 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