Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cross-compiling from darwin to ios #73

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion crates/tx5-go-pion-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::process::Command;
use std::{path::Path, process::Command};

#[derive(Debug)]
enum LinkType {
Expand Down Expand Up @@ -155,6 +155,29 @@ fn go_build_cmd(

cmd.env("CGO_ENABLED", "1");

let target_os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
if target_os == "ios" {
// Determine Xcode directory path
guillemcordoba marked this conversation as resolved.
Show resolved Hide resolved
let xcode_select_output =
Command::new("xcode-select").arg("-p").output().unwrap();
if !xcode_select_output.status.success() {
panic!("Failed to run xcode-select -p");
}
let xcode_dir = String::from_utf8(xcode_select_output.stdout)
.unwrap()
.trim()
.to_string();

// Determine SDK directory paths
let sdk_dir_ios = Path::new(&xcode_dir)
.join("Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk")
.to_str()
.unwrap()
.to_string();

cmd.env("CGO_CFLAGS", format!(" -isysroot {sdk_dir_ios}"));
}

// grr, clippy, the debug symbols belong in one arg
#[allow(clippy::suspicious_command_arg_space)]
{
Expand Down
Loading