fix cross compilation with cross
This commit is contained in:
parent
acb956a28d
commit
b7ad25b5ec
|
@ -2073,7 +2073,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "nebula-ffi"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"gobuild",
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
# Cross config
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
pre-build = [
|
||||
"apt-get update && apt-get install --assume-yes wget && wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /go.tar.gz && tar -C /usr/local -xzf /go.tar.gz && echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile && touch /go-installed",
|
||||
]
|
||||
|
||||
[target.aarch64-unknown-linux-musl.env]
|
||||
volumes = []
|
||||
passthrough = ["GOPATH=/tmp/gopath", "GOCACHE=/tmp/gocache"]
|
||||
|
||||
[target.x86_64-unknown-linux-musl]
|
||||
pre-build = [
|
||||
"apt-get update && apt-get install --assume-yes wget && wget https://go.dev/dl/go1.20.5.linux-amd64.tar.gz -O /go.tar.gz && tar -C /usr/local -xzf /go.tar.gz && echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile && touch /go-installed",
|
||||
]
|
||||
|
||||
[target.x86_64-unknown-linux-musl]
|
||||
volumes = []
|
||||
passthrough = ["GOPATH=/tmp/gopath", "GOCACHE=/tmp/gocache"]
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "nebula-ffi"
|
||||
version = "0.1.1"
|
||||
version = "0.1.3"
|
||||
edition = "2021"
|
||||
description = "A Rust wrapper crate for communicating with Nebula via a CGO FFI."
|
||||
license = "GPL-3.0-or-later"
|
||||
|
@ -13,4 +13,4 @@ repository = "https://git.e3t.cc/~core/trifid"
|
|||
|
||||
[build-dependencies]
|
||||
gobuild = "0.1.0-alpha.2"
|
||||
bindgen = "0.66.1"
|
||||
bindgen = "0.66.1"
|
||||
|
|
|
@ -1,9 +1,20 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use bindgen::CargoCallbacks;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
gobuild::Build::new().file("main.go").compile("nebulaffi");
|
||||
// Find compiler: if /usr/local/go/bin/go exists, use that
|
||||
// otherwise, rely on PATH
|
||||
let compiler;
|
||||
if Path::new("/usr/local/go/bin/go").exists() {
|
||||
println!("Using /usr/local/go/bin/go");
|
||||
compiler = "/usr/local/go/bin/go";
|
||||
} else {
|
||||
compiler = "go";
|
||||
}
|
||||
|
||||
gobuild::Build::new().compiler(compiler).file("main.go").compile("nebulaffi");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
|
||||
|
@ -13,6 +24,8 @@ fn main() {
|
|||
println!("cargo:rerun-if-changed=go.sum");
|
||||
println!("cargo:rerun-if-changed=main.go");
|
||||
|
||||
println!("Bindgen start");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(out_path.join("libnebulaffi.h").display().to_string())
|
||||
.parse_callbacks(Box::new(CargoCallbacks))
|
||||
|
@ -23,4 +36,4 @@ fn main() {
|
|||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,10 +49,3 @@ license-file = "LICENSE.txt"
|
|||
maintainer-scripts = "debian/"
|
||||
systemd-units = { enable = false, unit-name = "tfclient@" }
|
||||
|
||||
# Cross config
|
||||
[target.aarch64-unknown-linux-musl]
|
||||
pre-build = [
|
||||
"wget https://go.dev/dl/go1.20.5.linux-arm64.tar.gz -O /go.tar.gz",
|
||||
"tar -C /usr/local -xzf /go.tar.gz",
|
||||
"echo \"export PATH=$PATH:/usr/local/go/bin\" >> /etc/profile"
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue