From 0cf27d112cbe49d8effcac616b1de7f318629a15 Mon Sep 17 00:00:00 2001 From: Ivan Folgueira Bande Date: Mon, 28 Oct 2024 14:05:24 +0100 Subject: [PATCH] build.rs: add negentropy dependency and cmdCount cmdLine dependencies --- waku-sys/Cargo.toml | 2 +- waku-sys/build.rs | 24 ++++++++++++++++++++++++ waku-sys/src/cmd.c | 13 +++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 waku-sys/src/cmd.c diff --git a/waku-sys/Cargo.toml b/waku-sys/Cargo.toml index 07fe377..c1ddd07 100644 --- a/waku-sys/Cargo.toml +++ b/waku-sys/Cargo.toml @@ -36,4 +36,4 @@ crate-type = ["rlib"] [build-dependencies] bindgen = "0.64" -cc = "1.0" +cc = "1.0.73" diff --git a/waku-sys/build.rs b/waku-sys/build.rs index d2a1902..a469cbb 100644 --- a/waku-sys/build.rs +++ b/waku-sys/build.rs @@ -38,6 +38,7 @@ fn generate_bindgen_code(project_dir: &Path) { vendor_path.join("build").display() ); println!("cargo:rustc-link-lib=static=waku"); + println!( "cargo:rustc-link-search={}", vendor_path @@ -45,6 +46,7 @@ fn generate_bindgen_code(project_dir: &Path) { .display() ); println!("cargo:rustc-link-lib=static=miniupnpc"); + println!( "cargo:rustc-link-search={}", vendor_path @@ -52,8 +54,10 @@ fn generate_bindgen_code(project_dir: &Path) { .display() ); println!("cargo:rustc-link-lib=static=natpmp"); + println!("cargo:rustc-link-lib=dl"); println!("cargo:rustc-link-lib=m"); + println!( "cargo:rustc-link-search=native={}", vendor_path @@ -62,7 +66,27 @@ fn generate_bindgen_code(project_dir: &Path) { ); println!("cargo:rustc-link-lib=static=backtrace"); + println!("cargo:rustc-link-lib=stdc++"); + + println!( + "cargo:rustc-link-search={}", + vendor_path + .join("vendor/negentropy/cpp") + .display() + ); + println!("cargo:rustc-link-lib=static=negentropy"); + + println!("cargo:rustc-link-lib=ssl"); + println!("cargo:rustc-link-lib=crypto"); + + cc::Build::new() + .file("src/cmd.c") // Compile the C file + .compile("cmditems"); // Compile it as a library + println!("cargo:rustc-link-lib=static=cmditems"); + // TODO: Determine if pthread is automatically included + println!("cargo:rustc-link-lib=pthread"); + // TODO: Test in other architectures // Generate waku bindings with bindgen diff --git a/waku-sys/src/cmd.c b/waku-sys/src/cmd.c new file mode 100644 index 0000000..4c9147a --- /dev/null +++ b/waku-sys/src/cmd.c @@ -0,0 +1,13 @@ + +/* + This file is needed to avoid errors like the following when linking the waku-sys lib crate: + <> + and + <> +*/ + +#include + +int cmdCount = 0; +char** cmdLine = NULL; +