@@ -768,7 +768,7 @@ pub struct UnitFor {
768
768
/// any of its dependencies. This enables `build-override` profiles for
769
769
/// these targets.
770
770
///
771
- /// An invariant is that if `build_dep ` is true, `host` must be true.
771
+ /// An invariant is that if `host_features ` is true, `host` must be true.
772
772
///
773
773
/// Note that this is `true` for `RunCustomBuild` units, even though that
774
774
/// unit should *not* use build-override profiles. This is a bit of a
@@ -779,16 +779,16 @@ pub struct UnitFor {
779
779
/// sticky (and forced to `true` for all further dependencies) — which is
780
780
/// the whole point of `UnitFor`.
781
781
host : bool ,
782
- /// A target for a build dependency (or any of its dependencies). This is
783
- /// used for computing features of build dependencies independently of
784
- /// other dependency kinds.
782
+ /// A target for a build dependency or proc-macro (or any of its
783
+ /// dependencies). This is used for computing features of build
784
+ /// dependencies and proc-macros independently of other dependency kinds.
785
785
///
786
786
/// The subtle difference between this and `host` is that the build script
787
787
/// for a non-host package sets this to `false` because it wants the
788
788
/// features of the non-host package (whereas `host` is true because the
789
- /// build script is being built for the host). `build_dep ` becomes `true`
790
- /// for build-dependencies, or any of their dependencies. For example, with
791
- /// this dependency tree:
789
+ /// build script is being built for the host). `host_features ` becomes
790
+ /// `true` for build-dependencies or proc-macros , or any of their
791
+ /// dependencies. For example, with this dependency tree:
792
792
///
793
793
/// ```text
794
794
/// foo
@@ -799,17 +799,18 @@ pub struct UnitFor {
799
799
/// └── shared_dep build.rs
800
800
/// ```
801
801
///
802
- /// In this example, `foo build.rs` is HOST=true, BUILD_DEP=false. This is
803
- /// so that `foo build.rs` gets the profile settings for build scripts
804
- /// (HOST=true) and features of foo (BUILD_DEP=false) because build scripts
805
- /// need to know which features their package is being built with.
802
+ /// In this example, `foo build.rs` is HOST=true, HOST_FEATURES=false.
803
+ /// This is so that `foo build.rs` gets the profile settings for build
804
+ /// scripts (HOST=true) and features of foo (HOST_FEATURES=false) because
805
+ /// build scripts need to know which features their package is being built
806
+ /// with.
806
807
///
807
808
/// But in the case of `shared_dep`, when built as a build dependency,
808
809
/// both flags are true (it only wants the build-dependency features).
809
810
/// When `shared_dep` is built as a normal dependency, then `shared_dep
810
- /// build.rs` is HOST=true, BUILD_DEP =false for the same reasons that
811
+ /// build.rs` is HOST=true, HOST_FEATURES =false for the same reasons that
811
812
/// foo's build script is set that way.
812
- build_dep : bool ,
813
+ host_features : bool ,
813
814
/// How Cargo processes the `panic` setting or profiles. This is done to
814
815
/// handle test/benches inheriting from dev/release, as well as forcing
815
816
/// `for_host` units to always unwind.
@@ -837,32 +838,35 @@ impl UnitFor {
837
838
pub fn new_normal ( ) -> UnitFor {
838
839
UnitFor {
839
840
host : false ,
840
- build_dep : false ,
841
+ host_features : false ,
841
842
panic_setting : PanicSetting :: ReadProfile ,
842
843
}
843
844
}
844
845
845
- /// A unit for a custom build script or its dependencies.
846
+ /// A unit for a custom build script or proc-macro or its dependencies.
846
847
///
847
- /// The `build_dep ` parameter is whether or not this is for a build
848
- /// dependency. Build scripts for non-host units should use `false`
849
- /// because they want to use the features of the package they are running
850
- /// for.
851
- pub fn new_build ( build_dep : bool ) -> UnitFor {
848
+ /// The `host_features ` parameter is whether or not this is for a build
849
+ /// dependency or proc-macro (something that requires being built "on the
850
+ /// host"). Build scripts for non-host units should use `false` because
851
+ /// they want to use the features of the package they are running for.
852
+ pub fn new_host ( host_features : bool ) -> UnitFor {
852
853
UnitFor {
853
854
host : true ,
854
- build_dep ,
855
+ host_features ,
855
856
// Force build scripts to always use `panic=unwind` for now to
856
857
// maximally share dependencies with procedural macros.
857
858
panic_setting : PanicSetting :: AlwaysUnwind ,
858
859
}
859
860
}
860
861
861
- /// A unit for a proc macro or compiler plugin or their dependencies.
862
+ /// A unit for a compiler plugin or their dependencies.
862
863
pub fn new_compiler ( ) -> UnitFor {
863
864
UnitFor {
864
865
host : false ,
865
- build_dep : false ,
866
+ // The feature resolver doesn't know which dependencies are
867
+ // plugins, so for now plugins don't split features. Since plugins
868
+ // are mostly deprecated, just leave this as false.
869
+ host_features : false ,
866
870
// Force plugins to use `panic=abort` so panics in the compiler do
867
871
// not abort the process but instead end with a reasonable error
868
872
// message that involves catching the panic in the compiler.
@@ -879,7 +883,7 @@ impl UnitFor {
879
883
pub fn new_test ( config : & Config ) -> UnitFor {
880
884
UnitFor {
881
885
host : false ,
882
- build_dep : false ,
886
+ host_features : false ,
883
887
// We're testing out an unstable feature (`-Zpanic-abort-tests`)
884
888
// which inherits the panic setting from the dev/release profile
885
889
// (basically avoid recompiles) but historical defaults required
@@ -902,7 +906,7 @@ impl UnitFor {
902
906
pub fn with_for_host ( self , for_host : bool ) -> UnitFor {
903
907
UnitFor {
904
908
host : self . host || for_host,
905
- build_dep : self . build_dep ,
909
+ host_features : self . host_features ,
906
910
panic_setting : if for_host {
907
911
PanicSetting :: AlwaysUnwind
908
912
} else {
@@ -911,15 +915,16 @@ impl UnitFor {
911
915
}
912
916
}
913
917
914
- /// Returns a new copy updating it for a build dependency.
918
+ /// Returns a new copy updating it whether or not it should use features
919
+ /// for build dependencies and proc-macros.
915
920
///
916
921
/// This is part of the machinery responsible for handling feature
917
922
/// decoupling for build dependencies in the new feature resolver.
918
- pub fn with_build_dep ( mut self , build_dep : bool ) -> UnitFor {
919
- if build_dep {
923
+ pub fn with_host_features ( mut self , host_features : bool ) -> UnitFor {
924
+ if host_features {
920
925
assert ! ( self . host) ;
921
926
}
922
- self . build_dep = self . build_dep || build_dep ;
927
+ self . host_features = self . host_features || host_features ;
923
928
self
924
929
}
925
930
@@ -929,8 +934,8 @@ impl UnitFor {
929
934
self . host
930
935
}
931
936
932
- pub fn is_for_build_dep ( & self ) -> bool {
933
- self . build_dep
937
+ pub fn is_for_host_features ( & self ) -> bool {
938
+ self . host_features
934
939
}
935
940
936
941
/// Returns how `panic` settings should be handled for this profile
@@ -943,43 +948,43 @@ impl UnitFor {
943
948
static ALL : & [ UnitFor ] = & [
944
949
UnitFor {
945
950
host : false ,
946
- build_dep : false ,
951
+ host_features : false ,
947
952
panic_setting : PanicSetting :: ReadProfile ,
948
953
} ,
949
954
UnitFor {
950
955
host : true ,
951
- build_dep : false ,
956
+ host_features : false ,
952
957
panic_setting : PanicSetting :: AlwaysUnwind ,
953
958
} ,
954
959
UnitFor {
955
960
host : false ,
956
- build_dep : false ,
961
+ host_features : false ,
957
962
panic_setting : PanicSetting :: AlwaysUnwind ,
958
963
} ,
959
964
UnitFor {
960
965
host : false ,
961
- build_dep : false ,
966
+ host_features : false ,
962
967
panic_setting : PanicSetting :: Inherit ,
963
968
} ,
964
- // build_dep =true must always have host=true
969
+ // host_features =true must always have host=true
965
970
// `Inherit` is not used in build dependencies.
966
971
UnitFor {
967
972
host : true ,
968
- build_dep : true ,
973
+ host_features : true ,
969
974
panic_setting : PanicSetting :: ReadProfile ,
970
975
} ,
971
976
UnitFor {
972
977
host : true ,
973
- build_dep : true ,
978
+ host_features : true ,
974
979
panic_setting : PanicSetting :: AlwaysUnwind ,
975
980
} ,
976
981
] ;
977
982
ALL
978
983
}
979
984
980
985
pub ( crate ) fn map_to_features_for ( & self ) -> FeaturesFor {
981
- if self . is_for_build_dep ( ) {
982
- FeaturesFor :: BuildDep
986
+ if self . is_for_host_features ( ) {
987
+ FeaturesFor :: HostDep
983
988
} else {
984
989
FeaturesFor :: NormalOrDev
985
990
}
0 commit comments