@@ -838,12 +838,12 @@ pub fn run_cargo(
838
838
let mut deps = Vec :: new ( ) ;
839
839
let mut toplevel = Vec :: new ( ) ;
840
840
let ok = stream_cargo ( builder, cargo, tail_args, & mut |msg| {
841
- let ( filenames, crate_types) = match msg {
841
+ let ( filenames, crate_types, kind , name ) = match msg {
842
842
CargoMessage :: CompilerArtifact {
843
843
filenames,
844
- target : CargoTarget { crate_types } ,
844
+ target : CargoTarget { crate_types, kind , name } ,
845
845
..
846
- } => ( filenames, crate_types) ,
846
+ } => ( filenames, crate_types, kind , name ) ,
847
847
_ => return ,
848
848
} ;
849
849
for filename in filenames {
@@ -859,13 +859,25 @@ pub fn run_cargo(
859
859
860
860
let filename = Path :: new ( & * filename) ;
861
861
862
- // If this was an output file in the "host dir" we don't actually
863
- // worry about it, it's not relevant for us
862
+ // If this was an output file in the "host dir", we want
863
+ // to ignore it if it's a build script.
864
864
if filename. starts_with ( & host_root_dir) {
865
- // Unless it's a proc macro used in the compiler
866
865
if crate_types. iter ( ) . any ( |t| t == "proc-macro" ) {
867
866
deps. push ( ( filename. to_path_buf ( ) , true ) ) ;
868
867
}
868
+
869
+ let is_build_script = kind == & [ "custom_build" ]
870
+ && crate_types == & [ "bin" ]
871
+ && name == "build-script-build" ;
872
+ // We don't care about build scripts, but we *do* care about proc-macro
873
+ // dependencies - the compiler needs their metadata when loading proc-macro
874
+ // crates. Anything that's not a build script should be a proc-macro dependency.
875
+ //
876
+ // FIXME: Have Cargo explicitly indicate build-script vs proc-macro dependencies,
877
+ // instead of relying on this check.
878
+ if !is_build_script {
879
+ deps. push ( ( filename. to_path_buf ( ) , false ) ) ;
880
+ }
869
881
continue ;
870
882
}
871
883
@@ -1003,6 +1015,8 @@ pub fn stream_cargo(
1003
1015
#[ derive( Deserialize ) ]
1004
1016
pub struct CargoTarget < ' a > {
1005
1017
crate_types : Vec < Cow < ' a , str > > ,
1018
+ kind : Vec < Cow < ' a , str > > ,
1019
+ name : Cow < ' a , str > ,
1006
1020
}
1007
1021
1008
1022
#[ derive( Deserialize ) ]
0 commit comments