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 ## Installation
1. Add this repo as a submodule: This manual uses gnumake, though it should work similarly for other build systems.
```bash
git submodule add https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c.git Add this repo as a submodule:
git commit -m "add servicepoint-binding-c submodule"
``` ```bash
2. Add a build step for the servicepoint library. If you use make, this could look something like this: git submodule add https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c.git
``` git commit -m "add servicepoint-binding-c submodule"
dependencies: FORCE ```
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 cargo build --manifest-path=servicepoint-binding-c/Cargo.toml --release
FORCE: ;
``` # add static lib as a dependency for your compilation
3. Link against the library. If you are on linux and linking statically: # 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} main.c \ $(CC) $(src) $(CFLAGS) -o $@
-I servicepoint-binding-c/include \ ```
-L servicepoint-binding-c/target/release \
-Wl,-Bstatic -lservicepoint_binding_c \
-Wl,-Bdynamic -llzma \
-o out/example
```
You have the choice of linking statically (recommended) or dynamically. You have the choice of linking statically (recommended) or dynamically.
When linked dynamically, you have to provide the `cdylib` at runtime in the _same_ version, as there are no API/ABI
- 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
guarantees yet. 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 ## 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) $(_unstripped_bins): out/%_unstripped: src/%.c $(SERVICEPOINT_HEADER_OUT)/servicepoint.h $(_sp_artifacts)
mkdir -p out || true mkdir -p out || true
${CC} $< \ $(CC) $< \
-I $(SERVICEPOINT_HEADER_OUT) \ -I $(SERVICEPOINT_HEADER_OUT) \
-L $(RUST_TARGET_DIR) \ -L $(RUST_TARGET_DIR) \
$(CCFLAGS) \ $(CCFLAGS) \
@ -113,7 +113,7 @@ $(_bins): out/%: out/%_unstripped
$(_sp_artifacts): $(_rs_src) $(_sp_artifacts): $(_rs_src)
mkdir -p $(SERVICEPOINT_HEADER_OUT) || true mkdir -p $(SERVICEPOINT_HEADER_OUT) || true
# generate servicepoint header and library to link against # generate servicepoint header and library to link against
${CARGO} rustc $(CARGOFLAGS) -- $(RUSTFLAGS) $(CARGO) rustc $(CARGOFLAGS) -- $(RUSTFLAGS)
$(_run_programs): run_%: out/% FORCE $(_run_programs): run_%: out/% FORCE
./$< ./$<

View file

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