Skip to content

Commit fe76650

Browse files
committed
rewrite env-dep-info to rmake
1 parent 87c7a42 commit fe76650

File tree

9 files changed

+47
-27
lines changed

9 files changed

+47
-27
lines changed

src/tools/run-make-support/src/rustc.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ use std::path::Path;
44

55
use crate::{command, cwd, env_var, set_host_rpath};
66

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.
89
#[track_caller]
910
pub fn rustc() -> Rustc {
1011
Rustc::new()
1112
}
1213

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.
1416
#[track_caller]
1517
pub fn bare_rustc() -> Rustc {
1618
Rustc::bare()
@@ -42,7 +44,8 @@ fn setup_common() -> Command {
4244
impl Rustc {
4345
// `rustc` invocation constructor methods
4446

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.
4649
#[track_caller]
4750
pub fn new() -> Self {
4851
let mut cmd = setup_common();

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ run-make/dep-info/Makefile
2323
run-make/dump-ice-to-disk/Makefile
2424
run-make/dump-mono-stats/Makefile
2525
run-make/emit-to-stdout/Makefile
26-
run-make/env-dep-info/Makefile
2726
run-make/export-executable-symbols/Makefile
2827
run-make/extern-diff-internal-name/Makefile
2928
run-make/extern-flag-disambiguates/Makefile
@@ -58,7 +57,6 @@ run-make/issue-35164/Makefile
5857
run-make/issue-36710/Makefile
5958
run-make/issue-47551/Makefile
6059
run-make/issue-69368/Makefile
61-
run-make/issue-83045/Makefile
6260
run-make/issue-84395-lto-embed-bitcode/Makefile
6361
run-make/issue-85019-moved-src-dir/Makefile
6462
run-make/issue-85401-static-mir/Makefile

tests/run-make/env-dep-info/Makefile

-19
This file was deleted.
Original file line numberDiff line numberDiff 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 numberDiff line numberDiff 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

tests/run-make/env-dep-info/rmake.rs

+21
Original file line numberDiff line numberDiff 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+
}

tests/run-make/ice-dep-cannot-find-dep/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn main() {
2727
.input("b.rs")
2828
.arg("--verbose")
2929
.run();
30-
fs_wrapper::create_dir("wrong_directory");
3130
bare_rustc()
3231
.extern_("b", rust_lib_name("b"))
3332
.crate_type("rlib")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
bar.d: bar.rs
2+
3+
bar.rs:

tests/run-make/rustc-macro-dep-files/rmake.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
// that macro code is not falsely seen as coming from a different file in dep-info.
55
// See https://github.com/rust-lang/rust/issues/36625
66

7-
use run_make_support::{fs_wrapper, rustc, target};
7+
use run_make_support::{diff, rustc, target};
88

99
fn main() {
1010
rustc().input("foo.rs").run();
1111
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();
1314
}

0 commit comments

Comments
 (0)