library is configurable now

This commit is contained in:
2024-05-31 12:35:29 +02:00
parent 637d87756c
commit 89a90f55b4
9 changed files with 116 additions and 10 deletions

7
examples/autoconfig.rs Normal file
View File

@ -0,0 +1,7 @@
const CSP_CONN_RXQUEUE_LEN: usize = 16
const CSP_QFIFO_LEN: usize = 16
const CSP_PORT_MAX_BIND: usize = 16
const CSP_CONN_MAX: usize = 8
const CSP_BUFFER_SIZE: usize = 256
const CSP_RDP_MAX_WINDOW: usize = 5
const CSP_RTABLE_SIZE: usize = 10

View File

@ -4,8 +4,18 @@ use libcsp_cargo_build::Builder;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap_or_default();
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap_or_default();
let libcsp_path = "../lib/libcsp";
let mut csp_builder = Builder::new(PathBuf::from(libcsp_path), PathBuf::from(out_dir));
let mut csp_builder = Builder::new(PathBuf::from(libcsp_path), PathBuf::from(&out_dir));
let update_autoconf = match env::var("UPDATE_CSP_AUTOCONF") {
Ok(update_autoconf) => update_autoconf == "1",
Err(_e) => false,
};
if update_autoconf {
csp_builder
.generate_autoconf_rust_file(PathBuf::from(&manifest_dir))
.expect("generating autoconfig.rs failed");
println!("cargo:warning=autoconfig.rs updated");
}
csp_builder.compile().expect("compiling libcsp failed");
}