dynamically link to provide more options for more platforms
This commit is contained in:
parent
8ce7bb0857
commit
40ce3efe3c
|
@ -1,18 +1,23 @@
|
|||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use bindgen::CargoCallbacks;
|
||||
use gobuild::BuildMode;
|
||||
|
||||
fn main() {
|
||||
gobuild::Build::new().file("main.go").compile("nebulaffi");
|
||||
gobuild::Build::new().buildmode(BuildMode::CShared).file("main.go").compile("nebulaffi");
|
||||
|
||||
println!("Go compile success");
|
||||
|
||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
|
||||
println!("cargo:rustc-link-search={}", out_path.display());
|
||||
println!("cargo:rustc-link-lib=static=nebulaffi");
|
||||
println!("cargo:rustc-link-lib=dylib=nebulaffi");
|
||||
println!("cargo:rerun-if-changed=go.mod");
|
||||
println!("cargo:rerun-if-changed=go.sum");
|
||||
println!("cargo:rerun-if-changed=main.go");
|
||||
|
||||
println!("Generating bindings");
|
||||
|
||||
let bindings = bindgen::Builder::default()
|
||||
.header(out_path.join("libnebulaffi.h").display().to_string())
|
||||
.parse_callbacks(Box::new(CargoCallbacks))
|
||||
|
@ -23,4 +28,4 @@ fn main() {
|
|||
bindings
|
||||
.write_to_file(out_path.join("bindings.rs"))
|
||||
.expect("Couldn't write bindings!");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,19 +25,13 @@ pub mod timerworker;
|
|||
pub mod util;
|
||||
|
||||
use crate::config::load_config;
|
||||
use clap::{ArgAction, Parser, Subcommand};
|
||||
use clap::{Parser, Subcommand};
|
||||
use log::{error, info};
|
||||
use simple_logger::SimpleLogger;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author = "c0repwn3r", version, about, long_about = None)]
|
||||
#[clap(disable_version_flag = true)]
|
||||
struct Cli {
|
||||
#[arg(short = 'v', long = "version", action = ArgAction::SetTrue)]
|
||||
#[clap(global = true)]
|
||||
/// Print the tfclient version, as well as the trifid-pki version and the version of the embedded nebula and nebula-cert binaries
|
||||
version: bool,
|
||||
|
||||
#[command(subcommand)]
|
||||
subcommand: Commands,
|
||||
}
|
||||
|
@ -75,13 +69,8 @@ enum Commands {
|
|||
|
||||
fn main() {
|
||||
SimpleLogger::new().init().unwrap();
|
||||
|
||||
let args = Cli::parse();
|
||||
|
||||
if args.version {
|
||||
print_version();
|
||||
}
|
||||
|
||||
match args.subcommand {
|
||||
Commands::Run { name, server } => {
|
||||
daemon::daemon_main(name, server);
|
||||
|
@ -121,12 +110,4 @@ fn main() {
|
|||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn print_version() {
|
||||
println!(
|
||||
"tfclient v{} linked to trifid-pki v{}",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
trifid_pki::TRIFID_PKI_VERSION
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue