@@ -40,6 +40,7 @@ pub struct Context<'a, 'cfg: 'a> {
40
40
pub compilation : Compilation < ' cfg > ,
41
41
pub packages : & ' a PackageSet < ' cfg > ,
42
42
pub build_state : Arc < BuildState > ,
43
+ pub build_script_overridden : HashSet < ( PackageId , Kind ) > ,
43
44
pub build_explicit_deps : HashMap < Unit < ' a > , BuildDeps > ,
44
45
pub fingerprints : HashMap < Unit < ' a > , Arc < Fingerprint > > ,
45
46
pub compiled : HashSet < Unit < ' a > > ,
@@ -156,6 +157,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
156
157
used_in_plugin : HashSet :: new ( ) ,
157
158
incremental_enabled : incremental_enabled,
158
159
jobserver : jobserver,
160
+ build_script_overridden : HashSet :: new ( ) ,
159
161
160
162
// TODO: Pre-Calculate these with a topo-sort, rather than lazy-calculating
161
163
target_filenames : HashMap :: new ( ) ,
@@ -499,7 +501,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
499
501
self . resolve . features_sorted ( unit. pkg . package_id ( ) ) . hash ( & mut hasher) ;
500
502
501
503
// Mix in the target-metadata of all the dependencies of this target
502
- if let Ok ( deps) = self . used_deps ( unit) {
504
+ if let Ok ( deps) = self . dep_targets ( unit) {
503
505
let mut deps_metadata = deps. into_iter ( ) . map ( |dep_unit| {
504
506
self . target_metadata ( & dep_unit)
505
507
} ) . collect :: < Vec < _ > > ( ) ;
@@ -695,10 +697,18 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
695
697
Ok ( Arc :: new ( ret) )
696
698
}
697
699
698
- fn used_deps ( & self , unit : & Unit < ' a > ) -> CargoResult < Vec < Unit < ' a > > > {
700
+ /// For a package, return all targets which are registered as dependencies
701
+ /// for that package.
702
+ pub fn dep_targets ( & self , unit : & Unit < ' a > ) -> CargoResult < Vec < Unit < ' a > > > {
703
+ if unit. profile . run_custom_build {
704
+ return self . dep_run_custom_build ( unit)
705
+ } else if unit. profile . doc && !unit. profile . test {
706
+ return self . doc_deps ( unit) ;
707
+ }
708
+
699
709
let id = unit. pkg . package_id ( ) ;
700
710
let deps = self . resolve . deps ( id) ;
701
- deps. filter ( |dep| {
711
+ let mut ret = deps. filter ( |dep| {
702
712
unit. pkg . dependencies ( ) . iter ( ) . filter ( |d| {
703
713
d. name ( ) == dep. name ( ) && d. version_req ( ) . matches ( dep. version ( ) )
704
714
} ) . any ( |d| {
@@ -747,20 +757,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
747
757
}
748
758
Err ( e) => Some ( Err ( e) )
749
759
}
750
- } ) . collect :: < CargoResult < Vec < _ > > > ( )
751
- }
752
-
753
- /// For a package, return all targets which are registered as dependencies
754
- /// for that package.
755
- pub fn dep_targets ( & self , unit : & Unit < ' a > ) -> CargoResult < Vec < Unit < ' a > > > {
756
- if unit. profile . run_custom_build {
757
- return self . dep_run_custom_build ( unit)
758
- } else if unit. profile . doc && !unit. profile . test {
759
- return self . doc_deps ( unit) ;
760
- }
761
-
762
- let id = unit. pkg . package_id ( ) ;
763
- let mut ret = self . used_deps ( unit) ?;
760
+ } ) . collect :: < CargoResult < Vec < _ > > > ( ) ?;
764
761
765
762
// If this target is a build script, then what we've collected so far is
766
763
// all we need. If this isn't a build script, then it depends on the
@@ -812,7 +809,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
812
809
// actually depend on anything, we've reached the end of the dependency
813
810
// chain as we've got all the info we're gonna get.
814
811
let key = ( unit. pkg . package_id ( ) . clone ( ) , unit. kind ) ;
815
- if self . build_state . outputs . lock ( ) . unwrap ( ) . contains_key ( & key) {
812
+ if self . build_script_overridden . contains ( & key) {
816
813
return Ok ( Vec :: new ( ) )
817
814
}
818
815
0 commit comments