@@ -60,29 +60,27 @@ crate struct Plan {
60
60
// An object for finding the package which a file belongs to and this inferring
61
61
// a package argument.
62
62
package_map : Option < PackageMap > ,
63
- // The package argument used in the last Cargo build.
64
- prev_package_arg : Option < PackageArg > ,
63
+ /// Packages for which this build plan was prepared.
64
+ /// Used to detect if the plan can reused when building certain packages.
65
+ built_packages : PackageArg ,
65
66
}
66
67
67
68
impl Plan {
68
69
crate fn new ( ) -> Plan {
70
+ Self :: for_packages ( PackageArg :: All )
71
+ }
72
+
73
+ crate fn for_packages ( pkgs : PackageArg ) -> Plan {
69
74
Plan {
70
75
units : HashMap :: new ( ) ,
71
76
dep_graph : HashMap :: new ( ) ,
72
77
rev_dep_graph : HashMap :: new ( ) ,
73
78
compiler_jobs : HashMap :: new ( ) ,
74
79
package_map : None ,
75
- prev_package_arg : None ,
80
+ built_packages : pkgs ,
76
81
}
77
82
}
78
83
79
- crate fn clear ( & mut self ) {
80
- self . units = HashMap :: new ( ) ;
81
- self . dep_graph = HashMap :: new ( ) ;
82
- self . rev_dep_graph = HashMap :: new ( ) ;
83
- self . compiler_jobs = HashMap :: new ( ) ;
84
- }
85
-
86
84
/// Returns whether a build plan has cached compiler invocations and dep
87
85
/// graph so it's at all able to return a job queue via `prepare_work`.
88
86
crate fn is_ready ( & self ) -> bool {
@@ -315,11 +313,7 @@ impl Plan {
315
313
. as_ref ( )
316
314
. unwrap ( )
317
315
. compute_package_arg ( modified) ;
318
- let package_arg_changed = match self . prev_package_arg {
319
- Some ( ref ppa) => ppa != & package_arg,
320
- None => true ,
321
- } ;
322
- self . prev_package_arg = Some ( package_arg. clone ( ) ) ;
316
+ let package_arg_changed = self . built_packages != package_arg;
323
317
324
318
if !self . is_ready ( ) || requested_cargo || package_arg_changed {
325
319
return WorkStatus :: NeedsCargo ( package_arg) ;
@@ -405,7 +399,7 @@ impl PackageMap {
405
399
}
406
400
}
407
401
408
- // Fine each package in the workspace and record the root directory and package name.
402
+ // Find each package in the workspace and record the root directory and package name.
409
403
fn discover_package_paths ( manifest_path : & Path ) -> HashMap < PathBuf , String > {
410
404
trace ! ( "read metadata {:?}" , manifest_path) ;
411
405
let metadata = match cargo_metadata:: metadata ( Some ( manifest_path) ) {
0 commit comments