split works

This commit is contained in:
Robin Müller 2024-06-01 12:05:24 +02:00
parent 24924ecdf2
commit fa13f3b367
Signed by: muellerr
GPG Key ID: A649FB78196E3849
5 changed files with 35 additions and 8 deletions

1
Cargo.lock generated
View File

@ -48,6 +48,7 @@ version = "0.1.0"
dependencies = [
"bitflags",
"libc",
"libcsp-sys",
"num_enum",
]

View File

@ -8,11 +8,11 @@ use std::{
time::Duration,
};
use libcsp_rust::{
use libcsp::{
csp_accept_guarded, csp_bind, csp_buffer_get, csp_conn_dport, csp_conn_print_table,
csp_connect_guarded, csp_iflist_print, csp_init, csp_listen, csp_ping, csp_read,
csp_read_guarded, csp_reboot, csp_route_work, csp_send, csp_service_handler, ConnectOpts,
CspSocket, MsgPriority, SocketFlags, CSP_ANY, CSP_LOOPBACK,
csp_connect_guarded, csp_iflist_print, csp_init, csp_listen, csp_ping, csp_read_guarded,
csp_reboot, csp_route_work, csp_send, csp_service_handler, ConnectOpts, CspError, CspSocket,
MsgPriority, SocketFlags, CSP_ANY, CSP_LOOPBACK,
};
const MY_SERVER_PORT: i32 = 10;
@ -38,7 +38,7 @@ fn main() -> Result<(), u32> {
}
if let Err(e) = csp_route_work() {
match e {
libcsp_rust::CspError::TimedOut => continue,
CspError::TimedOut => continue,
e => {
println!("CSP router error: {:?}", e);
break;

View File

@ -0,0 +1,28 @@
use std::{env, path::PathBuf};
pub const ENV_KEY_CSP_CONFIG_DIR: &str = "CSP_CONFIG_DIR";
fn main() {
println!("cargo:rustc-link-lib=csp");
let out_path = env::var("OUT_DIR").unwrap();
let csp_conf_dir = match env::var("CSP_CONFIG_DIR") {
Ok(conf_path) => conf_path,
Err(_e) => {
println!("cargo:warning=CSP_CONFIG_DIR not set, using CARGO_MANIFEST_DIR to search for autoconfig.rs");
env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set")
}
};
let mut csp_conf_path = PathBuf::new();
csp_conf_path.push(csp_conf_dir);
csp_conf_path.push("autoconfig.rs");
if !csp_conf_path.exists() {
panic!(
"autoconfig.rs not found at {:?}, is required for library build",
csp_conf_path
);
}
let out_path_full = PathBuf::from(&out_path).join("autoconfig.rs");
std::fs::copy(&csp_conf_path, out_path_full).expect("failed to copy autoconfig.rs to OUT_DIR");
println!("cargo::rerun-if-changed={:?}", &csp_conf_path);
}

View File

@ -15,3 +15,4 @@ categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support"
bitflags = "2"
num_enum = "0.7"
libc = "0.2"
libcsp-sys = { path = "../libcsp-sys" }

View File

@ -5,9 +5,6 @@ extern crate alloc;
#[cfg(any(feature = "std", test))]
extern crate std;
pub mod config;
pub mod ffi;
use core::time::Duration;
use num_enum::{IntoPrimitive, TryFromPrimitive};