Adjust go build to link with missing simbols on osx

This commit is contained in:
Daniel Sanchez Quiros 2022-09-26 16:59:55 +02:00
parent 6db57b44b6
commit 6d3d085a38
2 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,9 @@ name = "waku-sys"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[lib]
crate-type = ["rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]

View File

@ -3,20 +3,22 @@ use std::env::set_current_dir;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::Command; use std::process::Command;
fn main() { fn main() {
// 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 = "libgowaku.a"; let output_lib = "libgowaku.a";
set_current_dir("./vendor").unwrap(); set_current_dir("./vendor").unwrap();
Command::new("go") Command::new("/usr/local/go/bin/go")
.env("CGO_ENABLED","1")
.arg("build") .arg("build")
.arg("-buildmode=c-archive") .arg("-buildmode=c-archive")
.arg("-o") .arg("-o")
.arg(format!("./build/lib/{output_lib}")) .arg(format!("./build/lib/{output_lib}"))
.arg("./library/") .arg("./library")
.status() .status()
.map_err(|e| println!("cargo:warning={}", e)) .map_err(|e| println!("cargo:warning=go build failed due to: {}", e))
.unwrap(); .unwrap();
set_current_dir("../").unwrap(); set_current_dir("../").unwrap();
let mut lib_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let mut lib_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());