rename rust/ to taskchampion/

This commit is contained in:
Dustin J. Mitchell 2022-07-10 16:27:52 +00:00 committed by Tomas Babej
parent ccb9a0fdfb
commit 12ecfa2b1e
161 changed files with 15 additions and 15 deletions

View file

@ -0,0 +1,49 @@
//! This executable defines the `cargo xtask` subcommands.
//!
//! 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::path::PathBuf;
pub fn main() -> anyhow::Result<()> {
let arg = env::args().nth(1);
match arg.as_deref() {
Some("codegen") => codegen(),
Some(arg) => anyhow::bail!("unknown xtask {}", arg),
_ => anyhow::bail!("unknown xtask"),
}
}
/// `cargo xtask codegen`
///
/// This uses cbindgen 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"));
Ok(())
}