-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
37 lines (32 loc) · 1.01 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use std::{env, process::Command};
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let bridge_dir = "./libfffs"; // Path to your bridge directory
// Compile Objective-C code with ARC
let status = Command::new("clang")
.args(&[
"-c",
format!("{}/fffs.m", bridge_dir).as_str(),
"-o",
format!("{}/fffs.o", out_dir).as_str(),
"-fmodules",
"-fobjc-arc",
"-O3",
])
.status()
.expect("Failed to execute clang");
if !status.success() {
panic!("Failed to compile Objective-C code");
}
// Create a static library using 'ar'
Command::new("ar")
.args(&[
"rcs",
format!("{}/libfffs.a", out_dir).as_str(),
format!("{}/fffs.o", out_dir).as_str(),
])
.status()
.expect("Failed to create static library");
println!("cargo:rustc-link-lib=static=fffs");
println!("cargo:rustc-link-search=native={}", out_dir);
}