rewrite env-dep-info to rmake · rust-lang/rust@fe76650 (original) (raw)

9 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -4,13 +4,15 @@ use std::path::Path;
4 4
5 5 use crate::{command, cwd, env_var, set_host_rpath};
6 6
7 -/// Construct a new `rustc` invocation.
7 +/// Construct a new `rustc` invocation. This will automatically set the library
8 +/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
8 9 #[track_caller]
9 10 pub fn rustc() -> Rustc {
10 11 Rustc::new()
11 12 }
12 13
13 -/// Construct a plain `rustc` invocation with no flags set.
14 +/// Construct a plain `rustc` invocation with no flags set. Note that [`set_host_rpath`]
15 +/// still presets the environment variable `HOST_RPATH_DIR` by default.
14 16 #[track_caller]
15 17 pub fn bare_rustc() -> Rustc {
16 18 Rustc::bare()
@@ -42,7 +44,8 @@ fn setup_common() -> Command {
42 44 impl Rustc {
43 45 // `rustc` invocation constructor methods
44 46
45 -/// Construct a new `rustc` invocation.
47 +/// Construct a new `rustc` invocation. This will automatically set the library
48 + /// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
46 49 #[track_caller]
47 50 pub fn new() -> Self {
48 51 let mut cmd = setup_common();
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ run-make/dep-info/Makefile
23 23 run-make/dump-ice-to-disk/Makefile
24 24 run-make/dump-mono-stats/Makefile
25 25 run-make/emit-to-stdout/Makefile
26 -run-make/env-dep-info/Makefile
27 26 run-make/export-executable-symbols/Makefile
28 27 run-make/extern-diff-internal-name/Makefile
29 28 run-make/extern-flag-disambiguates/Makefile
@@ -58,7 +57,6 @@ run-make/issue-35164/Makefile
58 57 run-make/issue-36710/Makefile
59 58 run-make/issue-47551/Makefile
60 59 run-make/issue-69368/Makefile
61 -run-make/issue-83045/Makefile
62 60 run-make/issue-84395-lto-embed-bitcode/Makefile
63 61 run-make/issue-85019-moved-src-dir/Makefile
64 62 run-make/issue-85401-static-mir/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
1 +macro_use.d: macro_use.rs
2 +
3 +macro_use.rs:
4 +
5 +# env-dep:EXISTING_PROC_MACRO_ENV=1
6 +# env-dep:NONEXISTENT_PROC_MACEO_ENV
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
1 +main.d: main.rs
2 +
3 +main.rs:
4 +
5 +# env-dep:ESCAPE\nESCAPE\\
6 +# env-dep:EXISTING_ENV=1
7 +# env-dep:EXISTING_OPT_ENV=1
8 +# env-dep:NONEXISTENT_OPT_ENV
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1 +// Inside dep-info emit files, #71858 made it so all accessed environment
2 +// variables are usefully printed. This test checks that this feature works
3 +// as intended by checking if the environment variables used in compilation
4 +// appear in the output dep-info files.
5 +// See https://github.com/rust-lang/rust/issues/40364
6 +
7 +use run_make_support::{diff, rustc};
8 +
9 +fn main() {
10 +rustc()
11 +.env("EXISTING_ENV", "1")
12 +.env("EXISTING_OPT_ENV", "1")
13 +.emit("dep-info")
14 +.input("main.rs")
15 +.run();
16 +diff().expected_file("correct_main.d").actual_file("main.d").run();
17 +// Procedural macro
18 +rustc().input("macro_def.rs").run();
19 +rustc().env("EXISTING_PROC_MACRO_ENV", "1").emit("dep-info").input("macro_use.rs").run();
20 +diff().expected_file("correct_macro.d").actual_file("macro_use.d").run();
21 +}
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ fn main() {
27 27 .input("b.rs")
28 28 .arg("--verbose")
29 29 .run();
30 - fs_wrapper::create_dir("wrong_directory");
31 30 bare_rustc()
32 31 .extern_("b", rust_lib_name("b"))
33 32 .crate_type("rlib")
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1 +bar.d: bar.rs
2 +
3 +bar.rs:
Original file line number Diff line number Diff line change
@@ -4,10 +4,11 @@
4 4 // that macro code is not falsely seen as coming from a different file in dep-info.
5 5 // See https://github.com/rust-lang/rust/issues/36625
6 6
7 -use run_make_support::{fs_wrapper, rustc, target};
7 +use run_make_support::{diff, rustc, target};
8 8
9 9 fn main() {
10 10 rustc().input("foo.rs").run();
11 11 rustc().input("bar.rs").target(target()).emit("dep-info").run();
12 -assert!(!fs_wrapper::read_to_string("bar.d").contains("proc-macro source"));
12 +// The emitted file should not contain "proc-macro source".
13 +diff().expected_file("correct.d").actual_file("bar.d").run();
13 14 }