use codegen, instead of build.rs, to build header file

This commit is contained in:
Dustin J. Mitchell 2022-02-16 00:28:07 +00:00
parent 02055b122e
commit b1d537ac87
8 changed files with 76 additions and 35 deletions

View file

@ -2,7 +2,6 @@
name = "taskchampion-lib"
version = "0.1.0"
edition = "2018"
build = "build.rs"
[lib]
name = "taskchampion"
@ -17,6 +16,3 @@ anyhow = "1.0"
[dev-dependencies]
pretty_assertions = "1"
[build-dependencies]
cbindgen = "0.20.0"

View file

@ -1,26 +0,0 @@
use cbindgen::*;
use std::env;
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
Builder::new()
.with_crate(crate_dir)
.with_config(Config {
language: Language::C,
cpp_compat: true,
sys_includes: vec!["stdbool.h".into(), "stdint.h".into(), "time.h".into()],
usize_is_size_t: true,
no_includes: true,
enumeration: EnumConfig {
// this appears to still default to true for C
enum_class: false,
..Default::default()
},
..Default::default()
})
.generate()
.expect("Unable to generate bindings")
.write_to_file("taskchampion.h");
}