diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index b58b46eb8f2..c1e42c67128 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -549,45 +549,6 @@ impl Build { rustdoc } - /// Get a `Command` which is ready to run `tool` in `stage` built for - /// `host`. - fn tool_cmd(&self, compiler: Compiler, tool: &str) -> Command { - let mut cmd = Command::new(self.tool(compiler, tool)); - self.prepare_tool_cmd(compiler, &mut cmd); - cmd - } - - /// Prepares the `cmd` provided to be able to run the `compiler` provided. - /// - /// Notably this munges the dynamic library lookup path to point to the - /// right location to run `compiler`. - fn prepare_tool_cmd(&self, compiler: Compiler, cmd: &mut Command) { - let host = compiler.host; - let mut paths = vec![ - self.sysroot_libdir(compiler, compiler.host), - self.cargo_out(compiler, Mode::Tool, host).join("deps"), - ]; - - // On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make - // mode) and that C compiler may need some extra PATH modification. Do - // so here. - if compiler.host.contains("msvc") { - let curpaths = env::var_os("PATH").unwrap_or(OsString::new()); - let curpaths = env::split_paths(&curpaths).collect::>(); - for &(ref k, ref v) in self.cc[compiler.host].0.env() { - if k != "PATH" { - continue - } - for path in env::split_paths(v) { - if !curpaths.contains(&path) { - paths.push(path); - } - } - } - } - add_lib_path(paths, cmd); - } - /// Get the space-separated set of activated features for the standard /// library. fn std_features(&self) -> String { diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 234a903ee6c..f13f9e7d07c 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -369,3 +369,44 @@ impl<'a> Step<'a> for Rls<'a> { }) } } + +impl<'a> Builder<'a> { + /// Get a `Command` which is ready to run `tool` in `stage` built for + /// `host`. + fn tool_cmd(&self, compiler: Compiler, tool: &str) -> Command { + let mut cmd = Command::new(self.tool(compiler, tool)); + self.prepare_tool_cmd(compiler, &mut cmd); + cmd + } + + /// Prepares the `cmd` provided to be able to run the `compiler` provided. + /// + /// Notably this munges the dynamic library lookup path to point to the + /// right location to run `compiler`. + fn prepare_tool_cmd(&self, compiler: Compiler, cmd: &mut Command) { + let host = compiler.host; + let mut paths = vec![ + self.sysroot_libdir(compiler, compiler.host), + self.cargo_out(compiler, Mode::Tool, host).join("deps"), + ]; + + // On MSVC a tool may invoke a C compiler (e.g. compiletest in run-make + // mode) and that C compiler may need some extra PATH modification. Do + // so here. + if compiler.host.contains("msvc") { + let curpaths = env::var_os("PATH").unwrap_or(OsString::new()); + let curpaths = env::split_paths(&curpaths).collect::>(); + for &(ref k, ref v) in self.cc[compiler.host].0.env() { + if k != "PATH" { + continue + } + for path in env::split_paths(v) { + if !curpaths.contains(&path) { + paths.push(path); + } + } + } + } + add_lib_path(paths, cmd); + } +}