From 3bf5249d08e0a062617390816796bcbb5c34a385 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sun, 12 May 2024 21:33:47 +0200 Subject: [PATCH] move c binding into separate dir --- examples/lang_c/Makefile | 23 ++++++++----------- .../cbindgen.toml | 0 servicepoint2-binding-c/generate.sh | 4 ++++ .../servicepoint2.h | 0 servicepoint2/generate-include | 5 ---- 5 files changed, 14 insertions(+), 18 deletions(-) rename {servicepoint2 => servicepoint2-binding-c}/cbindgen.toml (100%) create mode 100755 servicepoint2-binding-c/generate.sh rename {servicepoint2/include => servicepoint2-binding-c}/servicepoint2.h (100%) delete mode 100755 servicepoint2/generate-include diff --git a/examples/lang_c/Makefile b/examples/lang_c/Makefile index cac2abf..cb2b68e 100644 --- a/examples/lang_c/Makefile +++ b/examples/lang_c/Makefile @@ -2,24 +2,21 @@ ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST)))) OUT_DIR := ${ROOT_DIR}/out SP2_DIR := ${ROOT_DIR}/../../servicepoint2 -SP2_INCLUDE := ${SP2_DIR}/include +SP2_INCLUDE := ${ROOT_DIR}/../../servicepoint2-binding-c SP2_TARGET_RELEASE := ${ROOT_DIR}/../../target/release -.PHONY: clean +.PHONY: build run clean + +build: ${OUT_DIR}/lang_c run: ${OUT_DIR}/lang_c out/lang_c -all: ${OUT_DIR}/lang_c - -${OUT_DIR}/lang_c: ${SP2_TARGET_RELEASE} main.c - mkdir -p ${OUT_DIR} - gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint2 -Wl,-Bdynamic -o ${OUT_DIR}/lang_c - -${SP2_TARGET_RELEASE}: - cd ${SP2_DIR} && cargo build --release --all-features - clean: - rm -r ${SP2_INCLUDE_DIR} || true rm -r ${OUT_DIR} || true - rm -r ${SP2_TARGET_RELEASE} || true \ No newline at end of file + rm -r ${SP2_TARGET_RELEASE} || true + +${OUT_DIR}/lang_c: main.c + cd ${SP2_DIR} && cargo build --release --all-features + mkdir -p ${OUT_DIR} + gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint2 -Wl,-Bdynamic -o ${OUT_DIR}/lang_c \ No newline at end of file diff --git a/servicepoint2/cbindgen.toml b/servicepoint2-binding-c/cbindgen.toml similarity index 100% rename from servicepoint2/cbindgen.toml rename to servicepoint2-binding-c/cbindgen.toml diff --git a/servicepoint2-binding-c/generate.sh b/servicepoint2-binding-c/generate.sh new file mode 100755 index 0000000..9ccb70a --- /dev/null +++ b/servicepoint2-binding-c/generate.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +# if the script crashes here, run `cargo install cbindgen` +cbindgen --config cbindgen.toml --clean --output servicepoint2.h ../servicepoint2 diff --git a/servicepoint2/include/servicepoint2.h b/servicepoint2-binding-c/servicepoint2.h similarity index 100% rename from servicepoint2/include/servicepoint2.h rename to servicepoint2-binding-c/servicepoint2.h diff --git a/servicepoint2/generate-include b/servicepoint2/generate-include deleted file mode 100755 index 9b1085a..0000000 --- a/servicepoint2/generate-include +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -rm -r include || true - -# if the script crashes here, run `cargo install cbindgen` -cbindgen --config cbindgen.toml --clean --output include/servicepoint2.h