Skip to content

Commit

Permalink
fix(cli/android): fallback to all targets (#7028)
Browse files Browse the repository at this point in the history
fix regression introduced in d03e47d
  • Loading branch information
amrbashir committed May 22, 2023
1 parent aa6c916 commit 3f4c4ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changes/cli-android-split-per-abit-target.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'cli.rs': 'patch'
---

Fix `--split-per-abi` not building any targets unless specified by `--target` flag.
46 changes: 25 additions & 21 deletions tooling/cli/src/mobile/android/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -212,24 +212,28 @@ fn run_build(
Ok(())
}

fn get_targets<'a>(targets: Vec<String>) -> Result<Vec<&'a Target<'a>>> {
let mut outs = Vec::new();

let possible_targets = Target::all()
.keys()
.map(|key| key.to_string())
.collect::<Vec<String>>()
.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);
fn get_targets_or_all<'a>(targets: Vec<String>) -> Result<Vec<&'a Target<'a>>> {
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::<Vec<String>>()
.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);
}
Ok(outs)
}
Ok(outs)
}

0 comments on commit 3f4c4ce

Please sign in to comment.