fix cross compilation with cross
This commit is contained in:
parent
acb956a28d
commit
b7ad25b5ec
|
@ -2073,7 +2073,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nebula-ffi"
|
name = "nebula-ffi"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bindgen",
|
"bindgen",
|
||||||
"gobuild",
|
"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]
|
[package]
|
||||||
name = "nebula-ffi"
|
name = "nebula-ffi"
|
||||||
version = "0.1.1"
|
version = "0.1.3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
description = "A Rust wrapper crate for communicating with Nebula via a CGO FFI."
|
description = "A Rust wrapper crate for communicating with Nebula via a CGO FFI."
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
|
@ -13,4 +13,4 @@ repository = "https://git.e3t.cc/~core/trifid"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gobuild = "0.1.0-alpha.2"
|
gobuild = "0.1.0-alpha.2"
|
||||||
bindgen = "0.66.1"
|
bindgen = "0.66.1"
|
||||||
|
|
|
@ -1,9 +1,20 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use bindgen::CargoCallbacks;
|
use bindgen::CargoCallbacks;
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
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());
|
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=go.sum");
|
||||||
println!("cargo:rerun-if-changed=main.go");
|
println!("cargo:rerun-if-changed=main.go");
|
||||||
|
|
||||||
|
println!("Bindgen start");
|
||||||
|
|
||||||
let bindings = bindgen::Builder::default()
|
let bindings = bindgen::Builder::default()
|
||||||
.header(out_path.join("libnebulaffi.h").display().to_string())
|
.header(out_path.join("libnebulaffi.h").display().to_string())
|
||||||
.parse_callbacks(Box::new(CargoCallbacks))
|
.parse_callbacks(Box::new(CargoCallbacks))
|
||||||
|
@ -23,4 +36,4 @@ fn main() {
|
||||||
bindings
|
bindings
|
||||||
.write_to_file(out_path.join("bindings.rs"))
|
.write_to_file(out_path.join("bindings.rs"))
|
||||||
.expect("Couldn't write bindings!");
|
.expect("Couldn't write bindings!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,10 +49,3 @@ license-file = "LICENSE.txt"
|
||||||
maintainer-scripts = "debian/"
|
maintainer-scripts = "debian/"
|
||||||
systemd-units = { enable = false, unit-name = "tfclient@" }
|
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