split up crate

This commit is contained in:
Robin Müller 2024-06-01 12:02:34 +02:00
parent 2ba21f9011
commit 24924ecdf2
Signed by: muellerr
GPG Key ID: A649FB78196E3849
15 changed files with 37 additions and 44 deletions

25
Cargo.lock generated
View File

@ -43,14 +43,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]] [[package]]
name = "libcsp-cargo-build" name = "libcsp"
version = "0.1.0"
dependencies = [
"cc",
]
[[package]]
name = "libcsp-rust"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"bitflags", "bitflags",
@ -58,12 +51,26 @@ dependencies = [
"num_enum", "num_enum",
] ]
[[package]]
name = "libcsp-cargo-build"
version = "0.1.0"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "libcsp-rust-examples" name = "libcsp-rust-examples"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"libcsp",
"libcsp-cargo-build", "libcsp-cargo-build",
"libcsp-rust", ]
[[package]]
name = "libcsp-sys"
version = "0.1.0"
dependencies = [
"libc",
] ]
[[package]] [[package]]

View File

@ -1,5 +1,5 @@
[workspace] [workspace]
members = [ members = [
"libcsp-cargo-build", "libcsp-rust", "examples" "libcsp-cargo-build", "libcsp", "libcsp-sys", "examples"
] ]
resolver = "2" resolver = "2"

View File

@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021" edition = "2021"
[dependencies] [dependencies]
libcsp-rust = { path = "../libcsp-rust" } libcsp = { path = "../libcsp" }
[build-dependencies] [build-dependencies]
libcsp-cargo-build = { path = "../libcsp-cargo-build" } libcsp-cargo-build = { path = "../libcsp-cargo-build" }

View File

@ -1,2 +0,0 @@
/target
/Cargo.lock

View File

@ -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);
}

16
libcsp-sys/Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "libcsp-sys"
version = "0.1.0"
edition = "2021"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
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"

0
libcsp-sys/build.rs Normal file
View File

View File

@ -1,16 +1,15 @@
[package] [package]
name = "libcsp-rust" name = "libcsp"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"] authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
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" homepage = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust"
repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust" repository = "https://egit.irs.uni-stuttgart.de/rust/libcsp-rust"
license = "Apache-2.0" license = "Apache-2.0"
keywords = ["no-std", "space", "aerospace", "ffi", "csp"] keywords = ["no-std", "space", "aerospace", "ffi", "csp"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # 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"] categories = ["aerospace", "external-ffi-bindings", "no-std", "hardware-support", "embedded"]
links = "csp"
[dependencies] [dependencies]
bitflags = "2" bitflags = "2"

View File

@ -14,6 +14,7 @@ use num_enum::{IntoPrimitive, TryFromPrimitive};
use bitflags::bitflags; use bitflags::bitflags;
use ffi::{csp_conn_s, csp_packet_s, csp_socket_s}; use ffi::{csp_conn_s, csp_packet_s, csp_socket_s};
use libcsp_sys as ffi;
#[derive(Debug, PartialEq, Eq, Copy, Clone)] #[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum ReservedPort { pub enum ReservedPort {