summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authormario <mario-krehl@gmx.de>2016-11-01 20:06:38 +0100
committermario <mario-krehl@gmx.de>2016-11-05 11:38:55 +0100
commitbf88a43a59f81341e436f73326e7117a30881dc4 (patch)
treeded24fbac7260dec14d89987eb07d8de8f74213c /bin
parent1db063f3343ccb8d7a2ea2f1c3acf8eb24d39162 (diff)
Add build.rs with basic idea
Diffstat (limited to 'bin')
-rw-r--r--bin/Cargo.toml7
-rw-r--r--bin/build.rs49
2 files changed, 56 insertions, 0 deletions
diff --git a/bin/Cargo.toml b/bin/Cargo.toml
index 3c02cd6d..cf9801e4 100644
--- a/bin/Cargo.toml
+++ b/bin/Cargo.toml
@@ -13,6 +13,13 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h
repository = "https://github.com/matthiasbeyer/imag"
homepage = "http://imag-pim.org"
+build = "build.rs"
+
+[build-dependencies]
+clap = ">=2.16.1"
+libimagrt = { path = "../libimagrt" }
+version = "2.0"
+
[profile.dev]
codegen-units = 2
diff --git a/bin/build.rs b/bin/build.rs
new file mode 100644
index 00000000..74fd4199
--- /dev/null
+++ b/bin/build.rs
@@ -0,0 +1,49 @@
+extern crate clap;
+extern crate libimagrt;
+#[macro_use] extern crate version;
+
+use clap::Shell;
+use libimagrt::runtime::Runtime;
+
+include!("../imag-store/src/ui.rs");
+
+macro_rules! gen_types_buildui {
+ ($(($p:expr, $n:ident)$(,)*)*) => (
+ trait _buildui_fn_type_trait {
+ fn build_ui<'a>(app : App<'a, 'a>) -> App<'a, 'a>;
+ }
+ $(
+ struct $n;
+ impl $n {
+ pub fn new() -> Self {
+ {}
+ }
+ }
+ impl _buildui_fn_type_trait for $n {
+ include!($p);
+ }
+ )*
+ )
+}
+
+gen_types_buildui!(("../imag-store/src/ui.rs", imagstore), ("../imag-todo/src/ui.rs", imagtodo));
+
+fn main() {
+ let mut app = Runtime::get_default_cli_builder(
+ "imag",
+ &version!()[..],
+ "imag foo bar");
+ let v = vec![("store", imagstore::new()), ("todo", imagtodo::new())];
+ for (name, obj) in v {
+ app
+ .subcommand(
+ obj::build_ui(Runtime::get_default_cli_builder(
+ name,
+ &version!()[..],
+ name)));
+ }
+ app.gen_completions("imag", Shell::Bash, env!("OUT_DIR"));
+ app.gen_completions("imag", Shell::Fish, env!("OUT_DIR"));
+ app.gen_completions("imag", Shell::Zsh, env!("OUT_DIR"));
+
+}