cross-platform nebula build process
This commit is contained in:
parent
7d1bdf07e0
commit
ae990cf977
|
@ -33,7 +33,7 @@ fn main() {
|
|||
let out = out_path.join(out_file);
|
||||
|
||||
let mut command = process::Command::new(compiler);
|
||||
command.args(["build", "-buildmode", "c-archive", "-o", out.display().to_string().as_str(), "main.go"]);
|
||||
command.args(["build", "-buildmode", link_type().as_str(), "-o", out.display().to_string().as_str(), "main.go"]);
|
||||
command.env("CGO_ENABLED", "1");
|
||||
command.env("CC", c_compiler.path());
|
||||
command.env("GOARCH", goarch());
|
||||
|
@ -50,7 +50,7 @@ fn main() {
|
|||
|
||||
println!("Go compile success");
|
||||
|
||||
println!("cargo:rustc-link-lib=static=nebula");
|
||||
print_link();
|
||||
println!("cargo:rustc-link-search=native={}", env::var("OUT_DIR").unwrap());
|
||||
|
||||
//let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
|
@ -63,7 +63,7 @@ fn main() {
|
|||
println!("Generating bindings");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(out_path.join("libnebula.h").display().to_string())
|
||||
.header(out_path.join(LIBRARY_PREFIX.to_owned() + "nebula.h").display().to_string())
|
||||
.parse_callbacks(Box::new(CargoCallbacks))
|
||||
.generate()
|
||||
.expect("Error generating CFFI bindings");
|
||||
|
@ -80,7 +80,7 @@ const LIBRARY_EXTENSION: & str = ".a";
|
|||
const LIBRARY_PREFIX: & str = "lib";
|
||||
|
||||
#[cfg(target_family = "windows")]
|
||||
const LIBRARY_EXTENSION: &str = ".lib";
|
||||
const LIBRARY_EXTENSION: &str = ".dll";
|
||||
#[cfg(target_family = "windows")]
|
||||
const LIBRARY_PREFIX: &str = "";
|
||||
|
||||
|
@ -110,3 +110,20 @@ fn goos() -> String {
|
|||
os => panic!("unsupported operating system {os}")
|
||||
}.to_string()
|
||||
}
|
||||
|
||||
#[cfg(target_family = "unix")]
|
||||
fn print_link() {
|
||||
println!("cargo:rustc-link-lib=static=nebula");
|
||||
}
|
||||
#[cfg(target_family = "unix")]
|
||||
fn link_type() -> String {
|
||||
"c-archive".to_string()
|
||||
}
|
||||
#[cfg(target_family = "windows")]
|
||||
fn print_link() {
|
||||
println!("cargo:rustc-link-lib=dylib=nebula");
|
||||
}
|
||||
#[cfg(target_family = "windows")]
|
||||
fn link_type() -> String {
|
||||
"c-shared".to_string()
|
||||
}
|
||||
|
|
|
@ -124,6 +124,8 @@ fn handle_client(
|
|||
) -> Result<(), io::Error> {
|
||||
info!("Handling connection from {}", stream.peer_addr()?);
|
||||
|
||||
stream.set_nonblocking(false)?;
|
||||
|
||||
let mut client = Client {
|
||||
state: ClientState::WaitHello,
|
||||
reader: BufReader::new(&stream),
|
||||
|
|
Loading…
Reference in New Issue