@@ -878,20 +878,26 @@ fn custom_build_script_rustc_flags() {
878
878
"foo/build.rs" ,
879
879
r#"
880
880
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());
882
885
}
883
886
"# ,
884
887
)
885
888
. build ( ) ;
889
+ p. root ( ) . join ( "dummy-path1" ) . mkdir_p ( ) ;
890
+ p. root ( ) . join ( "dummy-path2" ) . mkdir_p ( ) ;
886
891
887
- p. cargo ( "build --verbose" ) . with_stderr_data ( str![ [ r#"
892
+ p. cargo ( "build --verbose" )
893
+ . with_stderr_data ( str![ [ r#"
888
894
[LOCKING] 1 package to latest compatible version
889
895
[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
890
896
[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
891
897
[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`
893
899
[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`
895
901
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
896
902
897
903
"# ] ] ) . run ( ) ;
@@ -932,20 +938,25 @@ fn custom_build_script_rustc_flags_no_space() {
932
938
"foo/build.rs" ,
933
939
r#"
934
940
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());
936
945
}
937
946
"# ,
938
947
)
939
948
. build ( ) ;
949
+ p. root ( ) . join ( "dummy-path1" ) . mkdir_p ( ) ;
950
+ p. root ( ) . join ( "dummy-path2" ) . mkdir_p ( ) ;
940
951
941
952
p. cargo ( "build --verbose" ) . with_stderr_data ( str![ [ r#"
942
953
[LOCKING] 1 package to latest compatible version
943
954
[COMPILING] foo v0.5.0 ([ROOT]/foo/foo)
944
955
[RUNNING] `rustc --crate-name build_script_build --edition=2015 foo/build.rs [..]`
945
956
[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`
947
958
[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`
949
960
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
950
961
951
962
"# ] ] ) . run ( ) ;
@@ -2975,24 +2986,26 @@ fn flags_go_into_tests() {
2975
2986
"a/build.rs" ,
2976
2987
r#"
2977
2988
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());
2979
2991
}
2980
2992
"# ,
2981
2993
)
2982
2994
. build ( ) ;
2995
+ p. root ( ) . join ( "link-dir" ) . mkdir_p ( ) ;
2983
2996
2984
2997
p. cargo ( "test -v --test=foo" )
2985
2998
. with_stderr_data ( str![ [ r#"
2986
2999
[LOCKING] 2 packages to latest compatible versions
2987
3000
[COMPILING] a v0.5.0 ([ROOT]/foo/a)
2988
3001
[RUNNING] `rustc [..] a/build.rs [..]`
2989
3002
[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 `
2991
3004
[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 `
2993
3006
[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 `
2996
3009
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
2997
3010
[RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH][EXE]`
2998
3011
@@ -3011,7 +3024,7 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
3011
3024
. with_stderr_data ( str![ [ r#"
3012
3025
[FRESH] a v0.5.0 ([ROOT]/foo/a)
3013
3026
[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 `
3015
3028
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
3016
3029
[RUNNING] `[ROOT]/foo/target/debug/deps/b-[HASH][EXE]`
3017
3030
0 commit comments