forked from rust-osdev/x86_64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
40 lines (34 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
38
39
40
#[cfg(feature = "inline_asm")]
fn main() {}
#[cfg(all(not(feature = "inline_asm"), not(feature = "stable")))]
fn main() {
compile_error!("Neither feature \"stable\" nor \"nightly\" was set!");
}
#[cfg(all(not(feature = "inline_asm"), feature = "stable"))]
fn main() {
use std::ffi::OsString;
use std::fs;
println!("cargo:rerun-if-changed=build.rs");
let entries = fs::read_dir("src/asm")
.unwrap()
.filter_map(|f| {
f.ok().and_then(|e| {
let path = e.path();
match path.extension() {
Some(ext) if ext.eq(&OsString::from("s")) => Some(path),
_ => None,
}
})
})
.collect::<Vec<_>>();
cc::Build::new()
.no_default_flags(true)
.files(&entries)
.pic(true)
.static_flag(true)
.shared_flag(false)
.compile("x86_64_asm");
for e in entries {
println!("cargo:rerun-if-changed={}", e.to_str().unwrap());
}
}