Fix which path

This commit is contained in:
Daniel Sanchez Quiros 2022-09-27 12:19:26 +02:00
parent 9afac2497a
commit d64ca7248b

View File

@ -5,18 +5,20 @@ use std::process::Command;
fn get_go_bin() -> String { fn get_go_bin() -> String {
if cfg!(target_family = "unix") { if cfg!(target_family = "unix") {
let output = String::from_utf8( let output = String::from_utf8(
Command::new("which") Command::new("/usr/bin/which")
.arg("go") .arg("go")
.output() .output()
.map_err(|e| println!("cargo:warning=Coudling find which command: {}", e))
.expect("`which` command not found") .expect("`which` command not found")
.stdout, .stdout,
) )
.expect("which output couldnt be parsed"); .expect("which output couldnt be parsed");
if output.is_empty() { if output.is_empty() {
println!("cargo:warning=Couldn't find go binary installed, please ensure that it is installed and/or withing the system paths"); println!("cargo:warning=Couldn't find go binary installed, please ensure that it is installed and/or withing the system paths");
panic!("Couldn't find `go` binary installed"); panic!("Couldn't find `go` binary installed");
} }
output output.trim().to_string()
} else if cfg!(target_family = "windows") { } else if cfg!(target_family = "windows") {
"go".into() "go".into()
} else { } else {
@ -28,8 +30,8 @@ fn build_go_waku_lib(go_bin: &str, project_dir: &Path) {
// Build go-waku static lib // Build go-waku static lib
// build command taken from waku make file: // build command taken from waku make file:
// https://github.com/status-im/go-waku/blob/eafbc4c01f94f3096c3201fb1e44f17f907b3068/Makefile#L115 // https://github.com/status-im/go-waku/blob/eafbc4c01f94f3096c3201fb1e44f17f907b3068/Makefile#L115
let output_lib = project_dir.join("./vendor/build/lib/libgowaku.a"); let output_lib = project_dir.join("vendor/build/lib/libgowaku.a");
let library_path = project_dir.join("./vendor/library"); let library_path = project_dir.join("vendor/library");
Command::new(go_bin) Command::new(go_bin)
.env("CGO_ENABLED", "1") .env("CGO_ENABLED", "1")
.arg("build") .arg("build")