@@ -695,11 +695,13 @@ struct WorkspacePackageSettings {
695695}
696696
697697#[ derive( Clone , Debug , Deserialize ) ]
698+ #[ serde( rename_all = "kebab-case" ) ]
698699struct BinarySettings {
699700 name : String ,
700701 /// This is from nightly: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#different-binary-name
701702 filename : Option < String > ,
702703 path : Option < String > ,
704+ required_features : Option < Vec < String > > ,
703705}
704706
705707impl BinarySettings {
@@ -919,7 +921,7 @@ impl AppSettings for RustAppSettings {
919921 }
920922
921923 fn app_binary_path ( & self , options : & Options ) -> crate :: Result < PathBuf > {
922- let binaries = self . get_binaries ( ) ?;
924+ let binaries = self . get_binaries ( options ) ?;
923925 let bin_name = binaries
924926 . iter ( )
925927 . find ( |x| x. main ( ) )
@@ -945,8 +947,8 @@ impl AppSettings for RustAppSettings {
945947 Ok ( path)
946948 }
947949
948- fn get_binaries ( & self ) -> crate :: Result < Vec < BundleBinary > > {
949- let mut binaries: Vec < BundleBinary > = vec ! [ ] ;
950+ fn get_binaries ( & self , options : & Options ) -> crate :: Result < Vec < BundleBinary > > {
951+ let mut binaries = Vec :: new ( ) ;
950952
951953 if let Some ( bins) = & self . cargo_settings . bin {
952954 let default_run = self
@@ -955,6 +957,14 @@ impl AppSettings for RustAppSettings {
955957 . clone ( )
956958 . unwrap_or_default ( ) ;
957959 for bin in bins {
960+ if let ( Some ( req_features) , Some ( opt_features) ) =
961+ ( & bin. required_features , & options. features )
962+ {
963+ // Check if all required features are enabled.
964+ if !req_features. iter ( ) . all ( |feat| opt_features. contains ( feat) ) {
965+ continue ;
966+ }
967+ }
958968 let file_name = bin. file_name ( ) ;
959969 let is_main = file_name == self . cargo_package_settings . name || file_name == default_run;
960970 binaries. push ( BundleBinary :: with_path (
@@ -1659,7 +1669,7 @@ mod tests {
16591669
16601670 #[ test]
16611671 fn parse_cargo_option ( ) {
1662- let args = vec ! [
1672+ let args = [
16631673 "build" . into ( ) ,
16641674 "--" . into ( ) ,
16651675 "--profile" . into ( ) ,
0 commit comments