forked from zonyitoo/context-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
29 lines (23 loc) · 814 Bytes
/
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
extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a";
fn main() {
let target = env::var("TARGET").unwrap();
let arch_sub = target.split('-').next().unwrap();
let arch =
match arch_sub {
"x86_64" => "x86_64",
"x86" | "i686" | "i586" | "i486" | "i386" => "i686",
"arm" => "arm",
"mips" => "mips",
"mipsel" => "mipsel",
_ => {
panic!("Unsupported architecture: {}", target);
}
};
let src_path = &["src", "asm", arch, "_context.S"].iter().collect::<PathBuf>();
gcc::compile_library(LIB_NAME, &[src_path.to_str().unwrap()]);
// seems like this line is no need actually
// println!("cargo:rustc-flags=-l ctxswtch:static");
}