From 3f4c4ce88b071e4e59f03887beb4dfe76f66e11b Mon Sep 17 00:00:00 2001 From: Amr Bashir Date: Mon, 22 May 2023 19:00:18 +0300 Subject: [PATCH] fix(cli/android): fallback to all targets (#7028) fix regression introduced in https://github.com/tauri-apps/tauri/commit/d03e47d141c3917520975be9081775dbc4e9d4fd --- .changes/cli-android-split-per-abit-target.md | 5 +++ tooling/cli/src/mobile/android/build.rs | 42 ++++++++++--------- 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 .changes/cli-android-split-per-abit-target.md diff --git a/.changes/cli-android-split-per-abit-target.md b/.changes/cli-android-split-per-abit-target.md new file mode 100644 index 000000000..61439fdcc --- /dev/null +++ b/.changes/cli-android-split-per-abit-target.md @@ -0,0 +1,5 @@ +--- +'cli.rs': 'patch' +--- + +Fix `--split-per-abi` not building any targets unless specified by `--target` flag. diff --git a/tooling/cli/src/mobile/android/build.rs b/tooling/cli/src/mobile/android/build.rs index 6761e3422..92f8405fb 100644 --- a/tooling/cli/src/mobile/android/build.rs +++ b/tooling/cli/src/mobile/android/build.rs @@ -186,7 +186,7 @@ fn run_build( env, noise_level, profile, - get_targets(options.targets.clone().unwrap_or_default())?, + get_targets_or_all(options.targets.clone().unwrap_or_default())?, options.split_per_abi, )? } else { @@ -199,7 +199,7 @@ fn run_build( env, noise_level, profile, - get_targets(options.targets.unwrap_or_default())?, + get_targets_or_all(options.targets.unwrap_or_default())?, options.split_per_abi, )? } else { @@ -212,24 +212,28 @@ fn run_build( Ok(()) } -fn get_targets<'a>(targets: Vec) -> Result>> { - let mut outs = Vec::new(); +fn get_targets_or_all<'a>(targets: Vec) -> Result>> { + if targets.is_empty() { + Ok(Target::all().iter().map(|t| t.1).collect()) + } else { + let mut outs = Vec::new(); - let possible_targets = Target::all() - .keys() - .map(|key| key.to_string()) - .collect::>() - .join(","); + let possible_targets = Target::all() + .keys() + .map(|key| key.to_string()) + .collect::>() + .join(","); - for t in targets { - let target = Target::for_name(&t).ok_or_else(|| { - anyhow::anyhow!( - "Target {} is invalid; the possible targets are {}", - t, - possible_targets - ) - })?; - outs.push(target); + for t in targets { + let target = Target::for_name(&t).ok_or_else(|| { + anyhow::anyhow!( + "Target {} is invalid; the possible targets are {}", + t, + possible_targets + ) + })?; + outs.push(target); + } + Ok(outs) } - Ok(outs) }