@@ -878,20 +878,26 @@ fn custom_build_script_rustc_flags() {
878878 "foo/build.rs" ,
879879 r#"
880880 fn main() {
881- println!("cargo::rustc-flags=-l nonexistinglib -L /dummy/path1 -L /dummy/path2");
881+ let root = std::env::current_dir().unwrap();
882+ let root = root.parent().unwrap();
883+ println!("cargo::rustc-flags=-l nonexistinglib \
884+ -L {R}/dummy-path1 -L {R}/dummy-path2", R=root.display());
882885 }
883886 "# ,
884887 )
885888 . build ( ) ;
889+ p. root ( ) . join ( "dummy-path1" ) . mkdir_p ( ) ;
890+ p. root ( ) . join ( "dummy-path2" ) . mkdir_p ( ) ;
886891
887- p. cargo ( "build --verbose" ) . with_stderr_data ( str![ [ r#"
892+ p. cargo ( "build --verbose" )
893+ . with_stderr_data ( str![ [ r#"
888894[LOCKING] 1 package to latest compatible version
889895[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
890896[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
891897[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
892- [RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L /dummy/ path1 -L /dummy/ path2 -l nonexistinglib`
898+ [RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L [ROOT]/foo/dummy- path1 -L [ROOT]/foo/dummy- path2 -l nonexistinglib`
893899[COMPILING] bar v0.5.0 ([ROOT]/foo)
894- [RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L /dummy/ path1 -L /dummy/ path2`
900+ [RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L [ROOT]/foo/dummy- path1 -L [ROOT]/foo/dummy- path2`
895901[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
896902
897903"# ] ] ) . run ( ) ;
@@ -932,20 +938,25 @@ fn custom_build_script_rustc_flags_no_space() {
932938 "foo/build.rs" ,
933939 r#"
934940 fn main() {
935- println!("cargo::rustc-flags=-lnonexistinglib -L/dummy/path1 -L/dummy/path2");
941+ let root = std::env::current_dir().unwrap();
942+ let root = root.parent().unwrap();
943+ println!("cargo::rustc-flags=-lnonexistinglib \
944+ -L {R}/dummy-path1 -L {R}/dummy-path2", R=root.display());
936945 }
937946 "# ,
938947 )
939948 . build ( ) ;
949+ p. root ( ) . join ( "dummy-path1" ) . mkdir_p ( ) ;
950+ p. root ( ) . join ( "dummy-path2" ) . mkdir_p ( ) ;
940951
941952 p. cargo ( "build --verbose" ) . with_stderr_data ( str![ [ r#"
942953[LOCKING] 1 package to latest compatible version
943954[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
944955[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
945956[RUNNING] `[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build`
946- [RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L /dummy/ path1 -L /dummy/ path2 -l nonexistinglib`
957+ [RUNNING] `rustc --crate-name foo --edition=2015 foo/src/lib.rs [..]-L dependency=[ROOT]/foo/target/debug/deps -L [ROOT]/foo/dummy- path1 -L [ROOT]/foo/dummy- path2 -l nonexistinglib`
947958[COMPILING] bar v0.5.0 ([ROOT]/foo)
948- [RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L /dummy/ path1 -L /dummy/ path2`
959+ [RUNNING] `rustc --crate-name bar --edition=2015 src/main.rs [..]-L dependency=[ROOT]/foo/target/debug/deps --extern foo=[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib -L [ROOT]/foo/dummy- path1 -L [ROOT]/foo/dummy- path2`
949960[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
950961
951962"# ] ] ) . run ( ) ;
@@ -2975,24 +2986,26 @@ fn flags_go_into_tests() {
29752986 "a/build.rs" ,
29762987 r#"
29772988 fn main() {
2978- println!("cargo::rustc-link-search=test");
2989+ let path = std::env::current_dir().unwrap().parent().unwrap().join("link-dir");
2990+ println!("cargo::rustc-link-search={}", path.display());
29792991 }
29802992 "# ,
29812993 )
29822994 . build ( ) ;
2995+ p. root ( ) . join ( "link-dir" ) . mkdir_p ( ) ;
29832996
29842997 p. cargo ( "test -v --test=foo" )
29852998 . with_stderr_data ( str![ [ r#"
29862999[LOCKING] 2 packages to latest compatible versions
29873000[COMPILING] a v0.5.0 ([ROOT]/foo/a)
29883001[RUNNING] `rustc [..] a/build.rs [..]`
29893002[RUNNING] `[ROOT]/foo/target/debug/build/a-[HASH]/build-script-build`
2990- [RUNNING] `rustc [..] a/src/lib.rs [..] -L test `
3003+ [RUNNING] `rustc [..] a/src/lib.rs [..] -L [ROOT]/foo/link-dir `
29913004[COMPILING] b v0.5.0 ([ROOT]/foo/b)
2992- [RUNNING] `rustc [..] b/src/lib.rs [..] -L test `
3005+ [RUNNING] `rustc [..] b/src/lib.rs [..] -L [ROOT]/foo/link-dir `
29933006[COMPILING] foo v0.5.0 ([ROOT]/foo)
2994- [RUNNING] `rustc [..] src/lib.rs [..] -L test `
2995- [RUNNING] `rustc [..] tests/foo.rs [..] -L test `
3007+ [RUNNING] `rustc [..] src/lib.rs [..] -L [ROOT]/foo/link-dir `
3008+ [RUNNING] `rustc [..] tests/foo.rs [..] -L [ROOT]/foo/link-dir `
29963009[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
29973010[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
29983011
@@ -3011,7 +3024,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
30113024 . with_stderr_data ( str![ [ r#"
30123025[FRESH] a v0.5.0 ([ROOT]/foo/a)
30133026[COMPILING] b v0.5.0 ([ROOT]/foo/b)
3014- [RUNNING] `rustc --crate-name b [..] -L test `
3027+ [RUNNING] `rustc --crate-name b [..] -L [ROOT]/foo/link-dir `
30153028[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
30163029[RUNNING] `[ROOT]/foo/target/debug/deps/b-[HASH][EXE]`
30173030
0 commit comments