Use ffizz_header to generate taskchampion.h
This commit is contained in:
committed by
Dustin J. Mitchell
parent
989a330e46
commit
75e10676ce
@@ -3,8 +3,9 @@
|
||||
//! At the moment it is very simple, but if this grows more subcommands then
|
||||
//! it will be sensible to use `clap` or another similar library.
|
||||
|
||||
use cbindgen::*;
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn main() -> anyhow::Result<()> {
|
||||
@@ -18,32 +19,13 @@ pub fn main() -> anyhow::Result<()> {
|
||||
|
||||
/// `cargo xtask codegen`
|
||||
///
|
||||
/// This uses cbindgen to generate `lib/taskchampion.h`.
|
||||
/// This uses ffizz-header to generate `lib/taskchampion.h`.
|
||||
fn codegen() -> anyhow::Result<()> {
|
||||
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
|
||||
let workspace_dir = manifest_dir.parent().unwrap();
|
||||
let lib_crate_dir = workspace_dir.join("lib");
|
||||
|
||||
Builder::new()
|
||||
.with_crate(&lib_crate_dir)
|
||||
.with_config(Config {
|
||||
header: Some(include_str!("../../lib/header-intro.h").into()),
|
||||
language: Language::C,
|
||||
include_guard: Some("TASKCHAMPION_H".into()),
|
||||
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(lib_crate_dir.join("taskchampion.h"));
|
||||
let mut file = File::create(lib_crate_dir.join("taskchampion.h")).unwrap();
|
||||
write!(&mut file, "{}", ::taskchampion_lib::generate_header()).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user