rewrite remap-path-prefix to rmake
This commit is contained in:
parent
99f77a2eda
commit
acb6078d91
@ -106,6 +106,17 @@ impl Rustc {
|
||||
self
|
||||
}
|
||||
|
||||
/// Remap source path prefixes in all output.
|
||||
pub fn remap_path_prefix<P: AsRef<Path>>(&mut self, from: P, to: P) -> &mut Self {
|
||||
let from = from.as_ref().to_string_lossy();
|
||||
let to = to.as_ref().to_string_lossy();
|
||||
|
||||
self.cmd.arg("--remap-path-prefix");
|
||||
self.cmd.arg(format!("{from}={to}"));
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Specify path to the input file.
|
||||
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
|
||||
self.cmd.arg(path.as_ref());
|
||||
|
@ -1,30 +0,0 @@
|
||||
include ../tools.mk
|
||||
|
||||
# ignore-windows
|
||||
|
||||
ifeq ($(UNAME),Darwin)
|
||||
DEBUGINFOOPTS := -Csplit-debuginfo=off
|
||||
else
|
||||
DEBUGINFOOPTS :=
|
||||
endif
|
||||
|
||||
all: remap remap-with-scope
|
||||
|
||||
# Checks if remapping works if the remap-from string contains path to the working directory plus more
|
||||
remap:
|
||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux --crate-type=lib --emit=metadata auxiliary/lib.rs
|
||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
|
||||
remap-with-scope:
|
||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
|
||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=macro $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
|
||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
58
tests/run-make/remap-path-prefix/rmake.rs
Normal file
58
tests/run-make/remap-path-prefix/rmake.rs
Normal file
@ -0,0 +1,58 @@
|
||||
// Generating metadata alongside remap-path-prefix would fail to actually remap the path
|
||||
// in the metadata. After this was fixed in #85344, this test checks that "auxiliary" is being
|
||||
// successfully remapped to "/the/aux" in the rmeta files.
|
||||
// See https://github.com/rust-lang/rust/pull/85344
|
||||
|
||||
// FIXME(Oneirical): check if works without ignore-windows
|
||||
|
||||
use run_make_support::{invalid_utf8_contains, invalid_utf8_not_contains, is_darwin, rustc};
|
||||
|
||||
fn main() {
|
||||
let mut out_simple = rustc();
|
||||
let mut out_object = rustc();
|
||||
let mut out_macro = rustc();
|
||||
let mut out_diagobj = rustc();
|
||||
out_simple
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_object
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_macro
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_diagobj
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
|
||||
out_simple.run();
|
||||
invalid_utf8_contains("liblib.rmeta", "/the/aux/lib.rs");
|
||||
invalid_utf8_not_contains("liblib.rmeta", "auxiliary");
|
||||
|
||||
out_object.arg("-Zremap-path-scope=object");
|
||||
out_macro.arg("-Zremap-path-scope=macro");
|
||||
out_diagobj.arg("-Zremap-path-scope=diagnostics,object");
|
||||
if is_darwin() {
|
||||
out_object.arg("-Csplit-debuginfo=off");
|
||||
out_macro.arg("-Csplit-debuginfo=off");
|
||||
out_diagobj.arg("-Csplit-debuginfo=off");
|
||||
}
|
||||
|
||||
out_object.run();
|
||||
invalid_utf8_contains("liblib.rmeta", "/the/aux/lib.rs");
|
||||
invalid_utf8_not_contains("liblib.rmeta", "auxiliary");
|
||||
out_macro.run();
|
||||
invalid_utf8_contains("liblib.rmeta", "/the/aux/lib.rs");
|
||||
invalid_utf8_not_contains("liblib.rmeta", "auxiliary");
|
||||
out_diagobj.run();
|
||||
invalid_utf8_contains("liblib.rmeta", "/the/aux/lib.rs");
|
||||
invalid_utf8_not_contains("liblib.rmeta", "auxiliary");
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user