clean up
This commit is contained in:
@ -2,8 +2,13 @@
|
||||
name = "libcsp-cargo-build"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
description = "Tools to build libcsp using cargo"
|
||||
homepage = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust"
|
||||
repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust"
|
||||
license = "Apache-2.0"
|
||||
keywords = ["no-std", "space", "aerospace", "ffi", "csp"]
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support", "embedded"]
|
||||
|
||||
[dependencies]
|
||||
cc = "1"
|
||||
|
@ -3,5 +3,7 @@ libcsp-cargo-build
|
||||
|
||||
This crate provides a library to allow building the [`libcsp`](https://github.com/libcsp/libcsp)
|
||||
with cargo. You can find some more high-level information and examples in the
|
||||
[main workspace](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust). The API documentation
|
||||
should provide all additional advanced information you might require to tweak the `libcsp` build.
|
||||
[main workspace](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust).
|
||||
|
||||
The API documentation should provide all additional advanced information you might require to tweak
|
||||
the `libcsp` build.
|
||||
|
@ -3,31 +3,31 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
pub mod autoconf {
|
||||
pub const CFG_POSIX: &str = "CSP_POSIX";
|
||||
pub const CFG_ZEPHYR: &str = "CSP_ZEPHYR";
|
||||
pub mod cfg_keys {
|
||||
pub const POSIX: &str = "CSP_POSIX";
|
||||
pub const ZEPHYR: &str = "CSP_ZEPHYR";
|
||||
|
||||
pub const CFG_HAVE_STDIO: &str = "CSP_HAVE_STDIO";
|
||||
pub const CFG_ENABLE_CSP_PRINT: &str = "CSP_ENABLE_CSP_PRINT";
|
||||
pub const CFG_PRINT_STDIO: &str = "CSP_PRINT_STDIO";
|
||||
pub const HAVE_STDIO: &str = "CSP_HAVE_STDIO";
|
||||
pub const ENABLE_CSP_PRINT: &str = "CSP_ENABLE_CSP_PRINT";
|
||||
pub const PRINT_STDIO: &str = "CSP_PRINT_STDIO";
|
||||
|
||||
pub const CFG_REPRODUCIBLE_BUILDS: &str = "CSP_REPRODUCIBLE_BUILDS";
|
||||
pub const REPRODUCIBLE_BUILDS: &str = "CSP_REPRODUCIBLE_BUILDS";
|
||||
|
||||
pub const CFG_QFIFO_LEN: &str = "CSP_QFIFO_LEN";
|
||||
pub const CFG_PORT_MAX_BIND: &str = "CSP_PORT_MAX_BIND";
|
||||
pub const CFG_CONN_RXQUEUE_LEN: &str = "CSP_CONN_RXQUEUE_LEN";
|
||||
pub const CFG_CONN_MAX: &str = "CSP_CONN_MAX";
|
||||
pub const CFG_BUFFER_SIZE: &str = "CSP_BUFFER_SIZE";
|
||||
pub const CFG_BUFFER_COUNT: &str = "CSP_BUFFER_COUNT";
|
||||
pub const CFG_RDP_MAX_WINDOW: &str = "CSP_RDP_MAX_WINDOW";
|
||||
pub const CFG_RTABLE_SIZE: &str = "CSP_RTABLE_SIZE";
|
||||
pub const QFIFO_LEN: &str = "CSP_QFIFO_LEN";
|
||||
pub const PORT_MAX_BIND: &str = "CSP_PORT_MAX_BIND";
|
||||
pub const CONN_RXQUEUE_LEN: &str = "CSP_CONN_RXQUEUE_LEN";
|
||||
pub const CONN_MAX: &str = "CSP_CONN_MAX";
|
||||
pub const BUFFER_SIZE: &str = "CSP_BUFFER_SIZE";
|
||||
pub const BUFFER_COUNT: &str = "CSP_BUFFER_COUNT";
|
||||
pub const RDP_MAX_WINDOW: &str = "CSP_RDP_MAX_WINDOW";
|
||||
pub const RTABLE_SIZE: &str = "CSP_RTABLE_SIZE";
|
||||
|
||||
pub const CFG_USE_RDP: &str = "CSP_USE_RDP";
|
||||
pub const CFG_USE_HMAC: &str = "CSP_USE_HMAC";
|
||||
pub const CFG_USE_PROMISC: &str = "CSP_USE_PROMISC";
|
||||
pub const CFG_USE_RTABLE: &str = "CSP_USE_RTABLE";
|
||||
pub const CFG_HAVE_LIBSOCKETCAN: &str = "CSP_HAVE_LIBSOCKETCAN";
|
||||
pub const CFG_HAVE_LIBZMQ: &str = "CSP_HAVE_LIBZMQ";
|
||||
pub const USE_RDP: &str = "CSP_USE_RDP";
|
||||
pub const USE_HMAC: &str = "CSP_USE_HMAC";
|
||||
pub const USE_PROMISC: &str = "CSP_USE_PROMISC";
|
||||
pub const USE_RTABLE: &str = "CSP_USE_RTABLE";
|
||||
pub const HAVE_LIBSOCKETCAN: &str = "CSP_HAVE_LIBSOCKETCAN";
|
||||
pub const HAVE_LIBZMQ: &str = "CSP_HAVE_LIBZMQ";
|
||||
}
|
||||
|
||||
const SRCS_LIST: &[&str] = &[
|
||||
@ -219,103 +219,101 @@ impl Builder {
|
||||
pub fn generate_autoconf_header_file(out_dir: impl AsRef<Path>, cfg: &Config) -> io::Result<()> {
|
||||
let out_dir = out_dir.as_ref();
|
||||
let mut autoconf_file_string = String::new();
|
||||
autoconf_file_string
|
||||
.push_str("// This file was auto-generated by the libcsp-cargo-build library\n");
|
||||
#[cfg(unix)]
|
||||
autoconf_file_string.push_str("#define CSP_POSIX 1\n");
|
||||
autoconf_file_string.push_str("#define CSP_ZEPHYR 0\n");
|
||||
autoconf_file_string.push('\n');
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_HAVE_STDIO,
|
||||
cfg_keys::HAVE_STDIO,
|
||||
cfg.have_stdio as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_ENABLE_CSP_PRINT,
|
||||
cfg_keys::ENABLE_CSP_PRINT,
|
||||
cfg.csp_print as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_PRINT_STDIO,
|
||||
cfg_keys::PRINT_STDIO,
|
||||
cfg.print_stdio as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_REPRODUCIBLE_BUILDS,
|
||||
cfg_keys::REPRODUCIBLE_BUILDS,
|
||||
cfg.reproducible_builds as u32
|
||||
));
|
||||
autoconf_file_string.push('\n');
|
||||
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_QFIFO_LEN,
|
||||
cfg_keys::QFIFO_LEN,
|
||||
cfg.qfifo_len
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_PORT_MAX_BIND,
|
||||
cfg_keys::PORT_MAX_BIND,
|
||||
cfg.port_max_bind
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_CONN_RXQUEUE_LEN,
|
||||
cfg_keys::CONN_RXQUEUE_LEN,
|
||||
cfg.conn_rx_queue_len
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_CONN_MAX,
|
||||
cfg_keys::CONN_MAX,
|
||||
cfg.conn_max
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_BUFFER_SIZE,
|
||||
cfg_keys::BUFFER_SIZE,
|
||||
cfg.buffer_size
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_BUFFER_COUNT,
|
||||
cfg_keys::BUFFER_COUNT,
|
||||
cfg.buffer_count
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_RDP_MAX_WINDOW,
|
||||
cfg_keys::RDP_MAX_WINDOW,
|
||||
cfg.rdp_max_window
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_RTABLE_SIZE,
|
||||
cfg_keys::RTABLE_SIZE,
|
||||
cfg.rtable_size
|
||||
));
|
||||
|
||||
autoconf_file_string.push('\n');
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_USE_RDP,
|
||||
cfg_keys::USE_RDP,
|
||||
cfg.rdp as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_USE_HMAC,
|
||||
cfg_keys::USE_HMAC,
|
||||
cfg.hmac as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_USE_PROMISC,
|
||||
cfg_keys::USE_PROMISC,
|
||||
cfg.promisc as u32
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_USE_RTABLE,
|
||||
cfg_keys::USE_RTABLE,
|
||||
cfg.rtable as u32
|
||||
));
|
||||
|
||||
autoconf_file_string.push('\n');
|
||||
// TODO: Maybe those will be added at some point..
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"#define {} {}\n",
|
||||
autoconf::CFG_HAVE_LIBSOCKETCAN,
|
||||
0
|
||||
));
|
||||
autoconf_file_string.push_str(&format!("#define {} {}\n", autoconf::CFG_HAVE_LIBZMQ, 0));
|
||||
// TODO: Maybe those will be added at some point.. For now, they are hardcoded to 0.
|
||||
autoconf_file_string.push_str(&format!("#define {} {}\n", cfg_keys::HAVE_LIBSOCKETCAN, 0));
|
||||
autoconf_file_string.push_str(&format!("#define {} {}\n", cfg_keys::HAVE_LIBZMQ, 0));
|
||||
let out_file = out_dir.join("autoconfig.h");
|
||||
let mut file = std::fs::File::create(out_file)?;
|
||||
file.write_all(autoconf_file_string.as_bytes())?;
|
||||
@ -325,39 +323,41 @@ pub fn generate_autoconf_header_file(out_dir: impl AsRef<Path>, cfg: &Config) ->
|
||||
pub fn generate_autoconf_rust_file(out_dir: impl AsRef<Path>, cfg: &Config) -> io::Result<()> {
|
||||
let out_dir = out_dir.as_ref();
|
||||
let mut autoconf_file_string = String::new();
|
||||
autoconf_file_string
|
||||
.push_str("// This file was auto-generated by the libcsp-cargo-build library\n");
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_CONN_RXQUEUE_LEN,
|
||||
cfg_keys::CONN_RXQUEUE_LEN,
|
||||
cfg.conn_rx_queue_len
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_QFIFO_LEN,
|
||||
cfg_keys::QFIFO_LEN,
|
||||
cfg.qfifo_len
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_PORT_MAX_BIND,
|
||||
cfg_keys::PORT_MAX_BIND,
|
||||
cfg.port_max_bind
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_CONN_MAX,
|
||||
cfg_keys::CONN_MAX,
|
||||
cfg.conn_max
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_BUFFER_SIZE,
|
||||
cfg_keys::BUFFER_SIZE,
|
||||
cfg.buffer_size
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_RDP_MAX_WINDOW,
|
||||
cfg_keys::RDP_MAX_WINDOW,
|
||||
cfg.rdp_max_window
|
||||
));
|
||||
autoconf_file_string.push_str(&format!(
|
||||
"pub const {}: usize = {};\n",
|
||||
autoconf::CFG_RTABLE_SIZE,
|
||||
cfg_keys::RTABLE_SIZE,
|
||||
cfg.rtable_size
|
||||
));
|
||||
let out_file = out_dir.join("autoconfig.rs");
|
||||
@ -368,5 +368,5 @@ pub fn generate_autoconf_rust_file(out_dir: impl AsRef<Path>, cfg: &Config) -> i
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
// TODO: Unittest autoconf generator.
|
||||
// TODO: Unittest autoconf generators.
|
||||
}
|
||||
|
Reference in New Issue
Block a user