1- use std:: collections:: HashMap ;
2- use std:: collections:: HashSet ;
31use std:: path:: PathBuf ;
42use std:: process:: Command ;
53
@@ -12,7 +10,6 @@ use crate::{Build, Crate};
1210#[ derive( Deserialize ) ]
1311struct Output {
1412 packages : Vec < Package > ,
15- resolve : Resolve ,
1613}
1714
1815#[ derive( Deserialize ) ]
@@ -21,65 +18,39 @@ struct Package {
2118 name : String ,
2219 source : Option < String > ,
2320 manifest_path : String ,
21+ dependencies : Vec < Dependency > ,
2422}
2523
2624#[ derive( Deserialize ) ]
27- struct Resolve {
28- nodes : Vec < ResolveNode > ,
29- }
30-
31- #[ derive( Deserialize ) ]
32- struct ResolveNode {
33- id : String ,
34- dependencies : Vec < String > ,
25+ struct Dependency {
26+ name : String ,
27+ source : Option < String > ,
3528}
3629
3730pub fn build ( build : & mut Build ) {
3831 // Run `cargo metadata` to figure out what crates we're testing.
39- let features: Vec < _ > = build
40- . std_features ( )
41- . split_whitespace ( )
42- . map ( |f| format ! ( "test/{}" , f) )
43- . chain ( build. rustc_features ( ) . split_whitespace ( ) . map ( |f| format ! ( "rustc-main/{}" , f) ) )
44- . collect ( ) ;
4532 let mut cargo = Command :: new ( & build. initial_cargo ) ;
4633 cargo
4734 . arg ( "metadata" )
4835 . arg ( "--format-version" )
4936 . arg ( "1" )
50- . arg ( "--features" )
51- . arg ( features. join ( "," ) )
52- . arg ( "-Zpackage-features" )
37+ . arg ( "--no-deps" )
5338 . arg ( "--manifest-path" )
54- . arg ( build. src . join ( "Cargo.toml" ) )
55- . env ( "RUSTC_BOOTSTRAP" , "1" ) ;
39+ . arg ( build. src . join ( "Cargo.toml" ) ) ;
5640 let output = output ( & mut cargo) ;
5741 let output: Output = serde_json:: from_str ( & output) . unwrap ( ) ;
5842 for package in output. packages {
5943 if package. source . is_none ( ) {
6044 let name = INTERNER . intern_string ( package. name ) ;
6145 let mut path = PathBuf :: from ( package. manifest_path ) ;
6246 path. pop ( ) ;
63- build. crates . insert ( name, Crate { name, id : package. id , deps : HashSet :: new ( ) , path } ) ;
64- }
65- }
66-
67- let id2name: HashMap < _ , _ > =
68- build. crates . iter ( ) . map ( |( name, krate) | ( krate. id . clone ( ) , name. clone ( ) ) ) . collect ( ) ;
69-
70- for node in output. resolve . nodes {
71- let name = match id2name. get ( & node. id ) {
72- Some ( name) => name,
73- None => continue ,
74- } ;
75-
76- let krate = build. crates . get_mut ( name) . unwrap ( ) ;
77- for dep in node. dependencies . iter ( ) {
78- let dep = match id2name. get ( dep) {
79- Some ( dep) => dep,
80- None => continue ,
81- } ;
82- krate. deps . insert ( * dep) ;
47+ let deps = package
48+ . dependencies
49+ . into_iter ( )
50+ . filter ( |dep| dep. source . is_none ( ) )
51+ . map ( |dep| INTERNER . intern_string ( dep. name ) )
52+ . collect ( ) ;
53+ build. crates . insert ( name, Crate { name, id : package. id , deps, path } ) ;
8354 }
8455 }
8556}
0 commit comments