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