Skip to content

Commit e1a9ba9

Browse files
committed
merge utils and misc
Signed-off-by: onur-ozkan <[email protected]>
1 parent ed7766b commit e1a9ba9

29 files changed

+94
-102
lines changed

src/bootstrap/src/core/build_steps/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::core::build_steps::compile::{
66
use crate::core::build_steps::tool::{prepare_tool_cargo, SourceType};
77
use crate::core::builder::{crate_description, Alias, Builder, Kind, RunConfig, ShouldRun, Step};
88
use crate::core::config::TargetSelection;
9-
use crate::misc::cache::Interned;
9+
use crate::utils::cache::Interned;
1010
use crate::INTERNER;
1111
use crate::{Compiler, Mode, Subcommand};
1212
use std::path::{Path, PathBuf};

src/bootstrap/src/core/build_steps/clean.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use std::io::{self, ErrorKind};
1010
use std::path::Path;
1111

1212
use crate::core::builder::{crate_description, Builder, RunConfig, ShouldRun, Step};
13-
use crate::misc::cache::Interned;
14-
use crate::utils::t;
13+
use crate::utils::cache::Interned;
14+
use crate::utils::helpers::t;
1515
use crate::{Build, Compiler, Mode, Subcommand};
1616

1717
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]

src/bootstrap/src/core/build_steps/compile.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ use crate::core::builder::crate_description;
2626
use crate::core::builder::Cargo;
2727
use crate::core::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
2828
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
29-
use crate::misc::cache::{Interned, INTERNER};
30-
use crate::utils::get_clang_cl_resource_dir;
31-
use crate::utils::{exe, is_debug_info, is_dylib, output, symlink_dir, t, up_to_date};
29+
use crate::utils::cache::{Interned, INTERNER};
30+
use crate::utils::helpers::{exe, is_debug_info, get_clang_cl_resource_dir, is_dylib, output, symlink_dir, t, up_to_date};
3231
use crate::LLVM_TOOLS;
3332
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
3433
use filetime::FileTime;

src/bootstrap/src/core/build_steps/dist.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ use crate::core::build_steps::llvm;
2525
use crate::core::build_steps::tool::{self, Tool};
2626
use crate::core::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2727
use crate::core::config::TargetSelection;
28-
use crate::misc::cache::{Interned, INTERNER};
29-
use crate::misc::channel;
30-
use crate::misc::tarball::{GeneratedTarball, OverlayKind, Tarball};
31-
use crate::utils::{exe, is_dylib, output, t, timeit};
28+
use crate::utils::cache::{Interned, INTERNER};
29+
use crate::utils::channel;
30+
use crate::utils::tarball::{GeneratedTarball, OverlayKind, Tarball};
31+
use crate::utils::helpers::{exe, is_dylib, output, t, timeit};
3232
use crate::{Compiler, DependencyType, Mode, LLVM_TOOLS};
3333

