@@ -533,7 +533,7 @@ pub struct Target {
533533 pub linker : Option < PathBuf > ,
534534 pub ndk : Option < PathBuf > ,
535535 pub sanitizers : Option < bool > ,
536- pub profiler : Option < bool > ,
536+ pub profiler : Option < StringOrBool > ,
537537 pub rpath : Option < bool > ,
538538 pub crt_static : Option < bool > ,
539539 pub musl_root : Option < PathBuf > ,
@@ -862,9 +862,9 @@ define_config! {
862862 }
863863}
864864
865- #[ derive( Debug , Deserialize ) ]
865+ #[ derive( Clone , Debug , Deserialize ) ]
866866#[ serde( untagged) ]
867- enum StringOrBool {
867+ pub enum StringOrBool {
868868 String ( String ) ,
869869 Bool ( bool ) ,
870870}
@@ -875,6 +875,12 @@ impl Default for StringOrBool {
875875 }
876876}
877877
878+ impl StringOrBool {
879+ fn is_string_or_true ( & self ) -> bool {
880+ matches ! ( self , Self :: String ( _) | Self :: Bool ( true ) )
881+ }
882+ }
883+
878884#[ derive( Clone , Debug , PartialEq , Eq ) ]
879885pub enum RustOptimize {
880886 String ( String ) ,
@@ -1038,7 +1044,7 @@ define_config! {
10381044 llvm_libunwind: Option <String > = "llvm-libunwind" ,
10391045 android_ndk: Option <String > = "android-ndk" ,
10401046 sanitizers: Option <bool > = "sanitizers" ,
1041- profiler: Option <bool > = "profiler" ,
1047+ profiler: Option <StringOrBool > = "profiler" ,
10421048 rpath: Option <bool > = "rpath" ,
10431049 crt_static: Option <bool > = "crt-static" ,
10441050 musl_root: Option <String > = "musl-root" ,
@@ -1951,12 +1957,24 @@ impl Config {
19511957 self . target_config . values ( ) . any ( |t| t. sanitizers == Some ( true ) ) || self . sanitizers
19521958 }
19531959
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+
19541967 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 )
19561973 }
19571974
19581975 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
19601978 }
19611979
19621980 pub fn rpath_enabled ( & self , target : TargetSelection ) -> bool {
0 commit comments