Skip to content

Commit

Permalink
Switch to git-testament rather than old build.rs
Browse files Browse the repository at this point in the history
Rather than the previous not-very-informative version string
which was generated by build.rs and then not updated unless
build.rs was touched, use the new `git-testament` crate which
does a more complete job at compile time via a proc-macro.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
  • Loading branch information
kinnison committed Mar 14, 2019
1 parent bc74eb4 commit 103bdfd
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 60 deletions.
74 changes: 74 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ keywords = ["rustup", "multirust", "install", "proxy"]

license = "MIT OR Apache-2.0"

build = "build.rs"

[features]

default = ["curl-backend", "reqwest-backend"]
Expand Down Expand Up @@ -51,6 +49,8 @@ toml = "0.4"
url = "1.1.0"
wait-timeout = "0.1.5"
openssl = { version = '0.10.15', optional = true }
git-testament = { git = "https://github.com/kinnison/git-testament" }
lazy_static = "1.0.0"

[target."cfg(windows)".dependencies]
winapi = { version = "0.3", features = ["jobapi", "jobapi2", "processthreadsapi", "psapi", "synchapi", "winuser"] }
Expand Down
54 changes: 0 additions & 54 deletions build.rs

This file was deleted.

21 changes: 17 additions & 4 deletions src/rustup-cli/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use crate::errors::*;
use crate::self_update;
use crate::term2;
use git_testament::git_testament;
use lazy_static::lazy_static;
use rustup::{Cfg, Notification, Toolchain, UpdateStatus};
use rustup_utils::notify::NotificationLevel;
use rustup_utils::utils;
Expand Down Expand Up @@ -402,11 +404,22 @@ pub fn list_overrides(cfg: &Cfg) -> Result<()> {
Ok(())
}

git_testament!(TESTAMENT);

lazy_static! {
static ref VERSION_STRING: String = {
let testament_string = format!("{}", TESTAMENT);
let pkg_version = env!("CARGO_PKG_VERSION");
if &testament_string[..pkg_version.len()] == pkg_version {
testament_string
} else {
format!("{} really {}", pkg_version, testament_string)
}
};
}

pub fn version() -> &'static str {
concat!(
env!("CARGO_PKG_VERSION"),
include_str!(concat!(env!("OUT_DIR"), "/commit-info.txt"))
)
VERSION_STRING.as_ref()
}

pub fn report_error(e: &Error) {
Expand Down

0 comments on commit 103bdfd

Please sign in to comment.