@@ -111,6 +111,12 @@ struct Install {
111
111
/// the directory the command is called.
112
112
#[ arg( long) ]
113
113
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 ,
114
120
/// Whether to bypass the install prompt.
115
121
#[ clap( long) ]
116
122
yes : bool ,
@@ -156,6 +162,12 @@ struct Stubs {
156
162
/// provides a direct path to the extension shared library.
157
163
#[ arg( long, conflicts_with = "ext" ) ]
158
164
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 ,
159
171
}
160
172
161
173
impl Args {
@@ -172,7 +184,13 @@ impl Args {
172
184
impl Install {
173
185
pub fn handle ( self ) -> CrateResult {
174
186
let artifact = find_ext ( self . manifest . as_ref ( ) ) ?;
175
- let ext_path = build_ext ( & artifact, self . release ) ?;
187
+ let ext_path = build_ext (
188
+ & artifact,
189
+ self . release ,
190
+ self . features ,
191
+ self . all_features ,
192
+ self . no_default_features ,
193
+ ) ?;
176
194
177
195
let ( mut ext_dir, mut php_ini) = if let Some ( install_dir) = self . install_dir {
178
196
( install_dir, None )
@@ -371,7 +389,14 @@ impl Stubs {
371
389
ext_path
372
390
} else {
373
391
let target = find_ext ( self . manifest . as_ref ( ) ) ?;
374
- build_ext ( & target, false ) ?. into ( )
392
+ build_ext (
393
+ & target,
394
+ false ,
395
+ self . features ,
396
+ self . all_features ,
397
+ self . no_default_features ,
398
+ ) ?
399
+ . into ( )
375
400
} ;
376
401
377
402
if !ext_path. is_file ( ) {
@@ -469,17 +494,38 @@ fn find_ext(manifest: Option<&PathBuf>) -> AResult<cargo_metadata::Target> {
469
494
///
470
495
/// * `target` - The target to compile.
471
496
/// * `release` - Whether to compile the target in release mode.
497
+ /// * `features` - Optional list of features.
472
498
///
473
499
/// # Returns
474
500
///
475
501
/// The path to the target artifact.
476
- fn build_ext ( target : & Target , release : bool ) -> AResult < Utf8PathBuf > {
502
+ fn build_ext (
503
+ target : & Target ,
504
+ release : bool ,
505
+ features : Option < Vec < String > > ,
506
+ all_features : bool ,
507
+ no_default_features : bool ,
508
+ ) -> AResult < Utf8PathBuf > {
477
509
let mut cmd = Command :: new ( "cargo" ) ;
478
510
cmd. arg ( "build" )
479
511
. arg ( "--message-format=json-render-diagnostics" ) ;
480
512
if release {
481
513
cmd. arg ( "--release" ) ;
482
514
}
515
+ if let Some ( features) = features {
516
+ cmd. arg ( "--features" ) ;
517
+ for feature in features {
518
+ cmd. arg ( feature) ;
519
+ }
520
+ }
521
+
522
+ if all_features {
523
+ cmd. arg ( "--all-features" ) ;
524
+ }
525
+
526
+ if no_default_features {
527
+ cmd. arg ( "--no-default-features" ) ;
528
+ }
483
529
484
530
let mut spawn = cmd
485
531
. stdout ( Stdio :: piped ( ) )
0 commit comments