From a94ee694a3801293905ecd9bb9961198953a4068 Mon Sep 17 00:00:00 2001 From: Daniel Sanchez Quiros Date: Mon, 26 Sep 2022 17:06:14 +0200 Subject: [PATCH] Use different binary depending os family --- waku-sys/build.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/waku-sys/build.rs b/waku-sys/build.rs index c945872..955f6c4 100644 --- a/waku-sys/build.rs +++ b/waku-sys/build.rs @@ -1,3 +1,5 @@ +extern crate core; + use std::env; use std::env::set_current_dir; use std::path::PathBuf; @@ -5,12 +7,21 @@ use std::process::Command; fn main() { + // TODO: well, there are a lot of things to consider here, including architechture target. A better aware system should be used. + // For now this will have to do + let go_bin = if cfg!(target_family = "unix") { + "/usr/local/go/bin/go" + } else if cfg!(target_family = "windows") { + "go" + } else { + panic!("OS not supported!"); + }; // Build go-waku static lib // build command taken from waku make file: // https://github.com/status-im/go-waku/blob/eafbc4c01f94f3096c3201fb1e44f17f907b3068/Makefile#L115 let output_lib = "libgowaku.a"; set_current_dir("./vendor").unwrap(); - Command::new("/usr/local/go/bin/go") + Command::new(go_bin) .env("CGO_ENABLED","1") .arg("build") .arg("-buildmode=c-archive")