diff --git a/README.md b/README.md index 32f9b02..9d23d53 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ffi/Cargo.toml b/ffi/Cargo.toml index f39c25f..5cb6087 100644 --- a/ffi/Cargo.toml +++ b/ffi/Cargo.toml @@ -19,4 +19,4 @@ default = [] ffi-headers = ["cbindgen"] [build-dependencies] -cbindgen = { version = "0.6", optional = true } +cbindgen = { version = "0.9", optional = true } diff --git a/ffi/build.rs b/ffi/build.rs index 0315e0b..74affc4 100644 --- a/ffi/build.rs +++ b/ffi/build.rs @@ -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"); } } diff --git a/ffi/cbindgen.toml b/ffi/cbindgen.toml new file mode 100644 index 0000000..f0407f7 --- /dev/null +++ b/ffi/cbindgen.toml @@ -0,0 +1,2 @@ +language = "C" +cpp_compat = true diff --git a/ffi/tests/ffi.cpp b/ffi/tests/ffi.cpp index c84fd70..d2b24a0 100644 --- a/ffi/tests/ffi.cpp +++ b/ffi/tests/ffi.cpp @@ -8,7 +8,7 @@ #include #include -#include "loot_condition_interpreter.hpp" +#include "loot_condition_interpreter.h" void test_game_id_values() { printf("testing LCI_GAME_* values...\n");