From b57dbd8d1a6c4efda4e28c12342896b9bd4bf46a Mon Sep 17 00:00:00 2001 From: Doug Date: Mon, 13 May 2024 15:46:38 +0100 Subject: [PATCH] xtask: Allow passing multiple targets to Swift's build-framework. * Fix CI --- .github/workflows/bindings_ci.yml | 2 +- xtask/src/swift.rs | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bindings_ci.yml b/.github/workflows/bindings_ci.yml index 1a41fb14a..372694f88 100644 --- a/.github/workflows/bindings_ci.yml +++ b/.github/workflows/bindings_ci.yml @@ -108,4 +108,4 @@ jobs: run: swift test - name: Build Framework - run: target/debug/xtask swift build-framework --only-target=aarch64-apple-ios + run: target/debug/xtask swift build-framework --target=aarch64-apple-ios diff --git a/xtask/src/swift.rs b/xtask/src/swift.rs index 0a020aae4..30ce9c90c 100644 --- a/xtask/src/swift.rs +++ b/xtask/src/swift.rs @@ -34,9 +34,11 @@ enum SwiftCommand { #[clap(long)] profile: Option, - /// Build the given target only + /// Build the given target. This option can be specified multiple times + /// to build more than one. Omitting this option will build all + /// supported targets. #[clap(long)] - only_target: Option, + target: Option>, /// Move the generated xcframework and swift sources into the given /// components-folder @@ -61,11 +63,11 @@ impl SwiftArgs { release, profile, components_path, - only_target, + target: targets, sequentially, } => { let profile = profile.as_deref().unwrap_or(if release { "release" } else { "dev" }); - build_xcframework(profile, only_target, components_path, sequentially) + build_xcframework(profile, targets, components_path, sequentially) } } } @@ -169,7 +171,7 @@ fn generate_uniffi(library_path: &Utf8Path, ffi_directory: &Utf8Path) -> Result< fn build_xcframework( profile: &str, - only_target: Option, + targets: Option>, components_path: Option, sequentially: bool, ) -> Result<()> { @@ -186,9 +188,13 @@ fn build_xcframework( create_dir_all(headers_dir.clone())?; create_dir_all(swift_dir.clone())?; - let targets = if let Some(triple) = only_target { - let target = TARGETS.iter().find(|t| t.triple == triple).expect("Invalid target specified"); - vec![target] + let targets = if let Some(triples) = targets { + triples + .iter() + .map(|t| { + TARGETS.iter().find(|target| target.triple == *t).expect("Invalid target specified") + }) + .collect() } else { TARGETS.iter().collect() };