From ed8e36257486237f58d859318e6a58768157e467 Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sun, 16 Feb 2025 18:14:56 +0100 Subject: [PATCH] extend installation instructions, fix perm --- README.md | 39 ++++++++++++++++++++++++++++++++------- generate-binding.sh | 0 2 files changed, 32 insertions(+), 7 deletions(-) mode change 100644 => 100755 generate-binding.sh diff --git a/README.md b/README.md index 5204572..6d7b527 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![docs.rs](https://img.shields.io/docsrs/servicepoint_binding_c)](https://docs.rs/servicepoint/latest/servicepoint/) [![GPLv3 licensed](https://img.shields.io/crates/l/servicepoint_binding_c)](../LICENSE) -In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. +In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display". This crate contains C bindings for the `servicepoint` library, enabling users to parse, encode and send packets to this display via UDP. @@ -43,21 +43,46 @@ Please specify the full version including patch in your Cargo.toml until 1.0 is ## Installation -Copy the header to your project and compile against. +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 + ``` 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 guarantees yet. +- When linked dynamically, you have to provide the `cdylib` at runtime in the _same_ version, as there are no API/ABI + guarantees yet. ## Notes on differences to rust library - function names are: `sp_` \ \. -- Instances get consumed in the same way they do when writing rust code. Do not use an instance after an (implicit!) free. +- Instances get consumed in the same way they do when writing rust code. Do not use an instance after an (implicit!) + free. - Option or Result turn into nullable return values - check for NULL! -- There are no specifics for C++ here yet. You might get a nicer header when generating directly for C++, but it should be usable. +- There are no specifics for C++ here yet. You might get a nicer header when generating directly for C++, but it should + be usable. - Reading and writing to instances concurrently is not safe. Only reading concurrently is safe. -- documentation is included in the header and available [online](https://docs.rs/servicepoint_binding_c/latest/servicepoint_binding_c/) +- documentation is included in the header and + available [online](https://docs.rs/servicepoint_binding_c/latest/servicepoint_binding_c/) ## Everything else -Look at the main project [README](https://git.berlin.ccc.de/servicepoint/servicepoint/src/branch/main/README.md) for further information. +Look at the main project [README](https://git.berlin.ccc.de/servicepoint/servicepoint/src/branch/main/README.md) for +further information. diff --git a/generate-binding.sh b/generate-binding.sh old mode 100644 new mode 100755