2018-02-26 23:10:53 +00:00
|
|
|
loot-condition-interpreter
|
|
|
|
|
==========================
|
|
|
|
|
|
2025-08-01 17:37:38 +01:00
|
|
|

|
2022-11-09 00:09:35 +00:00
|
|
|
[](https://coveralls.io/github/loot/loot-condition-interpreter?branch=master)
|
2018-02-26 23:10:53 +00:00
|
|
|
|
2018-11-06 14:13:37 +00:00
|
|
|
A library for parsing and evaluating LOOT's metadata condition strings. It
|
|
|
|
|
provides:
|
2018-02-26 23:10:53 +00:00
|
|
|
|
2025-04-27 07:17:01 +01:00
|
|
|
- Support for metadata syntax v0.26 condition strings.
|
2018-11-06 14:13:37 +00:00
|
|
|
- Condition string parsing without evaluation, for checking syntax.
|
|
|
|
|
- Evaluation of parsed condition strings.
|
2019-06-16 20:36:14 +01:00
|
|
|
- Efficient and safe concurrent condition evaluation thanks to Rust's safety
|
2018-11-06 14:13:37 +00:00
|
|
|
guarantees.
|
|
|
|
|
- Caching of individual function evaluation results and calculated CRCs.
|
|
|
|
|
- Executable version parsing without any external runtime dependencies.
|
|
|
|
|
- Lots of tests, and benchmarks.
|
|
|
|
|
- A C FFI library that wraps the Rust library.
|
2018-10-06 16:00:47 +01:00
|
|
|
|
2018-11-06 14:13:37 +00:00
|
|
|
## Build
|
|
|
|
|
|
|
|
|
|
Make sure you have [Rust](https://www.rust-lang.org/) installed.
|
|
|
|
|
|
|
|
|
|
To build the Rust and C FFI libraries, run:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
cargo build --release --package loot-condition-interpreter-ffi
|
|
|
|
|
```
|
|
|
|
|
|
2024-04-30 23:11:25 +01:00
|
|
|
Use [cbindgen](https://github.com/eqrion/cbindgen) to generate a C++ header file:
|
2018-11-06 14:13:37 +00:00
|
|
|
|
|
|
|
|
```
|
2019-06-28 19:54:22 +01:00
|
|
|
cbindgen ffi/ -o ffi/include/loot_condition_interpreter.h
|
2018-11-06 14:13:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Tests & Benchmarks
|
|
|
|
|
|
2023-06-25 14:03:03 +01:00
|
|
|
The tests and benchmarks need the [testing-plugins](https://github.com/Ortham/testing-plugins)
|
2018-10-05 19:52:51 +01:00
|
|
|
and the [LOOT API v0.13.8](https://github.com/loot/loot-api/releases/tag/0.13.8)
|
2020-07-12 10:27:33 +01:00
|
|
|
Windows archives to be extracted and present in the repo root. See the GitHub
|
|
|
|
|
Actions CI workflow for examples on what should be extracted where.
|
2018-11-06 14:13:37 +00:00
|
|
|
|
|
|
|
|
To run the Rust tests:
|
|
|
|
|
|
|
|
|
|
```
|
2025-08-01 18:02:24 +01:00
|
|
|
cargo test --workspace
|
2018-11-06 14:13:37 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
To run the benchmarks:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
cargo bench
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
There are also C++ tests for the FFI library, they require a C++ toolchain and
|
|
|
|
|
[CMake](https://cmake.org/) to be installed. To run the C++ tests:
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
mkdir ffi/build
|
|
|
|
|
cd ffi/build
|
|
|
|
|
cmake ..
|
|
|
|
|
cmake --build .
|
|
|
|
|
ctest
|
|
|
|
|
```
|
2026-04-03 16:13:29 +01:00
|
|
|
|
|
|
|
|
## Minimum supported Rust version
|
|
|
|
|
|
|
|
|
|
The minimum supported Rust version is `1.89`. This may change at any time, but there is a CI job to check that it does not change unexpectedly.
|