Skip to content

Commit

Permalink
Fix cross-compiling from darwin to ios (#73)
Browse files Browse the repository at this point in the history
* Update build.rs

Fixes #71

* format

* Update crates/tx5-go-pion-sys/build.rs

Co-authored-by: David Braden <neonphog@gmail.com>

---------

Co-authored-by: David Braden <neonphog@gmail.com>
  • Loading branch information
guillemcordoba and neonphog authored Dec 1, 2023
1 parent c7c61df commit 6ce7baf
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 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,28 @@ fn go_build_cmd(

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

if TARGET.go_os == "ios" {
// Determine Xcode directory path
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

0 comments on commit 6ce7baf

Please sign in to comment.