rename to servicepoint, new dir structure, WIP build.rs

This commit is contained in:
Vinzenz Schroeter 2024-05-25 11:16:37 +02:00
parent e9dc4b59d2
commit f2d98af532
61 changed files with 751 additions and 140 deletions

View file

@ -0,0 +1,13 @@
[package]
name = "lang_c"
version = "0.1.0"
edition = "2021"
publish = false
[lib]
[build-dependencies]
cc = "1.0"
[dependencies]
servicepoint = { path = "../../crates/servicepoint" }

View file

@ -1,8 +1,8 @@
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
OUT_DIR := ${ROOT_DIR}/out
SP2_DIR := ${ROOT_DIR}/../../servicepoint2
SP2_INCLUDE := ${ROOT_DIR}/../../servicepoint2-binding-c
SP2_DIR := ${ROOT_DIR}/../../servicepoint
SP2_INCLUDE := ${ROOT_DIR}/../../servicepoint-binding-c
SP2_TARGET_RELEASE := ${SP2_DIR}/target/release
.PHONY: build run clean
@ -19,4 +19,4 @@ clean:
${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
gcc main.c -I ${SP2_INCLUDE} -L ${SP2_TARGET_RELEASE} -Wl,-Bstatic -lservicepoint -Wl,-Bdynamic -o ${OUT_DIR}/lang_c

8
examples/lang_c/build.rs Normal file
View file

@ -0,0 +1,8 @@
fn main() {
println!("cargo::rerun-if-changed=src/main.c");
cc::Build::new()
.file("src/main.c")
.compile("lang_c");
}

View file

View file

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