From f5f4fbc397320e808a503ae040c64635968d57b3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 31 Jan 2018 10:52:19 +0100 Subject: [PATCH 1/4] Add buildscript and infrastructure to include git information in version --- build.rs | 34 +++++++++++++++++++++++++++++++ lib/core/libimagrt/src/lib.rs | 1 + lib/core/libimagrt/src/version.rs | 32 +++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 build.rs create mode 100644 lib/core/libimagrt/src/version.rs diff --git a/build.rs b/build.rs new file mode 100644 index 00000000..ce7cf02d --- /dev/null +++ b/build.rs @@ -0,0 +1,34 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015-2018 the imag contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + +use std::process::Command; +fn main() { + let profile = String::from(std::env::var("PROFILE").unwrap()); + let git_hash = if profile == "debug" { + let output = Command::new("git") + .args(&["rev-parse", "--short=10", "HEAD"]) + .output() + .unwrap(); + String::from_utf8(output.stdout).unwrap() + } else { + String::from("") + }; + + println!("cargo:rustc-env=CARGO_BUILD_GIT_HASH={}", git_hash); +} diff --git a/lib/core/libimagrt/src/lib.rs b/lib/core/libimagrt/src/lib.rs index b7336ab4..b6c6e735 100644 --- a/lib/core/libimagrt/src/lib.rs +++ b/lib/core/libimagrt/src/lib.rs @@ -59,4 +59,5 @@ pub mod logger; pub mod runtime; pub mod setup; pub mod spec; +pub mod version; diff --git a/lib/core/libimagrt/src/version.rs b/lib/core/libimagrt/src/version.rs new file mode 100644 index 00000000..3f6d0ff3 --- /dev/null +++ b/lib/core/libimagrt/src/version.rs @@ -0,0 +1,32 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015-2018 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + +#[macro_export] +macro_rules! make_imag_version { + () => {{ + let pkg_version = env!("CARGO_PKG_VERSION"); + let git_version = env!("CARGO_BUILD_GIT_HASH"); + + if git_version == "" { + String::from(pkg_version) + } else { + format!("{}-{}", pkg_version, git_version) + } + }} +} From 9469693763fe95be3d07a14d89cd473192646bd5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 31 Jan 2018 11:09:00 +0100 Subject: [PATCH 2/4] Use new make_imag_version!() macro for building version string --- bin/core/imag-annotate/Cargo.toml | 2 ++ bin/core/imag-annotate/src/main.rs | 5 +++-- bin/core/imag-diagnostics/Cargo.toml | 2 ++ bin/core/imag-diagnostics/src/main.rs | 5 +++-- bin/core/imag-edit/Cargo.toml | 2 ++ bin/core/imag-edit/src/main.rs | 5 +++-- bin/core/imag-gps/Cargo.toml | 2 ++ bin/core/imag-gps/src/main.rs | 5 +++-- bin/core/imag-grep/Cargo.toml | 2 ++ bin/core/imag-grep/src/main.rs | 5 +++-- bin/core/imag-init/Cargo.toml | 2 ++ bin/core/imag-link/Cargo.toml | 2 ++ bin/core/imag-link/src/main.rs | 5 +++-- bin/core/imag-mv/Cargo.toml | 2 ++ bin/core/imag-mv/src/main.rs | 5 +++-- bin/core/imag-ref/Cargo.toml | 2 ++ bin/core/imag-ref/src/main.rs | 5 +++-- bin/core/imag-store/Cargo.toml | 2 ++ bin/core/imag-store/src/main.rs | 5 +++-- bin/core/imag-tag/Cargo.toml | 2 ++ bin/core/imag-tag/src/main.rs | 5 +++-- bin/core/imag-view/Cargo.toml | 2 ++ bin/core/imag-view/src/main.rs | 5 +++-- bin/core/imag/Cargo.toml | 2 ++ bin/core/imag/src/main.rs | 6 +++--- bin/domain/imag-bookmark/Cargo.toml | 2 ++ bin/domain/imag-bookmark/src/main.rs | 5 +++-- bin/domain/imag-contact/Cargo.toml | 2 ++ bin/domain/imag-contact/src/main.rs | 5 +++-- bin/domain/imag-diary/Cargo.toml | 2 ++ bin/domain/imag-diary/src/main.rs | 6 +++--- bin/domain/imag-habit/Cargo.toml | 2 ++ bin/domain/imag-habit/src/main.rs | 5 +++-- bin/domain/imag-log/Cargo.toml | 2 ++ bin/domain/imag-log/src/main.rs | 5 +++-- bin/domain/imag-mail/Cargo.toml | 2 ++ bin/domain/imag-mail/src/main.rs | 5 +++-- bin/domain/imag-notes/Cargo.toml | 2 ++ bin/domain/imag-notes/src/main.rs | 5 +++-- bin/domain/imag-timetrack/Cargo.toml | 2 ++ bin/domain/imag-timetrack/src/main.rs | 5 +++-- bin/domain/imag-todo/Cargo.toml | 2 ++ bin/domain/imag-todo/src/main.rs | 5 +++-- 43 files changed, 107 insertions(+), 44 deletions(-) diff --git a/bin/core/imag-annotate/Cargo.toml b/bin/core/imag-annotate/Cargo.toml index c8251657..b07ecd60 100644 --- a/bin/core/imag-annotate/Cargo.toml +++ b/bin/core/imag-annotate/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-annotate/src/main.rs b/bin/core/imag-annotate/src/main.rs index 4bdd9443..609deaef 100644 --- a/bin/core/imag-annotate/src/main.rs +++ b/bin/core/imag-annotate/src/main.rs @@ -39,7 +39,7 @@ extern crate log; extern crate libimagentryannotation; extern crate libimagentryedit; extern crate libimagerror; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagutil; @@ -59,8 +59,9 @@ use libimagutil::warn_exit::warn_exit; mod ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-annotation", - env!("CARGO_PKG_VERSION"), + &version, "Add annotations to entries", ui::build_ui); diff --git a/bin/core/imag-diagnostics/Cargo.toml b/bin/core/imag-diagnostics/Cargo.toml index df2bb9fe..bf33f9ee 100644 --- a/bin/core/imag-diagnostics/Cargo.toml +++ b/bin/core/imag-diagnostics/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [dependencies] toml = "0.4" toml-query = "0.6" diff --git a/bin/core/imag-diagnostics/src/main.rs b/bin/core/imag-diagnostics/src/main.rs index 371b1bcf..24426e68 100644 --- a/bin/core/imag-diagnostics/src/main.rs +++ b/bin/core/imag-diagnostics/src/main.rs @@ -36,7 +36,7 @@ extern crate clap; extern crate toml; extern crate toml_query; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagentrylink; extern crate libimagstore; @@ -92,8 +92,9 @@ impl<'a> From> for Diagnostic { } fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-diagnostics", - &env!("CARGO_PKG_VERSION")[..], + &version, "Print diagnostics about imag and the imag store", ui::build_ui); diff --git a/bin/core/imag-edit/Cargo.toml b/bin/core/imag-edit/Cargo.toml index e125a273..b498c42d 100644 --- a/bin/core/imag-edit/Cargo.toml +++ b/bin/core/imag-edit/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-edit/src/main.rs b/bin/core/imag-edit/src/main.rs index bf05e8eb..c69c341a 100644 --- a/bin/core/imag-edit/src/main.rs +++ b/bin/core/imag-edit/src/main.rs @@ -37,7 +37,7 @@ extern crate clap; extern crate libimagentryedit; extern crate libimagerror; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagutil; @@ -52,8 +52,9 @@ use libimagstore::storeid::IntoStoreId; mod ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-edit", - env!("CARGO_PKG_VERSION"), + &version, "Edit store entries with $EDITOR", ui::build_ui); diff --git a/bin/core/imag-gps/Cargo.toml b/bin/core/imag-gps/Cargo.toml index f5347412..119b4c6c 100644 --- a/bin/core/imag-gps/Cargo.toml +++ b/bin/core/imag-gps/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-gps/src/main.rs b/bin/core/imag-gps/src/main.rs index eda98a19..713278ca 100644 --- a/bin/core/imag-gps/src/main.rs +++ b/bin/core/imag-gps/src/main.rs @@ -37,7 +37,7 @@ extern crate clap; extern crate log; extern crate libimagentrygps; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagutil; extern crate libimagerror; extern crate libimagstore; @@ -57,8 +57,9 @@ use libimagstore::storeid::IntoStoreId; mod ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-gps", - env!("CARGO_PKG_VERSION"), + &version, "Add GPS coordinates to entries", ui::build_ui); diff --git a/bin/core/imag-grep/Cargo.toml b/bin/core/imag-grep/Cargo.toml index fadbc8db..7da96fc6 100644 --- a/bin/core/imag-grep/Cargo.toml +++ b/bin/core/imag-grep/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-grep/src/main.rs b/bin/core/imag-grep/src/main.rs index 9da97ae0..9e1354e5 100644 --- a/bin/core/imag-grep/src/main.rs +++ b/bin/core/imag-grep/src/main.rs @@ -36,7 +36,7 @@ extern crate clap; extern crate regex; extern crate libimagstore; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; use regex::Regex; @@ -53,8 +53,9 @@ struct Options { } fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-grep", - env!("CARGO_PKG_VERSION"), + &version, "grep through entries text", ui::build_ui); diff --git a/bin/core/imag-init/Cargo.toml b/bin/core/imag-init/Cargo.toml index da9e24d9..7eaf6f0b 100644 --- a/bin/core/imag-init/Cargo.toml +++ b/bin/core/imag-init/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-link/Cargo.toml b/bin/core/imag-link/Cargo.toml index 60f74568..c05fe184 100644 --- a/bin/core/imag-link/Cargo.toml +++ b/bin/core/imag-link/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs index dd5f055d..1dde3f94 100644 --- a/bin/core/imag-link/src/main.rs +++ b/bin/core/imag-link/src/main.rs @@ -39,7 +39,7 @@ extern crate url; #[cfg(test)] extern crate toml_query; extern crate libimagentrylink; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagerror; @@ -72,8 +72,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-link", - env!("CARGO_PKG_VERSION"), + &version, "Link entries", build_ui); if rt.cli().is_present("check-consistency") { diff --git a/bin/core/imag-mv/Cargo.toml b/bin/core/imag-mv/Cargo.toml index faa0db92..7c38f937 100644 --- a/bin/core/imag-mv/Cargo.toml +++ b/bin/core/imag-mv/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-mv/src/main.rs b/bin/core/imag-mv/src/main.rs index 4de0186e..fbb5021e 100644 --- a/bin/core/imag-mv/src/main.rs +++ b/bin/core/imag-mv/src/main.rs @@ -35,7 +35,7 @@ #[macro_use] extern crate log; extern crate clap; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagerror; extern crate libimagentrylink; @@ -56,8 +56,9 @@ use libimagentrylink::internal::InternalLinker; use libimagstore::iter::get::StoreIdGetIteratorExtension; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-mv", - env!("CARGO_PKG_VERSION"), + &version, "Move things around in the store", build_ui); diff --git a/bin/core/imag-ref/Cargo.toml b/bin/core/imag-ref/Cargo.toml index 29af8fea..b0fb814a 100644 --- a/bin/core/imag-ref/Cargo.toml +++ b/bin/core/imag-ref/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-ref/src/main.rs b/bin/core/imag-ref/src/main.rs index 3235d1ce..3d1339e7 100644 --- a/bin/core/imag-ref/src/main.rs +++ b/bin/core/imag-ref/src/main.rs @@ -35,7 +35,7 @@ #[macro_use] extern crate log; extern crate clap; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagentryref; extern crate libimagerror; extern crate libimagentrylist; @@ -56,8 +56,9 @@ use libimagrt::setup::generate_runtime_setup; use libimagrt::runtime::Runtime; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-ref", - env!("CARGO_PKG_VERSION"), + &version, "Reference files outside of the store", build_ui); rt.cli() diff --git a/bin/core/imag-store/Cargo.toml b/bin/core/imag-store/Cargo.toml index 39d3db4b..db746943 100644 --- a/bin/core/imag-store/Cargo.toml +++ b/bin/core/imag-store/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-store/src/main.rs b/bin/core/imag-store/src/main.rs index bbcb3260..2b16b047 100644 --- a/bin/core/imag-store/src/main.rs +++ b/bin/core/imag-store/src/main.rs @@ -38,7 +38,7 @@ extern crate toml; #[cfg(test)] extern crate toml_query; #[macro_use] extern crate error_chain; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagerror; @@ -76,8 +76,9 @@ use verify::verify; use ids::ids; fn main() { + let version = make_imag_version!(); let mut rt = generate_runtime_setup("imag-store", - env!("CARGO_PKG_VERSION"), + &version, "Direct interface to the store. Use with great care!", build_ui); diff --git a/bin/core/imag-tag/Cargo.toml b/bin/core/imag-tag/Cargo.toml index f5059c71..1da7b182 100644 --- a/bin/core/imag-tag/Cargo.toml +++ b/bin/core/imag-tag/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs index da9c7cf2..009b4c78 100644 --- a/bin/core/imag-tag/src/main.rs +++ b/bin/core/imag-tag/src/main.rs @@ -23,7 +23,7 @@ extern crate clap; #[cfg(test)] extern crate toml; extern crate libimagstore; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagentrytag; extern crate libimagerror; @@ -57,8 +57,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-store", - env!("CARGO_PKG_VERSION"), + &version, "Direct interface to the store. Use with great care!", build_ui); diff --git a/bin/core/imag-view/Cargo.toml b/bin/core/imag-view/Cargo.toml index 6a98a301..6f3452bc 100644 --- a/bin/core/imag-view/Cargo.toml +++ b/bin/core/imag-view/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag-view/src/main.rs b/bin/core/imag-view/src/main.rs index 4f08141c..2303ffaf 100644 --- a/bin/core/imag-view/src/main.rs +++ b/bin/core/imag-view/src/main.rs @@ -41,7 +41,7 @@ extern crate toml_query; extern crate libimagentryview; extern crate libimagerror; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; use std::collections::BTreeMap; @@ -64,8 +64,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup( "imag-view", - env!("CARGO_PKG_VERSION"), + &version, "View entries (readonly)", build_ui); diff --git a/bin/core/imag/Cargo.toml b/bin/core/imag/Cargo.toml index 729d033d..fcdfb968 100644 --- a/bin/core/imag/Cargo.toml +++ b/bin/core/imag/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/core/imag/src/main.rs b/bin/core/imag/src/main.rs index 19f5308b..9addf820 100644 --- a/bin/core/imag/src/main.rs +++ b/bin/core/imag/src/main.rs @@ -23,7 +23,7 @@ extern crate walkdir; extern crate toml; extern crate toml_query; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; use std::env; @@ -120,11 +120,11 @@ fn get_commands() -> Vec { fn main() { // Initialize the Runtime and build the CLI let appname = "imag"; - let version = env!("CARGO_PKG_VERSION"); + let version = make_imag_version!(); let about = "imag - the PIM suite for the commandline"; let commands = get_commands(); let helptext = help_text(commands.clone()); - let mut app = Runtime::get_default_cli_builder(appname, version, about) + let mut app = Runtime::get_default_cli_builder(appname, &version, about) .settings(&[AppSettings::AllowExternalSubcommands, AppSettings::ArgRequiredElseHelp]) .arg(Arg::with_name("version") .long("version") diff --git a/bin/domain/imag-bookmark/Cargo.toml b/bin/domain/imag-bookmark/Cargo.toml index 7a4f97e4..4b4ee6ad 100644 --- a/bin/domain/imag-bookmark/Cargo.toml +++ b/bin/domain/imag-bookmark/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-bookmark/src/main.rs b/bin/domain/imag-bookmark/src/main.rs index 63b0a456..48e94954 100644 --- a/bin/domain/imag-bookmark/src/main.rs +++ b/bin/domain/imag-bookmark/src/main.rs @@ -38,7 +38,7 @@ extern crate toml; extern crate toml_query; extern crate libimagbookmark; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagutil; @@ -59,8 +59,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-bookmark", - env!("CARGO_PKG_VERSION"), + &version, "Bookmark collection tool", build_ui); diff --git a/bin/domain/imag-contact/Cargo.toml b/bin/domain/imag-contact/Cargo.toml index c3cbf9b4..71a4b1c9 100644 --- a/bin/domain/imag-contact/Cargo.toml +++ b/bin/domain/imag-contact/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs index a6c3455d..16271eb3 100644 --- a/bin/domain/imag-contact/src/main.rs +++ b/bin/domain/imag-contact/src/main.rs @@ -43,7 +43,7 @@ extern crate uuid; extern crate libimagcontact; extern crate libimagstore; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagutil; extern crate libimaginteraction; @@ -78,8 +78,9 @@ use util::build_data_object_for_handlebars; use create::create; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-contact", - env!("CARGO_PKG_VERSION"), + &version, "Contact management tool", build_ui); diff --git a/bin/domain/imag-diary/Cargo.toml b/bin/domain/imag-diary/Cargo.toml index 1cbb642d..35f81803 100644 --- a/bin/domain/imag-diary/Cargo.toml +++ b/bin/domain/imag-diary/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-diary/src/main.rs b/bin/domain/imag-diary/src/main.rs index 935630a9..1ed42666 100644 --- a/bin/domain/imag-diary/src/main.rs +++ b/bin/domain/imag-diary/src/main.rs @@ -43,7 +43,7 @@ extern crate libimagentryedit; extern crate libimagentrylist; extern crate libimagerror; extern crate libimaginteraction; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagstore; extern crate libimagtimeui; extern crate libimagutil; @@ -68,10 +68,10 @@ use ui::build_ui; use view::view; fn main() { + let version = make_imag_version!(); let name = "imag-diary"; - let version = env!("CARGO_PKG_VERSION"); let about = "Personal Diary/Diaries"; - let ui = build_ui(Runtime::get_default_cli_builder(name, version, about)); + let ui = build_ui(Runtime::get_default_cli_builder(name, &version, about)); let rt = { let rt = Runtime::new(ui); if rt.is_ok() { diff --git a/bin/domain/imag-habit/Cargo.toml b/bin/domain/imag-habit/Cargo.toml index 3748e47b..56bf6622 100644 --- a/bin/domain/imag-habit/Cargo.toml +++ b/bin/domain/imag-habit/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs index f8fd12e3..a3ef5652 100644 --- a/bin/domain/imag-habit/src/main.rs +++ b/bin/domain/imag-habit/src/main.rs @@ -41,7 +41,7 @@ extern crate chrono; extern crate libimaghabit; extern crate libimagstore; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagutil; extern crate libimagentrylist; @@ -65,8 +65,9 @@ use libimaginteraction::ask::ask_bool; mod ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-habit", - env!("CARGO_PKG_VERSION"), + &version, "Habit tracking tool", ui::build_ui); diff --git a/bin/domain/imag-log/Cargo.toml b/bin/domain/imag-log/Cargo.toml index a606c89e..2eccb2db 100644 --- a/bin/domain/imag-log/Cargo.toml +++ b/bin/domain/imag-log/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-log/src/main.rs b/bin/domain/imag-log/src/main.rs index cf2e4c97..66a34add 100644 --- a/bin/domain/imag-log/src/main.rs +++ b/bin/domain/imag-log/src/main.rs @@ -39,7 +39,7 @@ extern crate toml; extern crate toml_query; extern crate libimaglog; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagdiary; @@ -56,8 +56,9 @@ use ui::build_ui; use toml::Value; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-log", - env!("CARGO_PKG_VERSION"), + &version, "Overlay to imag-diary to 'log' single lines of text", build_ui); diff --git a/bin/domain/imag-mail/Cargo.toml b/bin/domain/imag-mail/Cargo.toml index dabbe145..2bdd9686 100644 --- a/bin/domain/imag-mail/Cargo.toml +++ b/bin/domain/imag-mail/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-mail/src/main.rs b/bin/domain/imag-mail/src/main.rs index 202d424c..8de1b269 100644 --- a/bin/domain/imag-mail/src/main.rs +++ b/bin/domain/imag-mail/src/main.rs @@ -20,7 +20,7 @@ extern crate clap; #[macro_use] extern crate log; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagmail; extern crate libimagerror; extern crate libimagutil; @@ -36,8 +36,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-mail", - env!("CARGO_PKG_VERSION"), + &version, "Mail collection tool", build_ui); diff --git a/bin/domain/imag-notes/Cargo.toml b/bin/domain/imag-notes/Cargo.toml index 23707642..d65f68cc 100644 --- a/bin/domain/imag-notes/Cargo.toml +++ b/bin/domain/imag-notes/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-notes/src/main.rs b/bin/domain/imag-notes/src/main.rs index c2c01a59..40a2c1e7 100644 --- a/bin/domain/imag-notes/src/main.rs +++ b/bin/domain/imag-notes/src/main.rs @@ -22,7 +22,7 @@ extern crate clap; extern crate itertools; extern crate libimagnotes; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagentryedit; extern crate libimagerror; extern crate libimagutil; @@ -49,8 +49,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-notes", - env!("CARGO_PKG_VERSION"), + &version, "Note taking helper", build_ui); diff --git a/bin/domain/imag-timetrack/Cargo.toml b/bin/domain/imag-timetrack/Cargo.toml index 586472f7..71fe0e3d 100644 --- a/bin/domain/imag-timetrack/Cargo.toml +++ b/bin/domain/imag-timetrack/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-timetrack/src/main.rs b/bin/domain/imag-timetrack/src/main.rs index c5054460..ef857d54 100644 --- a/bin/domain/imag-timetrack/src/main.rs +++ b/bin/domain/imag-timetrack/src/main.rs @@ -29,7 +29,7 @@ extern crate kairos; extern crate libimagerror; extern crate libimagstore; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagtimetrack; extern crate libimagutil; @@ -58,8 +58,9 @@ use year::year; use libimagrt::setup::generate_runtime_setup; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-timetrack", - env!("CARGO_PKG_VERSION"), + &version, "Time tracking module", build_ui); diff --git a/bin/domain/imag-todo/Cargo.toml b/bin/domain/imag-todo/Cargo.toml index 1fcb6bbb..053ed558 100644 --- a/bin/domain/imag-todo/Cargo.toml +++ b/bin/domain/imag-todo/Cargo.toml @@ -13,6 +13,8 @@ documentation = "https://matthiasbeyer.github.io/imag/imag_documentation/index.h repository = "https://github.com/matthiasbeyer/imag" homepage = "http://imag-pim.org" +build = "../../../build.rs" + [badges] travis-ci = { repository = "matthiasbeyer/imag" } is-it-maintained-issue-resolution = { repository = "matthiasbeyer/imag" } diff --git a/bin/domain/imag-todo/src/main.rs b/bin/domain/imag-todo/src/main.rs index ab9f1a3b..d485ba2d 100644 --- a/bin/domain/imag-todo/src/main.rs +++ b/bin/domain/imag-todo/src/main.rs @@ -23,7 +23,7 @@ extern crate toml; extern crate toml_query; #[macro_use] extern crate is_match; -extern crate libimagrt; +#[macro_use] extern crate libimagrt; extern crate libimagerror; extern crate libimagtodo; @@ -39,8 +39,9 @@ mod ui; use ui::build_ui; fn main() { + let version = make_imag_version!(); let rt = generate_runtime_setup("imag-todo", - env!("CARGO_PKG_VERSION"), + &version, "Interface with taskwarrior", build_ui); From c43abf09d1e46d0e98feb3c2f2b89a2cf6d66363 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 13 Feb 2018 11:53:31 +0100 Subject: [PATCH 3/4] Use git-describe rather than rev-parse --- build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.rs b/build.rs index ce7cf02d..c2c4ec66 100644 --- a/build.rs +++ b/build.rs @@ -20,9 +20,9 @@ use std::process::Command; fn main() { let profile = String::from(std::env::var("PROFILE").unwrap()); - let git_hash = if profile == "debug" { + let git_version = if profile == "debug" { let output = Command::new("git") - .args(&["rev-parse", "--short=10", "HEAD"]) + .args(&["describe", "HEAD"]) .output() .unwrap(); String::from_utf8(output.stdout).unwrap() @@ -30,5 +30,5 @@ fn main() { String::from("") }; - println!("cargo:rustc-env=CARGO_BUILD_GIT_HASH={}", git_hash); + println!("cargo:rustc-env=CARGO_BUILD_VERSION={}", git_version); } From 3bd8822f4f62b89aa71f2708c965c2be3fe620ef Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 13 Feb 2018 11:53:51 +0100 Subject: [PATCH 4/4] Use version string from git, if present --- lib/core/libimagrt/src/version.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/core/libimagrt/src/version.rs b/lib/core/libimagrt/src/version.rs index 3f6d0ff3..10e034b7 100644 --- a/lib/core/libimagrt/src/version.rs +++ b/lib/core/libimagrt/src/version.rs @@ -21,12 +21,12 @@ macro_rules! make_imag_version { () => {{ let pkg_version = env!("CARGO_PKG_VERSION"); - let git_version = env!("CARGO_BUILD_GIT_HASH"); + let git_version = env!("CARGO_BUILD_VERSION"); if git_version == "" { String::from(pkg_version) } else { - format!("{}-{}", pkg_version, git_version) + String::from(git_version) } }} }