-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.rs
38 lines (35 loc) · 1.09 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
38
use std::env;
use std::process::Command;
fn main() {
// // FIXME: how to use cc?
// cc::Build::new()
// .file("foreign/tid.m")
// .include("foreign/tid.h")
// .pic(true)
// .compile("tid");
println!("cargo:rustc-link-lib=framework=Foundation");
println!("cargo:rustc-link-lib=framework=LocalAuthentication");
println!("cargo:rerun-if-changed=foreign/tid.m");
println!("cargo:rerun-if-changed=foreign/tid.h");
let output = env::var("OUT_DIR").unwrap();
Command::new("clang")
.arg(concat!("-I", env!("CARGO_MANIFEST_DIR"), "/foreign"))
.arg("-c")
.arg("-o")
.arg(format!("{}/lib_test.o", output))
.arg(concat!(env!("CARGO_MANIFEST_DIR"), "/foreign/tid.m"))
.arg("-fPIC")
.spawn()
.unwrap()
.wait()
.unwrap();
Command::new("ar")
.arg("r")
.arg(format!("{}/libtest.a", output))
.arg(format!("{}/lib_test.o", output))
.spawn()
.unwrap()
.wait()
.unwrap();
println!("cargo:rustc-link-arg={}/libtest.a", output)
}