3434
pub fn pkgname(builder: &Builder<'_>, component: &str) -> String {
@@ -487,7 +487,7 @@ impl Step for Rustc {
487487
let man_src = builder.src.join("src/doc/man");
488488
let man_dst = image.join("share/man/man1");
489489

490-
// don't use our `bootstrap::util::{copy, cp_r}`, because those try
490+
// don't use our `bootstrap::{copy, cp_r}`, because those try
491491
// to hardlink, and we don't want to edit the source templates
492492
for file_entry in builder.read_dir(&man_src) {
493493
let page_src = file_entry.path();

src/bootstrap/src/core/build_steps/doc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use crate::core::build_steps::tool::{self, prepare_tool_cargo, SourceType, Tool}
1515
use crate::core::builder::crate_description;
1616
use crate::core::builder::{Alias, Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
1717
use crate::core::config::{Config, TargetSelection};
18-
use crate::misc::cache::{Interned, INTERNER};
19-
use crate::utils::{dir_is_empty, symlink_dir, t, up_to_date};
18+
use crate::utils::cache::{Interned, INTERNER};
19+
use crate::utils::helpers::{dir_is_empty, symlink_dir, t, up_to_date};
2020
use crate::Mode;
2121

2222
macro_rules! submodule_helper {

src/bootstrap/src/core/build_steps/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Runs rustfmt on the repository.
22
33
use crate::core::builder::Builder;
4-
use crate::utils::{output, program_out_of_date, t};
4+
use crate::utils::helpers::{output, program_out_of_date, t};
55
use build_helper::ci::CiEnv;
66
use build_helper::git::get_git_modified_files;
77
use ignore::WalkBuilder;

src/bootstrap/src/core/build_steps/install.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use std::process::Command;
1111
use crate::core::build_steps::dist;
1212
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
1313
use crate::core::config::{Config, TargetSelection};
14-
use crate::misc::tarball::GeneratedTarball;
15-
use crate::utils::t;
14+
use crate::utils::tarball::GeneratedTarball;
15+
use crate::utils::helpers::t;
1616
use crate::{Compiler, Kind};
1717

1818
#[cfg(target_os = "illumos")]

src/bootstrap/src/core/build_steps/llvm.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ use std::process::Command;
1818

1919
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2020
use crate::core::config::{Config, TargetSelection};
21-
use crate::misc::channel;
22-
use crate::utils::get_clang_cl_resource_dir;
23-
use crate::utils::{self, exe, output, t, up_to_date};
21+
use crate::utils::channel;
22+
use crate::utils::helpers::{self, exe, output, t, up_to_date, get_clang_cl_resource_dir};
2423
use crate::{CLang, GitRepo, Kind};
2524

2625
use build_helper::ci::CiEnv;
@@ -281,7 +280,7 @@ impl Step for Llvm {
281280

282281
let _guard = builder.msg_unstaged(Kind::Build, "LLVM", target);
283282
t!(stamp.remove());
284-
let _time = utils::timeit(&builder);
283+
let _time = helpers::timeit(&builder);
285284
t!(fs::create_dir_all(&out_dir));
286285

287286
// https://llvm.org/docs/CMake.html
@@ -410,7 +409,7 @@ impl Step for Llvm {
410409

411410
let mut enabled_llvm_projects = Vec::new();
412411

413-
if utils::forcing_clang_based_tests() {
412+
if helpers::forcing_clang_based_tests() {
414413
enabled_llvm_projects.push("clang");
415414
enabled_llvm_projects.push("compiler-rt");
416415
}
@@ -850,7 +849,7 @@ impl Step for Lld {
850849
}
851850

852851
let _guard = builder.msg_unstaged(Kind::Build, "LLD", target);
853-
let _time = utils::timeit(&builder);
852+
let _time = helpers::timeit(&builder);
854853
t!(fs::create_dir_all(&out_dir));
855854

856855
let mut cfg = cmake::Config::new(builder.src.join("src/llvm-project/lld"));
@@ -881,7 +880,7 @@ impl Step for Lld {
881880
// `LD_LIBRARY_PATH` overrides)
882881
//
883882
if builder.config.rpath_enabled(target)
884-
&& utils::use_host_linker(target)
883+
&& helpers::use_host_linker(target)
885884
&& builder.config.llvm_link_shared()
886885
&& target.contains("linux")
887886
{
@@ -974,7 +973,7 @@ impl Step for Sanitizers {
974973

975974
let _guard = builder.msg_unstaged(Kind::Build, "sanitizers", self.target);
976975
t!(stamp.remove());
977-
let _time = utils::timeit(&builder);
976+
let _time = helpers::timeit(&builder);
978977

979978
let mut cfg = cmake::Config::new(&compiler_rt_dir);
980979
cfg.profile("Release");

src/bootstrap/src/core/build_steps/run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::core::build_steps::tool::{self, SourceType, Tool};
99
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
1010
use crate::core::config::flags::get_completion;
1111
use crate::core::config::TargetSelection;
12-
use crate::utils::output;
12+
use crate::utils::helpers::output;
1313
use crate::Mode;
1414

1515
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/src/core/build_steps/test.rs

+24-25
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ use crate::core::builder::{Builder, Compiler, Kind, RunConfig, ShouldRun, Step};
2525
use crate::core::config::flags::get_completion;
2626
use crate::core::config::flags::Subcommand;
2727
use crate::core::config::TargetSelection;
28-
use crate::misc::cache::Interned;
29-
use crate::misc::cache::INTERNER;
30-
use crate::misc::render_tests::add_flags_and_try_run_tests;
31-
use crate::misc::render_tests::try_run_tests;
32-
use crate::utils::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date};
28+
use crate::utils;
29+
use crate::utils::cache::{Interned, INTERNER};
30+
use crate::utils::render_tests::{try_run_tests, add_flags_and_try_run_tests};
31+
use crate::utils::helpers::{self, add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date};
3332
use crate::{envify, CLang, DocTests, GitRepo, Mode};
3433

3534
const ADB_TEST_DIR: &str = "/data/local/tmp/work";
@@ -169,7 +168,7 @@ You can skip linkcheck with --skip src/tools/linkchecker"
169168
// Run the linkchecker.
170169
let _guard =
171170
builder.msg(Kind::Test, compiler.stage, "Linkcheck", bootstrap_host, bootstrap_host);
172-
let _time = utils::timeit(&builder);
171+
let _time = helpers::timeit(&builder);
173172
builder.run_delaying_failure(linkchecker.arg(builder.out.join(host.triple).join("doc")));
174173
}
175174

@@ -266,7 +265,7 @@ impl Step for Cargotest {
266265
let out_dir = builder.out.join("ct");
267266
t!(fs::create_dir_all(&out_dir));
268267

269-
let _time = utils::timeit(&builder);
268+
let _time = helpers::timeit(&builder);
270269
let mut cmd = builder.tool_cmd(Tool::CargoTest);
271270
builder.run_delaying_failure(
272271
cmd.arg(&cargo)
@@ -334,7 +333,7 @@ impl Step for Cargo {
334333
builder,
335334
);
336335

337-
let _time = utils::timeit(&builder);
336+
let _time = helpers::timeit(&builder);
338337
add_flags_and_try_run_tests(builder, &mut cargo);
339338
}
340339
}
@@ -648,7 +647,7 @@ impl Step for Miri {
648647
// does not understand the flags added by `add_flags_and_try_run_test`.
649648
let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", compiler, target, builder);
650649
{
651-
let _time = utils::timeit(&builder);
650+
let _time = helpers::timeit(&builder);
652651
builder.run(&mut cargo);
653652
}
654653

@@ -664,7 +663,7 @@ impl Step for Miri {
664663

665664
let mut cargo = prepare_cargo_test(cargo, &[], &[], "miri", compiler, target, builder);
666665
{
667-
let _time = utils::timeit(&builder);
666+
let _time = helpers::timeit(&builder);
668667
builder.run(&mut cargo);
669668
}
670669
}
@@ -704,7 +703,7 @@ impl Step for Miri {
704703

705704
let mut cargo = Command::from(cargo);
706705
{
707-
let _time = utils::timeit(&builder);
706+
let _time = helpers::timeit(&builder);
708707
builder.run(&mut cargo);
709708
}
710709
}
@@ -865,7 +864,7 @@ impl Step for RustdocTheme {
865864
if builder.is_fuse_ld_lld(self.compiler.host) {
866865
cmd.env(
867866
"RUSTDOC_LLD_NO_THREADS",
868-
utils::lld_flag_no_threads(self.compiler.host.contains("windows")),
867+
helpers::lld_flag_no_threads(self.compiler.host.contains("windows")),
869868
);
870869
}
871870
builder.run_delaying_failure(&mut cmd);
@@ -906,7 +905,7 @@ impl Step for RustdocJSStd {
906905
.arg("--test-folder")
907906
.arg(builder.src.join("tests/rustdoc-js-std"));
908907
for path in &builder.paths {
909-
if let Some(p) = utils::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder) {
908+
if let Some(p) = helpers::is_valid_test_suite_arg(path, "tests/rustdoc-js-std", builder) {
910909
if !p.ends_with(".js") {
911910
eprintln!("A non-js file was given: `{}`", path.display());
912911
panic!("Cannot run rustdoc-js-std tests");
@@ -1041,7 +1040,7 @@ impl Step for RustdocGUI {
10411040
.env("RUSTC", builder.rustc(self.compiler));
10421041

10431042
for path in &builder.paths {
1044-
if let Some(p) = utils::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) {
1043+
if let Some(p) = helpers::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) {
10451044
if !p.ends_with(".goml") {
10461045
eprintln!("A non-goml file was given: `{}`", path.display());
10471046
panic!("Cannot run rustdoc-gui tests");
@@ -1064,7 +1063,7 @@ impl Step for RustdocGUI {
10641063
cmd.arg("--npm").arg(npm);
10651064
}
10661065

1067-
let _time = utils::timeit(&builder);
1066+
let _time = helpers::timeit(&builder);
10681067
let _guard = builder.msg_sysroot_tool(
10691068
Kind::Test,
10701069
self.compiler.stage,
@@ -1684,7 +1683,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
16841683
}
16851684
}
16861685

1687-
if utils::forcing_clang_based_tests() {
1686+
if helpers::forcing_clang_based_tests() {
16881687
let clang_exe = builder.llvm_out(target).join("bin").join("clang");
16891688
cmd.arg("--run-clang-based-tests-with").arg(clang_exe);
16901689
}
@@ -1703,7 +1702,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
17031702
// Get test-args by striping suite path
17041703
let mut test_args: Vec<&str> = paths
17051704
.iter()
1706-
.filter_map(|p| utils::is_valid_test_suite_arg(p, suite_path, builder))
1705+
.filter_map(|p| helpers::is_valid_test_suite_arg(p, suite_path, builder))
17071706
.collect();
17081707

17091708
test_args.append(&mut builder.config.test_args());
@@ -1914,7 +1913,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the
19141913
"Check compiletest suite={} mode={} compare_mode={} ({} -> {})",
19151914
suite, mode, compare_mode, &compiler.host, target
19161915
));
1917-
let _time = utils::timeit(&builder);
1916+
let _time = helpers::timeit(&builder);
19181917
try_run_tests(builder, &mut cmd, false);
19191918
}
19201919
}
@@ -1986,7 +1985,7 @@ impl BookTest {
19861985
compiler.host,
19871986
compiler.host,
19881987
);
1989-
let _time = utils::timeit(&builder);
1988+
let _time = helpers::timeit(&builder);
19901989
let toolstate = if builder.run_delaying_failure(&mut rustbook_cmd) {
19911990
ToolState::TestPass
19921991
} else {
@@ -2008,7 +2007,7 @@ impl BookTest {
20082007
// Do a breadth-first traversal of the `src/doc` directory and just run
20092008
// tests for all files that end in `*.md`
20102009
let mut stack = vec![builder.src.join(self.path)];
2011-
let _time = utils::timeit(&builder);
2010+
let _time = helpers::timeit(&builder);
20122011
let mut files = Vec::new();
20132012
while let Some(p) = stack.pop() {
20142013
if p.is_dir() {
@@ -2119,7 +2118,7 @@ impl Step for ErrorIndex {
21192118

21202119
let guard =
21212120
builder.msg(Kind::Test, compiler.stage, "error-index", compiler.host, compiler.host);
2122-
let _time = utils::timeit(&builder);
2121+
let _time = helpers::timeit(&builder);
21232122
builder.run_quiet(&mut tool);
21242123
drop(guard);
21252124
// The tests themselves need to link to std, so make sure it is
@@ -2241,7 +2240,7 @@ fn run_cargo_test<'a>(
22412240
) -> bool {
22422241
let mut cargo =
22432242
prepare_cargo_test(cargo, libtest_args, crates, primary_crate, compiler, target, builder);
2244-
let _time = utils::timeit(&builder);
2243+
let _time = helpers::timeit(&builder);
22452244
let _group = description.into().and_then(|what| {
22462245
builder.msg_sysroot_tool(Kind::Test, compiler.stage, what, compiler.host, target)
22472246
});
@@ -2636,7 +2635,7 @@ impl Step for RemoteCopyLibs {
26362635
for f in t!(builder.sysroot_libdir(compiler, target).read_dir()) {
26372636
let f = t!(f);
26382637
let name = f.file_name().into_string().unwrap();
2639-
if utils::is_dylib(&name) {
2638+
if helpers::is_dylib(&name) {
26402639
builder.run(Command::new(&tool).arg("push").arg(f.path()));
26412640
}
26422641
}
@@ -2681,7 +2680,7 @@ impl Step for Distcheck {
26812680
.current_dir(&dir),
26822681
);
26832682
builder.run(
2684-
Command::new(utils::make(&builder.config.build.triple)).arg("check").current_dir(&dir),
2683+
Command::new(helpers::make(&builder.config.build.triple)).arg("check").current_dir(&dir),
26852684
);
26862685

26872686
// Now make sure that rust-src has all of libstd's dependencies
@@ -3061,7 +3060,7 @@ impl Step for CodegenCranelift {
30613060
&compiler.host,
30623061
target
30633062
));
3064-
let _time = utils::timeit(&builder);
3063+
let _time = helpers::timeit(&builder);
30653064

30663065
// FIXME handle vendoring for source tarballs before removing the --skip-test below
30673066
let download_dir = builder.out.join("cg_clif_download");

src/bootstrap/src/core/build_steps/tool.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::core::build_steps::compile;
77
use crate::core::build_steps::toolstate::ToolState;
88
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
99
use crate::core::config::TargetSelection;
10-
use crate::misc::channel::GitInfo;
11-
use crate::utils::{add_dylib_path, exe, t};
10+
use crate::utils::channel::GitInfo;
11+
use crate::utils::helpers::{add_dylib_path, exe, t};
1212
use crate::Compiler;
1313
use crate::Mode;
1414
use crate::{gha, Kind};

src/bootstrap/src/core/build_steps/toolstate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
2-
use crate::utils::t;
2+
use crate::utils::helpers::t;
33
use serde_derive::{Deserialize, Serialize};
44
use std::collections::HashMap;
55
use std::env;

src/bootstrap/src/core/builder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use crate::core::build_steps::tool::{self, SourceType};
1717
use crate::core::build_steps::{check, clean, compile, dist, doc, install, run, setup, test};
1818
use crate::core::config::flags::{Color, Subcommand};
1919
use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection};
20-
use crate::misc::cache::{Cache, Interned, INTERNER};
21-
use crate::utils::{self, add_dylib_path, add_link_lib_path, exe, libdir, output, t};
20+
use crate::utils::cache::{Cache, Interned, INTERNER};
21+
use crate::utils::helpers::{self, add_dylib_path, add_link_lib_path, exe, libdir, output, t};
2222
use crate::Crate;
2323
use crate::EXTRA_CHECK_CFGS;
2424
use crate::{Build, CLang, DocTests, GitRepo, Mode};
@@ -1297,8 +1297,8 @@ impl<'a> Builder<'a> {
12971297

12981298
// See comment in rustc_llvm/build.rs for why this is necessary, largely llvm-config
12991299
// needs to not accidentally link to libLLVM in stage0/lib.
1300-
cargo.env("REAL_LIBRARY_PATH_VAR", &utils::dylib_path_var());
1301-
if let Some(e) = env::var_os(utils::dylib_path_var()) {
1300+
cargo.env("REAL_LIBRARY_PATH_VAR", &helpers::dylib_path_var());
1301+
if let Some(e) = env::var_os(helpers::dylib_path_var()) {
13021302
cargo.env("REAL_LIBRARY_PATH", e);
13031303
}
13041304

@@ -1629,7 +1629,7 @@ impl<'a> Builder<'a> {
16291629
// argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
16301630
// fun to pass a flag to a tool to pass a flag to pass a flag to a tool
16311631
// to change a flag in a binary?
1632-
if self.config.rpath_enabled(target) && utils::use_host_linker(target) {
1632+
if self.config.rpath_enabled(target) && helpers::use_host_linker(target) {
16331633
let libdir = self.sysroot_libdir_relative(compiler).to_str().unwrap();
16341634
let rpath = if target.contains("apple") {
16351635
// Note that we need to take one extra step on macOS to also pass

0 commit comments

Comments
 (0)