-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
47 lines (40 loc) · 1.26 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
41
42
43
44
45
46
47
extern crate ptx_builder;
use ptx_builder::{builder::{BuildStatus, Builder, Profile},
error::Result,
reporter::BuildReporter};
use std::env;
use std::process::exit;
fn main() {
if let Err(error) = build() {
eprintln!("{}", BuildReporter::report(error));
exit(1);
}
}
fn build() -> Result<()> {
let mut builder = Builder::new("kernel")?;
builder.set_profile(match env::var("PROFILE") {
Ok(s) => match s.as_ref() {
"debug" => Profile::Debug,
"release" => Profile::Release,
_ => Profile::Release,
},
_ => Profile::Release,
});
match builder.build()? {
BuildStatus::Success(output) => {
// Provide the PTX Assembly location via env variable
println!(
"cargo:rustc-env=KERNEL_PTX_PATH={}",
output.get_assembly_path().to_str().unwrap()
);
// Observe changes in kernel sources
for path in output.source_files()? {
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
}
}
BuildStatus::NotNeeded => {
println!("cargo:rustc-env=KERNEL_PTX_PATH=/dev/null");
}
};
Ok(())
}