Prettier version wo git dir; Use rustc compile time version

This commit is contained in:
arkpar 2016-03-17 18:41:55 +01:00
parent 570d2c21d3
commit 3bf0a00ba4
4 changed files with 24 additions and 6 deletions

View File

@ -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"

View File

@ -15,9 +15,23 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
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();
}

View File

@ -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;

View File

@ -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<Bytes, UtilError> {
/// 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()
}