Skip to content

Commit

Permalink
Update cbindgen, generate a single C/C++ header
Browse files Browse the repository at this point in the history
  • Loading branch information
Ortham committed Jun 28, 2019
1 parent adcd218 commit 2bf61a9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ default = []
ffi-headers = ["cbindgen"]

[build-dependencies]
cbindgen = { version = "0.8", optional = true }
cbindgen = { version = "0.9", optional = true }
15 changes: 2 additions & 13 deletions ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,16 @@ mod ffi_headers {
use std::fs;

use self::cbindgen::generate;
use self::cbindgen::Builder;
use self::cbindgen::Language;

pub fn generate_headers() {
let crate_dir = env::var("CARGO_MANIFEST_DIR")
.expect("could not get value of CARGO_MANIFEST_DIR env var");

fs::create_dir_all("include").expect("could not create include directory");

Builder::new()
.with_crate(&crate_dir)
.with_language(Language::C)
.with_parse_deps(true)
.with_parse_include(&["esplugin"])
.generate()
.expect("could not generate C header file")
.write_to_file("include/esplugin.h");

generate(&crate_dir)
.expect("could not generate C++ header file")
.write_to_file("include/esplugin.hpp");
.expect("could not generate C/C++ header file")
.write_to_file("include/esplugin.h");
}
}

Expand Down
3 changes: 2 additions & 1 deletion ffi/cbindgen.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
language = "C++"
language = "C"
cpp_compat = true

[parse]
parse_deps = true
Expand Down
2 changes: 1 addition & 1 deletion ffi/tests/ffi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <cstdio>
#include <cstring>

#include "esplugin.hpp"
#include "esplugin.h"

void test_game_id_values() {
printf("testing ESP_GAME_* values...\n");
Expand Down

0 comments on commit 2bf61a9

Please sign in to comment.