mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Update cbindgen, generate a single C/C++ header
This commit is contained in:
@@ -35,13 +35,13 @@ To generate a C++ header file as part of the build, instead run:
|
||||
cargo build --release --package loot-condition-interpreter-ffi --all-features
|
||||
```
|
||||
|
||||
This will create a file at `ffi/include/loot_condition_interpreter.hpp`.
|
||||
This will create a file at `ffi/include/loot_condition_interpreter.h`.
|
||||
However, this involves building [cbindgen](https://github.com/eqrion/cbindgen)
|
||||
as a dependency, which is relatively slow. If you have cbindgen installed
|
||||
separately, it's faster to generate the headers using its CLI:
|
||||
|
||||
```
|
||||
cbindgen ffi/ -l c++ -o ffi/include/loot_condition_interpreter.hpp
|
||||
cbindgen ffi/ -o ffi/include/loot_condition_interpreter.h
|
||||
```
|
||||
|
||||
## Tests & Benchmarks
|
||||
|
||||
+1
-1
@@ -19,4 +19,4 @@ default = []
|
||||
ffi-headers = ["cbindgen"]
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = { version = "0.6", optional = true }
|
||||
cbindgen = { version = "0.9", optional = true }
|
||||
|
||||
+4
-9
@@ -5,8 +5,7 @@ mod ffi_headers {
|
||||
use std::env;
|
||||
use std::fs;
|
||||
|
||||
use self::cbindgen::Builder;
|
||||
use self::cbindgen::Language;
|
||||
use self::cbindgen::generate;
|
||||
|
||||
pub fn generate_headers() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR")
|
||||
@@ -14,13 +13,9 @@ mod ffi_headers {
|
||||
|
||||
fs::create_dir_all("include").expect("could not create include directory");
|
||||
|
||||
Builder::new()
|
||||
.with_crate(&crate_dir)
|
||||
.with_language(Language::Cxx)
|
||||
.with_std_types(false)
|
||||
.generate()
|
||||
.expect("could not generate C++ header file")
|
||||
.write_to_file("include/loot_condition_interpreter.hpp");
|
||||
generate(&crate_dir)
|
||||
.expect("could not generate C/C++ header file")
|
||||
.write_to_file("include/loot_condition_interpreter.h");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
language = "C"
|
||||
cpp_compat = true
|
||||
+1
-1
@@ -8,7 +8,7 @@
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
#include "loot_condition_interpreter.hpp"
|
||||
#include "loot_condition_interpreter.h"
|
||||
|
||||
void test_game_id_values() {
|
||||
printf("testing LCI_GAME_* values...\n");
|
||||
|
||||
Reference in New Issue
Block a user