44 lines
1.5 KiB
Rust
44 lines
1.5 KiB
Rust
//! Assert the native build script's namespace boundaries.
|
|
fn main() {
|
|
if std::env::var("SAUSAGE_TEST_NO_BUILDER_SANDBOX").as_deref() == Ok("1") {
|
|
println!("cargo:warning=namespace assertions skipped: builder sandbox disabled");
|
|
} else {
|
|
assert!(!std::path::Path::new("/home").exists());
|
|
assert!(
|
|
!std::path::Path::new(&std::env::var("HOME").unwrap())
|
|
.join(".ssh")
|
|
.exists()
|
|
);
|
|
assert!(std::fs::write("/outside-probe", b"no").is_err());
|
|
assert!(
|
|
std::net::TcpStream::connect_timeout(
|
|
&"1.1.1.1:443".parse().unwrap(),
|
|
std::time::Duration::from_millis(100)
|
|
)
|
|
.is_err()
|
|
);
|
|
println!("cargo:warning=namespace assertions passed");
|
|
}
|
|
let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
|
|
let object = out.join("add.o");
|
|
assert!(
|
|
std::process::Command::new(std::env::var("CC_wasm32_wasip2").unwrap())
|
|
.args(["-c", "src/add.c", "-o"])
|
|
.arg(&object)
|
|
.status()
|
|
.unwrap()
|
|
.success()
|
|
);
|
|
assert!(
|
|
std::process::Command::new(std::env::var("AR_wasm32_wasip2").unwrap())
|
|
.arg("crs")
|
|
.arg(out.join("libadd.a"))
|
|
.arg(&object)
|
|
.status()
|
|
.unwrap()
|
|
.success()
|
|
);
|
|
println!("cargo:rustc-link-search=native={}", out.display());
|
|
println!("cargo:rustc-link-lib=static=add");
|
|
}
|