Skip to content

Commit

Permalink
xtask: Allow passing multiple targets to Swift's build-framework.
Browse files Browse the repository at this point in the history
* Fix CI
  • Loading branch information
pixlwave authored and bnjbvr committed May 14, 2024
1 parent aa6bbc1 commit b57dbd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bindings_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 14 additions & 8 deletions xtask/src/swift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ enum SwiftCommand {
#[clap(long)]
profile: Option<String>,

/// 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<String>,
target: Option<Vec<String>>,

/// Move the generated xcframework and swift sources into the given
/// components-folder
Expand All @@ -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)
}
}
}
Expand Down Expand Up @@ -169,7 +171,7 @@ fn generate_uniffi(library_path: &Utf8Path, ffi_directory: &Utf8Path) -> Result<

fn build_xcframework(
profile: &str,
only_target: Option<String>,
targets: Option<Vec<String>>,
components_path: Option<Utf8PathBuf>,
sequentially: bool,
) -> Result<()> {
Expand All @@ -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()
};
Expand Down

0 comments on commit b57dbd8

Please sign in to comment.