-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
33 lines (27 loc) · 858 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
30
31
32
33
use std::fs;
use std::env;
use std::path::Path;
fn main() {
let out_dir = env::var_os("OUT_DIR").unwrap();
let payload = env::var("MEOWSBI_PAYLOAD").ok();
let payload_rs = Path::new(&out_dir).join("payload_content.rs");
if let Some(payload) = payload {
fs::write(
&payload_rs,
format!(r#"
global_asm!("
.section .payload, \"ax\", %progbits
.globl payload
payload:
.incbin \"{}\"
");"#, payload),
).unwrap();
} else {
fs::write(&payload_rs, r#"
#[cfg(feature = "payload")]
compile_error!("MEOWSBI_PAYLOAD environment variable not set!");
"#).unwrap();
}
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-var-changed=MEOWSBI_PAYLOAD");
}