separate build lib and bindings lib
This commit is contained in:
2
libcsp-cargo-build/.gitignore
vendored
Normal file
2
libcsp-cargo-build/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
/libcsp
|
118
libcsp-cargo-build/Cargo.lock
generated
Normal file
118
libcsp-cargo-build/Cargo.lock
generated
Normal file
@ -0,0 +1,118 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.98"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f"
|
||||
|
||||
[[package]]
|
||||
name = "libcsp-cargo-build"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"walkdir",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "walkdir"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b"
|
||||
dependencies = [
|
||||
"same-file",
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b"
|
||||
dependencies = [
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
|
8
libcsp-cargo-build/Cargo.toml
Normal file
8
libcsp-cargo-build/Cargo.toml
Normal file
@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "libcsp-cargo-build"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cc = "1"
|
||||
walkdir = "2"
|
90
libcsp-cargo-build/src/lib.rs
Normal file
90
libcsp-cargo-build/src/lib.rs
Normal file
@ -0,0 +1,90 @@
|
||||
pub struct CspBuildOpts {
|
||||
rtable: bool,
|
||||
csp_print: bool,
|
||||
promisc: bool,
|
||||
rdp: bool,
|
||||
yaml: bool,
|
||||
}
|
||||
|
||||
impl Default for CspBuildOpts {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rtable: true,
|
||||
csp_print: true,
|
||||
promisc: true,
|
||||
rdp: true,
|
||||
yaml: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Builder {
|
||||
opts: CspBuildOpts,
|
||||
build: cc::Build,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
opts: CspBuildOpts::default(),
|
||||
build: cc::Build::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cc(&mut self) -> &mut cc::Build {
|
||||
&mut self.build
|
||||
}
|
||||
|
||||
pub fn compile(&mut self) {
|
||||
self.build
|
||||
.file("libcsp/src/csp_bridge.c")
|
||||
.file("libcsp/src/csp_buffer.c")
|
||||
.file("libcsp/src/csp_crc32.c")
|
||||
.file("libcsp/src/csp_debug.c")
|
||||
.file("libcsp/src/csp_id.c")
|
||||
.file("libcsp/src/csp_iflist.c")
|
||||
.file("libcsp/src/csp_init.c")
|
||||
.file("libcsp/src/csp_io.c")
|
||||
.file("libcsp/src/csp_port.c")
|
||||
.file("libcsp/src/csp_promisc.c")
|
||||
.file("libcsp/src/csp_qfifo.c")
|
||||
.file("libcsp/src/csp_port.c")
|
||||
.file("libcsp/src/csp_route.c");
|
||||
if self.opts.rdp {
|
||||
self.build.file("libcsp/src/csp_rdp.c");
|
||||
self.build.file("libcsp/src/csp_rdp_queue.c");
|
||||
}
|
||||
if self.opts.promisc {
|
||||
self.build.file("libcsp/src/csp_promisc.c");
|
||||
}
|
||||
if self.opts.csp_print {
|
||||
self.build.file("libcsp/src/csp_hex_dump.c");
|
||||
}
|
||||
if self.opts.yaml {
|
||||
self.build.file("libcsp/src/csp_yaml.c");
|
||||
}
|
||||
if self.opts.rtable {
|
||||
self.build.file("libcsp/src/csp_rtable_cidr.c");
|
||||
}
|
||||
|
||||
// TODO: UNIX does not necesarilly mean POSIX? Details to deal with later..
|
||||
#[cfg(unix)]
|
||||
self.posix_arch_files();
|
||||
|
||||
self.build.include("cfg");
|
||||
self.build.include("libcsp/include");
|
||||
self.build.include("libcsp/src");
|
||||
|
||||
self.build.compile("csp");
|
||||
}
|
||||
#[cfg(unix)]
|
||||
fn posix_arch_files(&mut self) {
|
||||
self.build
|
||||
.file("libcsp/src/arch/posix/csp_clock.c")
|
||||
.file("libcsp/src/arch/posix/csp_semaphore.c")
|
||||
.file("libcsp/src/arch/posix/csp_system.c")
|
||||
.file("libcsp/src/arch/posix/csp_time.c")
|
||||
.file("libcsp/src/arch/posix/csp_queue.c")
|
||||
.file("libcsp/src/arch/posix/pthread_queue.c");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user