Merge pull request #761 from ethcore/ver-fix

Prettier version w/o git dir; Use rustc compile time version
This commit is contained in:
Gav Wood 2016-03-17 19:32:42 +01:00
commit 4da8ede826
4 changed files with 24 additions and 6 deletions

View File

@ -29,7 +29,6 @@ sha3 = { path = "sha3" }
serde = "0.7.0" serde = "0.7.0"
clippy = { version = "0.0.50", optional = true } clippy = { version = "0.0.50", optional = true }
json-tests = { path = "json-tests" } json-tests = { path = "json-tests" }
rustc_version = "0.1.0"
igd = "0.4.2" igd = "0.4.2"
ethcore-devtools = { path = "../devtools" } ethcore-devtools = { path = "../devtools" }
libc = "0.2.7" libc = "0.2.7"
@ -44,3 +43,4 @@ dev = ["clippy"]
[build-dependencies] [build-dependencies]
vergen = "*" vergen = "*"
rustc_version = "0.1.0"

View File

@ -15,9 +15,23 @@
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern crate vergen; extern crate vergen;
extern crate rustc_version;
use vergen::*; use vergen::*;
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
fn main() { fn main() {
vergen(OutputFns::all()).unwrap(); 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 igd;
extern crate ethcore_devtools as devtools; extern crate ethcore_devtools as devtools;
extern crate libc; extern crate libc;
extern crate rustc_version;
extern crate target_info; extern crate target_info;
extern crate vergen;
extern crate bigint; extern crate bigint;
extern crate chrono; extern crate chrono;

View File

@ -20,9 +20,9 @@ use std::fs::File;
use common::*; use common::*;
use rlp::{Stream, RlpStream}; use rlp::{Stream, RlpStream};
use target_info::Target; use target_info::Target;
use rustc_version;
include!(concat!(env!("OUT_DIR"), "/version.rs")); include!(concat!(env!("OUT_DIR"), "/version.rs"));
include!(concat!(env!("OUT_DIR"), "/rustc_version.rs"));
#[derive(Debug,Clone,PartialEq,Eq)] #[derive(Debug,Clone,PartialEq,Eq)]
/// Diff type for specifying a change (or not). /// 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. /// Get the standard version string for this software.
pub fn version() -> String { pub fn version() -> String {
format!("Parity/v{}-unstable-{}-{}/{}-{}-{}/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{}-unstable{}{}{}{}/{}-{}{}{}/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. /// 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(); u32::from_str(env!("CARGO_PKG_VERSION_PATCH")).unwrap();
s.append(&v); s.append(&v);
s.append(&"Parity"); s.append(&"Parity");
s.append(&format!("{}", rustc_version::version())); s.append(&format!("{}", rustc_version()));
s.append(&&Target::os()[0..2]); s.append(&&Target::os()[0..2]);
s.out() s.out()
} }