From 24924ecdf26cfc9d1831f7e68c481ec63ab83323 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Sat, 1 Jun 2024 12:02:34 +0200 Subject: [PATCH] split up crate --- Cargo.lock | 25 +++++++++++------ Cargo.toml | 2 +- examples/Cargo.toml | 2 +- libcsp-rust/.gitignore | 2 -- libcsp-rust/build.rs | 28 ------------------- libcsp-sys/Cargo.toml | 16 +++++++++++ libcsp-sys/build.rs | 0 {libcsp-rust => libcsp-sys}/src/config.rs | 0 .../src/ffi.rs => libcsp-sys/src/lib.rs | 0 {libcsp-rust => libcsp}/Cargo.toml | 5 ++-- {libcsp-rust => libcsp}/LICENSE-APACHE | 0 {libcsp-rust => libcsp}/NOTICE | 0 {libcsp-rust => libcsp}/README.md | 0 {libcsp-rust => libcsp}/src/lib.rs | 1 + .../templates/autoconfig.rs | 0 15 files changed, 37 insertions(+), 44 deletions(-) delete mode 100644 libcsp-rust/.gitignore delete mode 100644 libcsp-rust/build.rs create mode 100644 libcsp-sys/Cargo.toml create mode 100644 libcsp-sys/build.rs rename {libcsp-rust => libcsp-sys}/src/config.rs (100%) rename libcsp-rust/src/ffi.rs => libcsp-sys/src/lib.rs (100%) rename {libcsp-rust => libcsp}/Cargo.toml (83%) rename {libcsp-rust => libcsp}/LICENSE-APACHE (100%) rename {libcsp-rust => libcsp}/NOTICE (100%) rename {libcsp-rust => libcsp}/README.md (100%) rename {libcsp-rust => libcsp}/src/lib.rs (99%) rename {libcsp-rust => libcsp}/templates/autoconfig.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index 0ebd55b..89fc465 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -43,14 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] -name = "libcsp-cargo-build" -version = "0.1.0" -dependencies = [ - "cc", -] - -[[package]] -name = "libcsp-rust" +name = "libcsp" version = "0.1.0" dependencies = [ "bitflags", @@ -58,12 +51,26 @@ dependencies = [ "num_enum", ] +[[package]] +name = "libcsp-cargo-build" +version = "0.1.0" +dependencies = [ + "cc", +] + [[package]] name = "libcsp-rust-examples" version = "0.1.0" dependencies = [ + "libcsp", "libcsp-cargo-build", - "libcsp-rust", +] + +[[package]] +name = "libcsp-sys" +version = "0.1.0" +dependencies = [ + "libc", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 97acdf7..5b3c604 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] members = [ - "libcsp-cargo-build", "libcsp-rust", "examples" + "libcsp-cargo-build", "libcsp", "libcsp-sys", "examples" ] resolver = "2" diff --git a/examples/Cargo.toml b/examples/Cargo.toml index 8215023..b065fb0 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -libcsp-rust = { path = "../libcsp-rust" } +libcsp = { path = "../libcsp" } [build-dependencies] libcsp-cargo-build = { path = "../libcsp-cargo-build" } diff --git a/libcsp-rust/.gitignore b/libcsp-rust/.gitignore deleted file mode 100644 index 4fffb2f..0000000 --- a/libcsp-rust/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -/Cargo.lock diff --git a/libcsp-rust/build.rs b/libcsp-rust/build.rs deleted file mode 100644 index f27a0c3..0000000 --- a/libcsp-rust/build.rs +++ /dev/null @@ -1,28 +0,0 @@ -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); -} diff --git a/libcsp-sys/Cargo.toml b/libcsp-sys/Cargo.toml new file mode 100644 index 0000000..9e3f683 --- /dev/null +++ b/libcsp-sys/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "libcsp-sys" +version = "0.1.0" +edition = "2021" +authors = ["Robin Mueller "] +description = "FFI bindings for libcsp" +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"] +links = "csp" + +[dependencies] +libc = "0.2" diff --git a/libcsp-sys/build.rs b/libcsp-sys/build.rs new file mode 100644 index 0000000..e69de29 diff --git a/libcsp-rust/src/config.rs b/libcsp-sys/src/config.rs similarity index 100% rename from libcsp-rust/src/config.rs rename to libcsp-sys/src/config.rs diff --git a/libcsp-rust/src/ffi.rs b/libcsp-sys/src/lib.rs similarity index 100% rename from libcsp-rust/src/ffi.rs rename to libcsp-sys/src/lib.rs diff --git a/libcsp-rust/Cargo.toml b/libcsp/Cargo.toml similarity index 83% rename from libcsp-rust/Cargo.toml rename to libcsp/Cargo.toml index d649f10..dddc3ee 100644 --- a/libcsp-rust/Cargo.toml +++ b/libcsp/Cargo.toml @@ -1,16 +1,15 @@ [package] -name = "libcsp-rust" +name = "libcsp" version = "0.1.0" edition = "2021" authors = ["Robin Mueller "] -description = "FFI bindings and a safe and ergonomic Rust API for libcsp" +description = "Safe and ergonomic Rust API for libcsp on top on libcsp-sys" 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"] -links = "csp" [dependencies] bitflags = "2" diff --git a/libcsp-rust/LICENSE-APACHE b/libcsp/LICENSE-APACHE similarity index 100% rename from libcsp-rust/LICENSE-APACHE rename to libcsp/LICENSE-APACHE diff --git a/libcsp-rust/NOTICE b/libcsp/NOTICE similarity index 100% rename from libcsp-rust/NOTICE rename to libcsp/NOTICE diff --git a/libcsp-rust/README.md b/libcsp/README.md similarity index 100% rename from libcsp-rust/README.md rename to libcsp/README.md diff --git a/libcsp-rust/src/lib.rs b/libcsp/src/lib.rs similarity index 99% rename from libcsp-rust/src/lib.rs rename to libcsp/src/lib.rs index 13c257a..5ae87c7 100644 --- a/libcsp-rust/src/lib.rs +++ b/libcsp/src/lib.rs @@ -14,6 +14,7 @@ use num_enum::{IntoPrimitive, TryFromPrimitive}; use bitflags::bitflags; use ffi::{csp_conn_s, csp_packet_s, csp_socket_s}; +use libcsp_sys as ffi; #[derive(Debug, PartialEq, Eq, Copy, Clone)] pub enum ReservedPort { diff --git a/libcsp-rust/templates/autoconfig.rs b/libcsp/templates/autoconfig.rs similarity index 100% rename from libcsp-rust/templates/autoconfig.rs rename to libcsp/templates/autoconfig.rs