forked from confidential-containers/trustee
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
42 lines (36 loc) · 1.12 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
use std::process::exit;
fn real_main() -> Result<(), String> {
let out_dir = std::env::var("OUT_DIR").unwrap();
println!("cargo:rerun-if-changed={out_dir}");
println!("cargo:rustc-link-search=native={out_dir}");
#[cfg(feature = "in-toto")]
{
println!("cargo:rustc-link-lib=static=cgo");
let cgo_dir = "./cgo".to_string();
let cgo = Command::new("go")
.args([
"build",
"-o",
&format!("{out_dir}/libcgo.a"),
"-buildmode=c-archive",
"intoto.go",
])
.current_dir(cgo_dir)
.output()
.expect("failed to launch opa compile process");
if !cgo.status.success() {
return Err(std::str::from_utf8(&cgo.stderr.to_vec())
.unwrap()
.to_string());
}
}
tonic_build::compile_protos("../protos/reference.proto").map_err(|e| format!("{e}"))?;
Ok(())
}
fn main() -> shadow_rs::SdResult<()> {
if let Err(e) = real_main() {
eprintln!("ERROR: {e}");
exit(1);
}
shadow_rs::new()
}