This commit is contained in:
Robin Müller 2024-06-01 01:23:26 +02:00
parent 64291e947f
commit b79c775801
Signed by: muellerr
GPG Key ID: A649FB78196E3849

View File

@ -11,7 +11,7 @@ It provides 2 crates for this:
- [`libcsp-rust`](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/libcsp-rust) - [`libcsp-rust`](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/libcsp-rust)
provides the Rust bindings to `libcsp` and a safe and ergonomic Rust interface. provides the Rust bindings to `libcsp` and a safe and ergonomic Rust interface.
In addition, it provides a workspace to allow updating the `libcsp` and the corresponding bindings In addition, it provides a workspace to allow updating the `libcsp` and the corresponding bindings
more easily inside the `lib` directory. Some of the examples `libcsp` provides were ported to Rust more easily inside the `lib` directory. Some of the examples `libcsp` provides were ported to Rust
and are showcases in the `examples` directory. and are showcases in the `examples` directory.
@ -36,8 +36,8 @@ The example uses both the builder crate and the bindings and API crate and imple
[server/client example](https://github.com/libcsp/libcsp/blob/develop/examples/csp_server_client.c) [server/client example](https://github.com/libcsp/libcsp/blob/develop/examples/csp_server_client.c)
in Rust. You can run the example using the following steps: in Rust. You can run the example using the following steps:
1. Clone `libcsp` into the `lib` folder, for example by using the provided `lib/clone-csp.sh` 1. Clone/Copy `libcsp` into the `lib` folder, for example by using the provided `lib/clone-csp.sh`
script. script or adding `libcsp` as a git submodule.
2. You can now use `cargo run -p libcsp-rust-examples` to run the server/client example. 2. You can now use `cargo run -p libcsp-rust-examples` to run the server/client example.
## Compile-time configuration of the `libcsp-rust` library ## Compile-time configuration of the `libcsp-rust` library
@ -46,10 +46,12 @@ The `libcsp-rust` library requires some compile-time configuration file to be in
properly. You can see an example version of the file for the workspace properly. You can see an example version of the file for the workspace
[here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs). [here](https://egit.irs.uni-stuttgart.de/rust/libcsp-rust/src/branch/main/examples/autoconfig.rs).
The user has to provide the path to a directory containing this `autoconfig.rs` file using the The user has to provide the path to a directory containing this `autoconfig.rs` file using the
`CSP_CONFIG_DIR` environmental variable. `CSP_CONFIG_DIR` environmental variable.
You can automatically generate this file when using `libcsp-cargo-build` by using the You can automatically generate this file when using `libcsp-cargo-build` by using the
[`generate_autoconf_rust_file`] method of the Builder object as done in the example build script. [`generate_autoconf_rust_file`](here be link soon) method of the Builder object as done in the
example build script.
In this workspace, the `CSP_CONFIG_DIR` variable is hardcoded using the following `.cargo/config.toml` In this workspace, the `CSP_CONFIG_DIR` variable is hardcoded using the following `.cargo/config.toml`
configuration: configuration:
@ -84,4 +86,3 @@ bindgen --use-core wrapper.h -- "-I./libcsp/include" "-I./cfg" "-I./libcsp/src"
With the bindings file, you can now manually update the FFI bindings provided in With the bindings file, you can now manually update the FFI bindings provided in
`libcsp-rust/src/ffi.rs` or in your own CSP library. `libcsp-rust/src/ffi.rs` or in your own CSP library.