Set GOCACHE variable to off for crates.io (#25)

* Set GOCACHE variable to off for crates.io

* Modify GOCACHE only for crates.io builds
This commit is contained in:
gusto
2022-11-30 09:45:22 +01:00
committed by GitHub
parent 718c28725d
commit 18436dfc21
+13 -4
View File
@@ -34,16 +34,25 @@ fn build_go_waku_lib(go_bin: &str, project_dir: &Path) {
let out_dir: PathBuf = env::var_os("OUT_DIR").unwrap().into();
let vendor_path = project_dir.join("vendor");
set_current_dir(vendor_path).expect("Moving to vendor dir");
Command::new(go_bin)
.env("CGO_ENABLED", "1")
let mut cmd = Command::new(go_bin);
cmd.env("CGO_ENABLED", "1")
.arg("build")
.arg("-buildmode=c-archive")
.arg("-o")
.arg(out_dir.join("libgowaku.a"))
.arg("./library")
.status()
.arg("./library");
// Setting `GOCACHE=/tmp/` for crates.io job that builds documentation
// when a crate is being published or updated.
if std::env::var("DOCS_RS").is_ok() {
cmd.env("GOCACHE", "/tmp/");
}
cmd.status()
.map_err(|e| println!("cargo:warning=go build failed due to: {}", e))
.unwrap();
set_current_dir(project_dir).expect("Going back to project dir");
}