yet another variant of the c library. now the header has to be generated manually.

This commit is contained in:
Vinzenz Schroeter 2024-05-12 21:14:23 +02:00
parent ff64557d29
commit 27a87cc80a
10 changed files with 431 additions and 327 deletions

View file

@ -1,4 +0,0 @@
.idea
out
rust-target
include

View file

@ -1,7 +1,9 @@
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
RUST_TARGET_DIR := ${ROOT_DIR}rust-target
export SP2_INCLUDE_DIR := ${ROOT_DIR}sp2
OUT_DIR := ${ROOT_DIR}out
OUT_DIR := ${ROOT_DIR}/out
SP2_DIR := ${ROOT_DIR}/../../servicepoint2
SP2_INCLUDE := ${SP2_DIR}/include
SP2_TARGET_RELEASE := ${ROOT_DIR}/../../target/release
.PHONY: clean
@ -10,14 +12,14 @@ run: ${OUT_DIR}/lang_c
all: ${OUT_DIR}/lang_c
${OUT_DIR}/lang_c: ${SP2_INCLUDE_DIR}/sp2-bindings.h main.c
${OUT_DIR}/lang_c: ${SP2_TARGET_RELEASE} main.c
mkdir -p ${OUT_DIR}
gcc ${SP2_INCLUDE_DIR}/sp2-bindings.h main.c -L ${RUST_TARGET_DIR}/release/ -Wl,-Bstatic -l servicepoint2 -Wl,-Bdynamic -o ${OUT_DIR}/lang_c --verbose
gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint2 -Wl,-Bdynamic -o ${OUT_DIR}/lang_c
${SP2_INCLUDE_DIR}/sp2-bindings.h:
cd ../../servicepoint2/ && cargo build --release --target-dir ${RUST_TARGET_DIR} --all-features
${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 ${RUST_TARGET_DIR} || true
rm -r ${SP2_TARGET_RELEASE} || true

View file

@ -1,5 +1,5 @@
#include <stdio.h>
#include "sp2/sp2-bindings.h"
#include "servicepoint2.h"
int main(void) {
sp2_Connection *connection = sp2_connection_open("localhost:2342");