Skip to content

pass build.npm from bootstrap to tidy and use it for npm install #144317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
5 changes: 4 additions & 1 deletion src/tools/tidy/src/ext_tool_checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -61,6 +62,7 @@ pub fn check(
ci_info,
librustdoc_path,
tools_path,
npm,
bless,
extra_checks,
pos_args,
Expand All @@ -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],
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 2 additions & 3 deletions src/tools/tidy/src/ext_tool_checks/rustdoc_js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down
2 changes: 2 additions & 0 deletions src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to think about using clap here soon... 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're going to refactor how bootstrap passes args to internal tools, I would prefer we use something more type-safe and typo-safe than manually serializing and deserializing args at every process boundary, especially considering these tools aren't really meant to be called directly.

my immediate thought would be putting some types into build_helper which get serialized into json blobs that get passed to tools and deserialized. I actually tried doing this in a limited form with compiletest all the way back in #135653, trying to reduce the amount of code that has to be kept in sync on both sides.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if some people don't use tidy or compiletest outside of bootstrap 🤷 But if not, then yeah, we might make the interface be more machine processing friendly.


let root_manifest = root_path.join("Cargo.toml");
let src_path = root_path.join("src");
Expand Down Expand Up @@ -182,6 +183,7 @@ fn main() {
&ci_info,
&librustdoc_path,
&tools_path,
&npm,
bless,
extra_checks,
pos_args
Expand Down
Loading