@@ -533,7 +533,7 @@ pub struct Target {
533
533
pub linker : Option < PathBuf > ,
534
534
pub ndk : Option < PathBuf > ,
535
535
pub sanitizers : Option < bool > ,
536
- pub profiler : Option < bool > ,
536
+ pub profiler : Option < StringOrBool > ,
537
537
pub rpath : Option < bool > ,
538
538
pub crt_static : Option < bool > ,
539
539
pub musl_root : Option < PathBuf > ,
@@ -862,9 +862,9 @@ define_config! {
862
862
}
863
863
}
864
864
865
- #[ derive( Debug , Deserialize ) ]
865
+ #[ derive( Clone , Debug , Deserialize ) ]
866
866
#[ serde( untagged) ]
867
- enum StringOrBool {
867
+ pub enum StringOrBool {
868
868
String ( String ) ,
869
869
Bool ( bool ) ,
870
870
}
@@ -875,6 +875,12 @@ impl Default for StringOrBool {
875
875
}
876
876
}
877
877
878
+ impl StringOrBool {
879
+ fn is_string_or_true ( & self ) -> bool {
880
+ matches ! ( self , Self :: String ( _) | Self :: Bool ( true ) )
881
+ }
882
+ }
883
+
878
884
#[ derive( Clone , Debug , PartialEq , Eq ) ]
879
885
pub enum RustOptimize {
880
886
String ( String ) ,
@@ -1038,7 +1044,7 @@ define_config! {
1038
1044
llvm_libunwind: Option <String > = "llvm-libunwind" ,
1039
1045
android_ndk: Option <String > = "android-ndk" ,
1040
1046
sanitizers: Option <bool > = "sanitizers" ,
1041
- profiler: Option <bool > = "profiler" ,
1047
+ profiler: Option <StringOrBool > = "profiler" ,
1042
1048
rpath: Option <bool > = "rpath" ,
1043
1049
crt_static: Option <bool > = "crt-static" ,
1044
1050
musl_root: Option <String > = "musl-root" ,
@@ -1951,12 +1957,24 @@ impl Config {
1951
1957
self . target_config . values ( ) . any ( |t| t. sanitizers == Some ( true ) ) || self . sanitizers
1952
1958
}
1953
1959
1960
+ pub fn profiler_path ( & self , target : TargetSelection ) -> Option < & str > {
1961
+ match self . target_config . get ( & target) ?. profiler . as_ref ( ) ? {
1962
+ StringOrBool :: String ( s) => Some ( s) ,
1963
+ StringOrBool :: Bool ( _) => None ,
1964
+ }
1965
+ }
1966
+
1954
1967
pub fn profiler_enabled ( & self , target : TargetSelection ) -> bool {
1955
- self . target_config . get ( & target) . map ( |t| t. profiler ) . flatten ( ) . unwrap_or ( self . profiler )
1968
+ self . target_config
1969
+ . get ( & target)
1970
+ . and_then ( |t| t. profiler . as_ref ( ) )
1971
+ . map ( StringOrBool :: is_string_or_true)
1972
+ . unwrap_or ( self . profiler )
1956
1973
}
1957
1974
1958
1975
pub fn any_profiler_enabled ( & self ) -> bool {
1959
- self . target_config . values ( ) . any ( |t| t. profiler == Some ( true ) ) || self . profiler
1976
+ self . target_config . values ( ) . any ( |t| matches ! ( & t. profiler, Some ( p) if p. is_string_or_true( ) ) )
1977
+ || self . profiler
1960
1978
}
1961
1979
1962
1980
pub fn rpath_enabled ( & self , target : TargetSelection ) -> bool {
0 commit comments