forked from rustcc/coroutine-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
28 lines (24 loc) · 826 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
extern crate gcc;
use std::path::PathBuf;
use std::env;
const LIB_NAME: &'static str = "libctxswtch.a";
fn main() {
let arch =
if cfg!(target_arch = "x86_64") {
"x86_64"
} else if cfg!(target_arch = "i686") {
"i686"
} else if cfg!(target_arch = "arm") {
"arm"
} else if cfg!(target_arch = "mips") {
"mips"
} else if cfg!(target_arch = "mipsel") {
"mipsel"
} else {
panic!("Unsupported architecture: {}", env::var("TARGET").unwrap());
};
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");
}