Skip to content

Commit

Permalink
chore(cli): enhance mobile build by only compiling selected target (#…
Browse files Browse the repository at this point in the history
…9894)

Co-authored-by: Lucas Nogueira <[email protected]>
  • Loading branch information
lucasfernog and lucasfernog-crabnebula authored May 28, 2024
1 parent 71a5e2b commit 3f1c59d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
27 changes: 12 additions & 15 deletions tooling/cli/src/mobile/android/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,17 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
delete_codegen_vars();

let mut build_options: BuildOptions = options.clone().into();
build_options.target = Some(
Target::all()
.get(Target::DEFAULT_KEY)
.unwrap()
.triple
.into(),
);

let first_target = Target::all()
.get(
options
.targets
.as_ref()
.and_then(|l| l.first().map(|t| t.as_str()))
.unwrap_or(Target::DEFAULT_KEY),
)
.unwrap();
build_options.target = Some(first_target.triple.into());

let tauri_config = get_tauri_config(
tauri_utils::platform::Target::Android,
Expand Down Expand Up @@ -138,14 +142,7 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
crate::build::setup(&interface, &mut build_options, tauri_config.clone(), true)?;

// run an initial build to initialize plugins
Target::all().values().next().unwrap().build(
&config,
&metadata,
&env,
noise_level,
true,
profile,
)?;
first_target.build(&config, &metadata, &env, noise_level, true, profile)?;

let open = options.open;
let _handle = run_build(
Expand Down
8 changes: 7 additions & 1 deletion tooling/cli/src/mobile/ios/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ pub fn command(options: Options, noise_level: NoiseLevel) -> Result<()> {
let mut build_options: BuildOptions = options.clone().into();
build_options.target = Some(
Target::all()
.get(Target::DEFAULT_KEY)
.get(
options
.targets
.first()
.map(|t| t.as_str())
.unwrap_or(Target::DEFAULT_KEY),
)
.unwrap()
.triple
.into(),
Expand Down

0 comments on commit 3f1c59d

Please sign in to comment.