fix(cli/android): fallback to all targets (#7028)

fix regression introduced in d03e47d141
This commit is contained in:
Amr Bashir 2023-05-22 19:00:18 +03:00 committed by GitHub
parent aa6c9164e6
commit 3f4c4ce88b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 19 deletions

View File

@ -0,0 +1,5 @@
---
'cli.rs': 'patch'
---
Fix `--split-per-abi` not building any targets unless specified by `--target` flag.

View File

@ -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<String>) -> Result<Vec<&'a Target<'a>>> {
let mut outs = Vec::new();
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(",");
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);
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)
}