upgrade vergen to 3.0 (#11293)

* version: upgrade vergen to 3.0

* version: use vergen for target triple
This commit is contained in:
Andronik Ordian
2019-12-02 22:18:44 +01:00
committed by Niklas Adolfsson
parent a016dc5c6c
commit 71f4f61146
4 changed files with 26 additions and 28 deletions

View File

@@ -27,7 +27,7 @@ rlp = "0.4.0"
target_info = "0.1"
[build-dependencies]
vergen = "0.1"
vergen = "3.0.4"
rustc_version = "0.2"
toml = "0.4"

View File

@@ -22,12 +22,17 @@ use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use vergen::{vergen, OutputFns};
use vergen::{ConstantsFlags, generate_cargo_keys};
const ERROR_MSG: &'static str = "Failed to generate metadata files";
fn main() {
vergen(OutputFns::all()).expect(ERROR_MSG);
let vergen_flags = ConstantsFlags::COMMIT_DATE |
ConstantsFlags::SHA |
ConstantsFlags::SHA_SHORT |
ConstantsFlags::TARGET_TRIPLE |
ConstantsFlags::REBUILD_ON_HEAD_CHANGE;
generate_cargo_keys(vergen_flags).expect(ERROR_MSG);
let version = rustc_version::version().expect(ERROR_MSG);

View File

@@ -24,11 +24,6 @@ use target_info::Target;
use bytes::Bytes;
use rlp::RlpStream;
mod vergen {
#![allow(unused)]
include!(concat!(env!("OUT_DIR"), "/version.rs"));
}
mod generated {
include!(concat!(env!("OUT_DIR"), "/meta.rs"));
}
@@ -43,18 +38,21 @@ const THIS_TRACK: &'static str = "unstable";
/// Get the platform identifier.
pub fn platform() -> String {
let env = Target::env();
let env_dash = if env.is_empty() { "" } else { "-" };
format!("{}-{}{}{}", Target::arch(), Target::os(), env_dash, env)
format!("{}", env!("VERGEN_TARGET_TRIPLE"))
}
/// Get the standard version string for this software.
pub fn version() -> String {
let sha3 = vergen::short_sha();
let sha3_dash = if sha3.is_empty() { "" } else { "-" };
let commit_date = vergen::commit_date().replace("-", "");
let date_dash = if commit_date.is_empty() { "" } else { "-" };
format!("Parity-Ethereum/v{}-{}{}{}{}{}/{}/rustc{}", env!("CARGO_PKG_VERSION"), THIS_TRACK, sha3_dash, sha3, date_dash, commit_date, platform(), generated::rustc_version())
let commit_date = format!("{}", env!("VERGEN_COMMIT_DATE")).replace("-", "");
format!(
"Parity-Ethereum/v{}-{}-{}-{}/{}/rustc{}",
env!("CARGO_PKG_VERSION"),
THIS_TRACK,
env!("VERGEN_SHA_SHORT"),
commit_date,
platform(),
generated::rustc_version(),
)
}
/// Get the standard version data for this software.
@@ -73,5 +71,5 @@ pub fn version_data() -> Bytes {
/// Provide raw information on the package.
pub fn raw_package_info() -> (&'static str, &'static str, &'static str) {
(THIS_TRACK, env!["CARGO_PKG_VERSION"], vergen::sha())
(THIS_TRACK, env!["CARGO_PKG_VERSION"], env!["VERGEN_SHA"])
}