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::env;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use bindgen::CargoCallbacks;
|
use bindgen::CargoCallbacks;
|
||||||
|
use gobuild::BuildMode;
|
||||||
|
|
||||||
fn main() {
|
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());
|
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
|
||||||
println!("cargo:rustc-link-search={}", out_path.display());
|
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.mod");
|
||||||
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!("Generating bindings");
|
||||||
|
|
||||||
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))
|
||||||
|
|
|
@ -25,19 +25,13 @@ pub mod timerworker;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use crate::config::load_config;
|
use crate::config::load_config;
|
||||||
use clap::{ArgAction, Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use simple_logger::SimpleLogger;
|
use simple_logger::SimpleLogger;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(author = "c0repwn3r", version, about, long_about = None)]
|
#[command(author = "c0repwn3r", version, about, long_about = None)]
|
||||||
#[clap(disable_version_flag = true)]
|
|
||||||
struct Cli {
|
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)]
|
#[command(subcommand)]
|
||||||
subcommand: Commands,
|
subcommand: Commands,
|
||||||
}
|
}
|
||||||
|
@ -75,13 +69,8 @@ enum Commands {
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
SimpleLogger::new().init().unwrap();
|
SimpleLogger::new().init().unwrap();
|
||||||
|
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
|
|
||||||
if args.version {
|
|
||||||
print_version();
|
|
||||||
}
|
|
||||||
|
|
||||||
match args.subcommand {
|
match args.subcommand {
|
||||||
Commands::Run { name, server } => {
|
Commands::Run { name, server } => {
|
||||||
daemon::daemon_main(name, server);
|
daemon::daemon_main(name, server);
|
||||||
|
@ -122,11 +111,3 @@ 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