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
|
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)
|
However, this involves building [cbindgen](https://github.com/eqrion/cbindgen)
|
||||||
as a dependency, which is relatively slow. If you have cbindgen installed
|
as a dependency, which is relatively slow. If you have cbindgen installed
|
||||||
separately, it's faster to generate the headers using its CLI:
|
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
|
## Tests & Benchmarks
|
||||||
|
|||||||
+1
-1
@@ -19,4 +19,4 @@ default = []
|
|||||||
ffi-headers = ["cbindgen"]
|
ffi-headers = ["cbindgen"]
|
||||||
|
|
||||||
[build-dependencies]
|
[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::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use self::cbindgen::Builder;
|
use self::cbindgen::generate;
|
||||||
use self::cbindgen::Language;
|
|
||||||
|
|
||||||
pub fn generate_headers() {
|
pub fn generate_headers() {
|
||||||
let crate_dir = env::var("CARGO_MANIFEST_DIR")
|
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");
|
fs::create_dir_all("include").expect("could not create include directory");
|
||||||
|
|
||||||
Builder::new()
|
generate(&crate_dir)
|
||||||
.with_crate(&crate_dir)
|
.expect("could not generate C/C++ header file")
|
||||||
.with_language(Language::Cxx)
|
.write_to_file("include/loot_condition_interpreter.h");
|
||||||
.with_std_types(false)
|
|
||||||
.generate()
|
|
||||||
.expect("could not generate C++ header file")
|
|
||||||
.write_to_file("include/loot_condition_interpreter.hpp");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
language = "C"
|
||||||
|
cpp_compat = true
|
||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "loot_condition_interpreter.hpp"
|
#include "loot_condition_interpreter.h"
|
||||||
|
|
||||||
void test_game_id_values() {
|
void test_game_id_values() {
|
||||||
printf("testing LCI_GAME_* values...\n");
|
printf("testing LCI_GAME_* values...\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user