@@ -139,7 +139,7 @@ pub struct BuildOptions {
139139 multiple_values( true ) ,
140140 value_parser( clap:: builder:: PossibleValuesParser :: new( Target :: name_list( ) ) )
141141 ) ]
142- targets : Option < Vec < String > > ,
142+ pub targets : Option < Vec < String > > ,
143143 /// List of cargo features to activate
144144 #[ clap( short, long, multiple_occurrences( true ) , multiple_values( true ) ) ]
145145 pub features : Option < Vec < String > > ,
@@ -279,6 +279,7 @@ fn run_build(mut options: BuildOptions, config: &AndroidConfig, env: Env) -> Res
279279 } else {
280280 Profile :: Release
281281 } ;
282+ let noise_level = NoiseLevel :: Polite ;
282283
283284 if !( options. apk || options. aab ) {
284285 // if the user didn't specify the format to build, we'll do both
@@ -320,7 +321,7 @@ fn run_build(mut options: BuildOptions, config: &AndroidConfig, env: Env) -> Res
320321 apk:: build (
321322 config,
322323 & env,
323- NoiseLevel :: Polite ,
324+ noise_level ,
324325 profile,
325326 get_targets_or_all ( Vec :: new ( ) ) ?,
326327 options. split_per_abi ,
@@ -333,7 +334,7 @@ fn run_build(mut options: BuildOptions, config: &AndroidConfig, env: Env) -> Res
333334 aab:: build (
334335 config,
335336 & env,
336- NoiseLevel :: Polite ,
337+ noise_level ,
337338 profile,
338339 get_targets_or_all ( Vec :: new ( ) ) ?,
339340 options. split_per_abi ,
@@ -360,15 +361,20 @@ fn log_finished(outputs: Vec<PathBuf>, kind: &str) {
360361}
361362
362363fn dev ( options : DevOptions ) -> Result < ( ) > {
363- with_config ( |_ , config, _metadata | {
364+ with_config ( |root_conf , config, metadata | {
364365 ensure_init ( config. project_dir ( ) , MobileTarget :: Android )
365366 . map_err ( |e| Error :: ProjectNotInitialized ( e. to_string ( ) ) ) ?;
366- run_dev ( options, config) . map_err ( |e| Error :: DevFailed ( e. to_string ( ) ) )
367+ run_dev ( options, root_conf , config, metadata ) . map_err ( |e| Error :: DevFailed ( e. to_string ( ) ) )
367368 } )
368369 . map_err ( Into :: into)
369370}
370371
371- fn run_dev ( options : DevOptions , config : & AndroidConfig ) -> Result < ( ) > {
372+ fn run_dev (
373+ options : DevOptions ,
374+ root_conf : & Config ,
375+ config : & AndroidConfig ,
376+ metadata : & AndroidMetadata ,
377+ ) -> Result < ( ) > {
372378 let mut dev_options = options. clone ( ) . into ( ) ;
373379 let mut interface = crate :: dev:: setup ( & mut dev_options) ?;
374380
@@ -407,7 +413,7 @@ fn run_dev(options: DevOptions, config: &AndroidConfig) -> Result<()> {
407413 if open {
408414 open_dev ( config)
409415 } else {
410- match run ( options) {
416+ match run ( options, root_conf , config , metadata ) {
411417 Ok ( c) => Ok ( Box :: new ( c) as Box < dyn DevProcess > ) ,
412418 Err ( Error :: FailedToPromptForDevice ( e) ) => {
413419 log:: error!( "{}" , e) ;
@@ -439,37 +445,42 @@ fn open() -> Result<()> {
439445 . map_err ( Into :: into)
440446}
441447
442- fn run ( options : MobileOptions ) -> Result < DevChild , Error > {
448+ fn run (
449+ options : MobileOptions ,
450+ root_conf : & Config ,
451+ config : & AndroidConfig ,
452+ metadata : & AndroidMetadata ,
453+ ) -> Result < DevChild , Error > {
443454 let profile = if options. debug {
444455 Profile :: Debug
445456 } else {
446457 Profile :: Release
447458 } ;
459+ let noise_level = NoiseLevel :: Polite ;
448460
449- with_config ( |root_conf, config, metadata| {
450- let build_app_bundle = metadata. asset_packs ( ) . is_some ( ) ;
461+ let build_app_bundle = metadata. asset_packs ( ) . is_some ( ) ;
451462
452- ensure_init ( config . project_dir ( ) , MobileTarget :: Android )
453- . map_err ( |e| Error :: ProjectNotInitialized ( e . to_string ( ) ) ) ?;
463+ let env = Env :: new ( ) . map_err ( Error :: EnvInitFailed ) ? ;
464+ super :: init :: init_dot_cargo ( root_conf , Some ( & env ) ) . map_err ( Error :: InitDotCargo ) ?;
454465
455- let env = Env :: new ( ) . map_err ( Error :: EnvInitFailed ) ?;
456- super :: init:: init_dot_cargo ( root_conf, Some ( & env) ) . map_err ( Error :: InitDotCargo ) ?;
466+ device_prompt ( & env)
467+ . map_err ( Error :: FailedToPromptForDevice ) ?
468+ . run (
469+ config,
470+ & env,
471+ noise_level,
472+ profile,
473+ None ,
474+ build_app_bundle,
475+ false ,
476+ ".MainActivity" . into ( ) ,
477+ )
478+ . map ( |c| DevChild ( Some ( c) ) )
479+ . map_err ( Error :: RunFailed )
480+ }
457481
458- device_prompt ( & env)
459- . map_err ( Error :: FailedToPromptForDevice ) ?
460- . run (
461- config,
462- & env,
463- NoiseLevel :: Polite ,
464- profile,
465- None ,
466- build_app_bundle,
467- false ,
468- ".MainActivity" . into ( ) ,
469- )
470- . map_err ( Error :: RunFailed )
471- } )
472- . map ( |c| DevChild ( Some ( c) ) )
482+ fn detect_target_ok < ' a > ( env : & Env ) -> Option < & ' a Target < ' a > > {
483+ device_prompt ( env) . map ( |device| device. target ( ) ) . ok ( )
473484}
474485
475486fn android_studio_script ( options : AndroidStudioScriptOptions ) -> Result < ( ) > {
@@ -478,10 +489,7 @@ fn android_studio_script(options: AndroidStudioScriptOptions) -> Result<()> {
478489 } else {
479490 Profile :: Debug
480491 } ;
481-
482- fn detect_target_ok < ' a > ( env : & Env ) -> Option < & ' a Target < ' a > > {
483- device_prompt ( env) . map ( |device| device. target ( ) ) . ok ( )
484- }
492+ let noise_level = NoiseLevel :: Polite ;
485493
486494 with_config ( |root_conf, config, metadata| {
487495 ensure_init ( config. project_dir ( ) , MobileTarget :: Android )
@@ -496,7 +504,7 @@ fn android_studio_script(options: AndroidStudioScriptOptions) -> Result<()> {
496504 & env,
497505 |target : & Target | {
498506 target
499- . build ( config, metadata, & env, NoiseLevel :: Polite , true , profile)
507+ . build ( config, metadata, & env, noise_level , true , profile)
500508 . map_err ( Error :: AndroidStudioScriptFailed )
501509 } ,
502510 )
0 commit comments