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

Support iOS #9

Merged
Merged
4 changes: 4 additions & 0 deletions .github/workflows/gen_bind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ jobs:
triple: x86_64-apple-darwin
- os: macos-latest
triple: aarch64-apple-darwin
- os: macos-latest
triple: aarch64-apple-ios
- os: macos-latest
triple: aarch64-apple-ios-sim
runs-on: ${{ matrix.target.os }}
steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ jobs:
target: aarch64-apple-darwin
- os: macos-latest
target: x86_64-apple-darwin
- os: macos-latest
target: aarch64-apple-ios
- os: macos-latest
target: aarch64-apple-ios-sim
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand Down
20 changes: 19 additions & 1 deletion crates/open_jtalk-sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{env, path::Path};
use std::{env, path::Path, process::Command};
fn main() {
let mut cmake_conf = cmake::Config::new("open_jtalk");
let target = env::var("TARGET").unwrap();
Expand Down Expand Up @@ -26,6 +26,24 @@ fn main() {
cmake_conf.define("CMAKE_SYSTEM_VERSION", "1");
}

// iOS SDKで必要な引数を指定する
if target.contains("ios") {
// iOSとiPhone simulatorは別扱いになる
let sdk = if target.contains("sim") {
"iphonesimulator"
} else {
"iphoneos"
};
let cmake_osx_sysroot = Command::new("xcrun")
.args(["--sdk", sdk, "--show-sdk-path"])
.output()
.expect("Failed to run xcrun command");
cmake_conf.define(
"CMAKE_OSX_SYSROOT",
String::from_utf8_lossy(&cmake_osx_sysroot.stdout).trim(),
);
}

let dst_dir = cmake_conf.build();
let lib_dir = dst_dir.join("lib");
println!("cargo:rustc-link-search={}", lib_dir.display());
Expand Down
6 changes: 6 additions & 0 deletions crates/open_jtalk-sys/src/generated/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ include!(concat!(
"/src/generated/macos/aarch64/bindings.rs"
));

#[cfg(all(target_os = "ios", target_arch = "aarch64"))]
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
"/src/generated/ios/aarch64/bindings.rs"
));

#[cfg(all(target_os = "windows", target_arch = "x86"))]
include!(concat!(
env!("CARGO_MANIFEST_DIR"),
Expand Down
Loading