remove all the wrappers, update servicepoint #1

Merged
vinzenz merged 28 commits from next into main 2025-05-04 14:02:53 +02:00
3 changed files with 30 additions and 26 deletions
Showing only changes of commit b06241f8d3 - Show all commits

View file

@ -43,32 +43,37 @@ Please specify the full version including patch in your Cargo.toml until 1.0 is
## Installation
1. Add this repo as a submodule:
```bash
git submodule add https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c.git
git commit -m "add servicepoint-binding-c submodule"
```
2. Add a build step for the servicepoint library. If you use make, this could look something like this:
```
dependencies: FORCE
cargo build --manifest-path=servicepoint-binding-c/Cargo.toml --release
FORCE: ;
```
3. Link against the library. If you are on linux and linking statically:
```
${CC} main.c \
-I servicepoint-binding-c/include \
-L servicepoint-binding-c/target/release \
-Wl,-Bstatic -lservicepoint_binding_c \
-Wl,-Bdynamic -llzma \
-o out/example
```
This manual uses gnumake, though it should work similarly for other build systems.
Add this repo as a submodule:
```bash
git submodule add https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c.git
git commit -m "add servicepoint-binding-c submodule"
```
Update your Makefile:
```Makefile
# provide header and binary to CC
CFLAGS += -I servicepoint-binding-c/include -L servicepoint-binding-c/target/release
# link statically against servicepoint, link against lzma dynamically
CFLAGS += -Wl,-Bstatic -lservicepoint_binding_c -Wl,-Bdynamic -llzma
# add target to build rust library - cargo will check for dependency changes
servicepoint-binding-c/target/release/libservicepoint.a:
cargo build --manifest-path=servicepoint-binding-c/Cargo.toml --release
# add static lib as a dependency for your compilation
# if you build .so files separately, this should be part of your build step
my_bin: $(src) servicepoint-binding-c/target/release/libservicepoint.a
$(CC) $(src) $(CFLAGS) -o $@
```
You have the choice of linking statically (recommended) or dynamically.
- The C example shows how to link statically against the `staticlib` variant.
- When linked dynamically, you have to provide the `cdylib` at runtime in the _same_ version, as there are no API/ABI
When linked dynamically, you have to provide the `cdylib` at runtime in the _same_ version, as there are no API/ABI
guarantees yet.
The Makefile in the example directory contains a bunch of additional compiler flags you might want to add depending on your use case.
## Notes on differences to rust library

View file

@ -101,7 +101,7 @@ clean-rust:
$(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts)
mkdir -p out || true
${CC} $< \
$(CC) $< \
-I $(SERVICEPOINT_HEADER_OUT) \
-L $(RUST_TARGET_DIR) \
$(CCFLAGS) \
@ -113,7 +113,7 @@ $(_bins): out/%: out/%_unstripped
$(_sp_artifacts): $(_rs_src)
mkdir -p $(SERVICEPOINT_HEADER_OUT) || true
# generate servicepoint header and library to link against
${CARGO} rustc $(CARGOFLAGS) -- $(RUSTFLAGS)
$(CARGO) rustc $(CARGOFLAGS) -- $(RUSTFLAGS)
$(_run_programs): run_%: out/% FORCE
./$<

View file

@ -37,7 +37,6 @@
xe
xz
libgcc
musl
libunwind
pkgsStatic.musl
];