@@ -111,6 +111,12 @@ struct Install {
111111 /// the directory the command is called.
112112 #[ arg( long) ]
113113 manifest : Option < PathBuf > ,
114+ #[ arg( short = 'F' , long, num_args = 1 ..) ]
115+ features : Option < Vec < String > > ,
116+ #[ arg( long) ]
117+ all_features : bool ,
118+ #[ arg( long) ]
119+ no_default_features : bool ,
114120 /// Whether to bypass the install prompt.
115121 #[ clap( long) ]
116122 yes : bool ,
@@ -156,6 +162,12 @@ struct Stubs {
156162 /// provides a direct path to the extension shared library.
157163 #[ arg( long, conflicts_with = "ext" ) ]
158164 manifest : Option < PathBuf > ,
165+ #[ arg( short = 'F' , long, num_args = 1 ..) ]
166+ features : Option < Vec < String > > ,
167+ #[ arg( long) ]
168+ all_features : bool ,
169+ #[ arg( long) ]
170+ no_default_features : bool ,
159171}
160172
161173impl Args {
@@ -172,7 +184,7 @@ impl Args {
172184impl Install {
173185 pub fn handle ( self ) -> CrateResult {
174186 let artifact = find_ext ( self . manifest . as_ref ( ) ) ?;
175- let ext_path = build_ext ( & artifact, self . release ) ?;
187+ let ext_path = build_ext ( & artifact, self . release , self . features , self . all_features , self . no_default_features ) ?;
176188
177189 let ( mut ext_dir, mut php_ini) = if let Some ( install_dir) = self . install_dir {
178190 ( install_dir, None )
@@ -371,7 +383,7 @@ impl Stubs {
371383 ext_path
372384 } else {
373385 let target = find_ext ( self . manifest . as_ref ( ) ) ?;
374- build_ext ( & target, false ) ?. into ( )
386+ build_ext ( & target, false , self . features , self . all_features , self . no_default_features ) ?. into ( )
375387 } ;
376388
377389 if !ext_path. is_file ( ) {
@@ -469,17 +481,38 @@ fn find_ext(manifest: Option<&PathBuf>) -> AResult<cargo_metadata::Target> {
469481///
470482/// * `target` - The target to compile.
471483/// * `release` - Whether to compile the target in release mode.
484+ /// * `features` - Optional list of features.
472485///
473486/// # Returns
474487///
475488/// The path to the target artifact.
476- fn build_ext ( target : & Target , release : bool ) -> AResult < Utf8PathBuf > {
489+ fn build_ext (
490+ target : & Target ,
491+ release : bool ,
492+ features : Option < Vec < String > > ,
493+ all_features : bool ,
494+ no_default_features : bool ,
495+ ) -> AResult < Utf8PathBuf > {
477496 let mut cmd = Command :: new ( "cargo" ) ;
478497 cmd. arg ( "build" )
479498 . arg ( "--message-format=json-render-diagnostics" ) ;
480499 if release {
481500 cmd. arg ( "--release" ) ;
482501 }
502+ if let Some ( features) = features {
503+ cmd. arg ( "--features" ) ;
504+ for feature in features {
505+ cmd. arg ( feature) ;
506+ }
507+ }
508+
509+ if all_features {
510+ cmd. arg ( "--all-features" ) ;
511+ }
512+
513+ if no_default_features {
514+ cmd. arg ( "--no-default-features" ) ;
515+ }
483516
484517 let mut spawn = cmd
485518 . stdout ( Stdio :: piped ( ) )
0 commit comments