From 0b7e0b20a87b91bae4af1d2df2752c40f51916d0 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 10 Dec 2020 15:47:44 -0500 Subject: [PATCH] Rust skeleton for core shim lib. --- .gitignore | 1 + Makefile | 23 +++++++++++++++-------- rust-zerotier-core/Cargo.toml | 9 +++++++++ rust-zerotier-core/src/capi/.gitkeep | 0 rust-zerotier-core/src/lib.rs | 7 +++++++ 5 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 rust-zerotier-core/Cargo.toml create mode 100644 rust-zerotier-core/src/capi/.gitkeep create mode 100644 rust-zerotier-core/src/lib.rs diff --git a/.gitignore b/.gitignore index 718deda89..4077f669a 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ node_modules *.vcxproj.backup /*.db /*.opendb +/rust-zerotier-core/src/capi/zerotier-capi.rs diff --git a/Makefile b/Makefile index f072b80f8..06d992ce4 100644 --- a/Makefile +++ b/Makefile @@ -6,26 +6,33 @@ TIMESTAMP=$(shell date +"%Y%m%d%H%M") all: setup cd ${BUILDDIR} && $(MAKE) -j4 VERBOSE=1 -setup: +setup: FORCE mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release ${CMAKE_ARGS} -setup-debug: +setup-debug: FORCE mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS} -debug: +debug: FORCE mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug ${CMAKE_ARGS} && $(MAKE) -central-controller: +central-controller: FORCE mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_CENTRAL_CONTROLLER=1 ${CMAKE_ARGS} && $(MAKE) -j4 -central-controller-debug: +central-controller-debug: FORCE mkdir -p ${BUILDDIR} && cd ${BUILDDIR} && cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_CENTRAL_CONTROLLER=1 ${CMAKE_ARGS} && $(MAKE) -j4 -central-controller-docker: +central-controller-docker: FORCE docker build -t registry.zerotier.com/zerotier-central/ztcentral-controller:${TIMESTAMP} -f controller/central-docker/Dockerfile . -clean: +clean: FORCE rm -rf ${BUILDDIR} -distclean: +distclean: FORCE rm -rf ${BUILDDIR} + +rust-zerotier-core-bindgen: FORCE + cargo install bindgen + rm -f rust-zerotier-core/src/capi/zerotier-capi.rs + bindgen core/zerotier.h >rust-zerotier-core/src/capi/zerotier-capi.rs + +FORCE: diff --git a/rust-zerotier-core/Cargo.toml b/rust-zerotier-core/Cargo.toml new file mode 100644 index 000000000..8517e095f --- /dev/null +++ b/rust-zerotier-core/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "rust-zerotier-core" +version = "0.1.0" +authors = ["Adam Ierymenko "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust-zerotier-core/src/capi/.gitkeep b/rust-zerotier-core/src/capi/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/rust-zerotier-core/src/lib.rs b/rust-zerotier-core/src/lib.rs new file mode 100644 index 000000000..31e1bb209 --- /dev/null +++ b/rust-zerotier-core/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +}