Skip to content

Commit

Permalink
Merge pull request #48 from HeavenVolkoff/master
Browse files Browse the repository at this point in the history
Enable cross-compiling for macOS targets
  • Loading branch information
Brendonovich committed May 11, 2023
2 parents a1578d5 + b444718 commit 973c222
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src-rs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,34 +238,32 @@ impl SwiftLinker {
.current_dir(&package.path)
.args(["--build-path", &out_path.display().to_string()]);

if matches!(rust_target.os, RustTargetOS::IOS) {
let sdk_path_output = Command::new("xcrun")
.args(["--sdk", &rust_target.sdk.to_string(), "--show-sdk-path"])
.output()
.unwrap();
if !sdk_path_output.status.success() {
panic!(
"Failed to get SDK path with `xcrun --sdk {} --show-sdk-path`",
rust_target.sdk
);
}

let sdk_path = String::from_utf8_lossy(&sdk_path_output.stdout);

command.args([
"-Xswiftc",
"-sdk",
"-Xswiftc",
sdk_path.trim(),
"-Xswiftc",
"-target",
"-Xswiftc",
&rust_target.swift_target_triple(
&self.macos_min_version,
self.ios_min_version.as_deref(),
),
]);
}
let sdk_path_output = Command::new("xcrun")
.args(["--sdk", &rust_target.sdk.to_string(), "--show-sdk-path"])
.output()
.unwrap();
if !sdk_path_output.status.success() {
panic!(
"Failed to get SDK path with `xcrun --sdk {} --show-sdk-path`",
rust_target.sdk
);
}

let sdk_path = String::from_utf8_lossy(&sdk_path_output.stdout);

command.args([
"-Xswiftc",
"-sdk",
"-Xswiftc",
sdk_path.trim(),
"-Xswiftc",
"-target",
"-Xswiftc",
&rust_target.swift_target_triple(
&self.macos_min_version,
self.ios_min_version.as_deref(),
),
]);

if !command.status().unwrap().success() {
panic!("Failed to compile swift package {}", package.name);
Expand Down

0 comments on commit 973c222

Please sign in to comment.