mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
rename rust/ to taskchampion/
This commit is contained in:
parent
ccb9a0fdfb
commit
12ecfa2b1e
161 changed files with 15 additions and 15 deletions
49
taskchampion/xtask/src/main.rs
Normal file
49
taskchampion/xtask/src/main.rs
Normal 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(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue