diff --git a/util/Cargo.toml b/util/Cargo.toml index 262e14ed3..c0d106c1e 100644 --- a/util/Cargo.toml +++ b/util/Cargo.toml @@ -29,7 +29,6 @@ sha3 = { path = "sha3" } serde = "0.7.0" clippy = { version = "0.0.50", optional = true } json-tests = { path = "json-tests" } -rustc_version = "0.1.0" igd = "0.4.2" ethcore-devtools = { path = "../devtools" } libc = "0.2.7" @@ -44,3 +43,4 @@ dev = ["clippy"] [build-dependencies] vergen = "*" +rustc_version = "0.1.0" diff --git a/util/build.rs b/util/build.rs index b0b64a380..f033e52e0 100644 --- a/util/build.rs +++ b/util/build.rs @@ -15,9 +15,23 @@ // along with Parity. If not, see . extern crate vergen; +extern crate rustc_version; use vergen::*; +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::Path; fn main() { vergen(OutputFns::all()).unwrap(); + let out_dir = env::var("OUT_DIR").unwrap(); + let dest_path = Path::new(&out_dir).join("rustc_version.rs"); + let mut f = File::create(&dest_path).unwrap(); + f.write_all(format!(" + /// Returns compiler version. + pub fn rustc_version() -> &'static str {{ + \"{}\" + }} + ", rustc_version::version()).as_bytes()).unwrap(); } diff --git a/util/src/lib.rs b/util/src/lib.rs index cdc3a3f19..6abf6485d 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -109,9 +109,7 @@ extern crate log as rlog; extern crate igd; extern crate ethcore_devtools as devtools; extern crate libc; -extern crate rustc_version; extern crate target_info; -extern crate vergen; extern crate bigint; extern crate chrono; diff --git a/util/src/misc.rs b/util/src/misc.rs index d76098672..14fcf522a 100644 --- a/util/src/misc.rs +++ b/util/src/misc.rs @@ -20,9 +20,9 @@ use std::fs::File; use common::*; use rlp::{Stream, RlpStream}; use target_info::Target; -use rustc_version; include!(concat!(env!("OUT_DIR"), "/version.rs")); +include!(concat!(env!("OUT_DIR"), "/rustc_version.rs")); #[derive(Debug,Clone,PartialEq,Eq)] /// Diff type for specifying a change (or not). @@ -70,7 +70,13 @@ pub fn contents(name: &str) -> Result { /// Get the standard version string for this software. pub fn version() -> String { - format!("Parity/v{}-beta-{}-{}/{}-{}-{}/rustc{}", env!("CARGO_PKG_VERSION"), short_sha(), commit_date().replace("-", ""), Target::arch(), Target::os(), Target::env(), rustc_version::version()) + let sha3 = short_sha(); + let sha3_dash = if sha3.is_empty() { "" } else { "-" }; + let commit_date = commit_date().replace("-", ""); + let date_dash = if commit_date.is_empty() { "" } else { "-" }; + let env = Target::env(); + let env_dash = if env.is_empty() { "" } else { "-" }; + format!("Parity/v{}-beta{}{}{}{}/{}-{}{}{}/rustc{}", env!("CARGO_PKG_VERSION"), sha3_dash, sha3, date_dash, commit_date, Target::arch(), Target::os(), env_dash, env, rustc_version()) } /// Get the standard version data for this software. @@ -82,7 +88,7 @@ pub fn version_data() -> Bytes { u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap(); s.append(&v); s.append(&"Parity"); - s.append(&format!("{}", rustc_version::version())); + s.append(&format!("{}", rustc_version())); s.append(&&Target::os()[0..2]); s.out() }