-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (20 loc) · 816 Bytes
/
Copy pathbuild.rs
File metadata and controls
27 lines (20 loc) · 816 Bytes
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
use std::env;
use std::path::PathBuf;
fn main() {
let target = env::var("TARGET").unwrap_or_default();
if !target.starts_with("x86_64") {
return;
}
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
println!("cargo:rerun-if-changed=src/task/switch.s");
std::process::Command::new("nasm")
.args(&["-f", "elf64", "src/task/switch.s", "-o"])
.arg(&format!("{}/switch.o", out_dir.display()))
.status()
.expect("Failed to assemble switch.s");
println!("cargo:rustc-link-search={}", out_dir.display());
println!("cargo:rustc-link-lib=static=switch");
ar::Builder::new(std::fs::File::create(format!("{}/libswitch.a", out_dir.display())).unwrap())
.append_path(format!("{}/switch.o", out_dir.display()))
.unwrap();
}