mirror of
https://github.com/denoland/deno.git
synced 2025-01-08 15:19:40 -05:00
add commit hash and target to long_version output (#8133)
This commit is contained in:
parent
e3b096f6f6
commit
0e5c8c03ac
3 changed files with 30 additions and 5 deletions
29
cli/build.rs
29
cli/build.rs
|
@ -104,6 +104,28 @@ fn ts_version() -> String {
|
||||||
.collect::<String>()
|
.collect::<String>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn git_commit_hash() -> String {
|
||||||
|
if let Ok(output) = std::process::Command::new("git")
|
||||||
|
.arg("rev-list")
|
||||||
|
.arg("-1")
|
||||||
|
.arg("HEAD")
|
||||||
|
.output()
|
||||||
|
{
|
||||||
|
if output.status.success() {
|
||||||
|
std::str::from_utf8(&output.stdout[..7])
|
||||||
|
.unwrap()
|
||||||
|
.to_string()
|
||||||
|
} else {
|
||||||
|
// When not in git repository
|
||||||
|
// (e.g. when the user install by `cargo install deno`)
|
||||||
|
"UNKNOWN".to_string()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// When there is no git command for some reason
|
||||||
|
"UNKNOWN".to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Don't build V8 if "cargo doc" is being run. This is to support docs.rs.
|
// Don't build V8 if "cargo doc" is being run. This is to support docs.rs.
|
||||||
if env::var_os("RUSTDOCFLAGS").is_some() {
|
if env::var_os("RUSTDOCFLAGS").is_some() {
|
||||||
|
@ -114,6 +136,7 @@ fn main() {
|
||||||
// op_fetch_asset::trace_serializer();
|
// op_fetch_asset::trace_serializer();
|
||||||
|
|
||||||
println!("cargo:rustc-env=TS_VERSION={}", ts_version());
|
println!("cargo:rustc-env=TS_VERSION={}", ts_version());
|
||||||
|
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash());
|
||||||
println!(
|
println!(
|
||||||
"cargo:rustc-env=DENO_WEB_LIB_PATH={}",
|
"cargo:rustc-env=DENO_WEB_LIB_PATH={}",
|
||||||
deno_web::get_declaration().display()
|
deno_web::get_declaration().display()
|
||||||
|
@ -123,10 +146,8 @@ fn main() {
|
||||||
deno_fetch::get_declaration().display()
|
deno_fetch::get_declaration().display()
|
||||||
);
|
);
|
||||||
|
|
||||||
println!(
|
println!("cargo:rustc-env=TARGET={}", env::var("TARGET").unwrap());
|
||||||
"cargo:rustc-env=TARGET={}",
|
println!("cargo:rustc-env=PROFILE={}", env::var("PROFILE").unwrap());
|
||||||
std::env::var("TARGET").unwrap()
|
|
||||||
);
|
|
||||||
|
|
||||||
let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
let c = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").unwrap());
|
||||||
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
let o = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||||
|
|
|
@ -221,8 +221,11 @@ To evaluate code in the shell:
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LONG_VERSION: String = format!(
|
static ref LONG_VERSION: String = format!(
|
||||||
"{}\nv8 {}\ntypescript {}",
|
"{} ({}, {}, {})\nv8 {}\ntypescript {}",
|
||||||
crate::version::DENO,
|
crate::version::DENO,
|
||||||
|
crate::version::GIT_COMMIT_HASH,
|
||||||
|
env!("PROFILE"),
|
||||||
|
env!("TARGET"),
|
||||||
crate::version::v8(),
|
crate::version::v8(),
|
||||||
crate::version::TYPESCRIPT
|
crate::version::TYPESCRIPT
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
||||||
|
|
||||||
pub const DENO: &str = env!("CARGO_PKG_VERSION");
|
pub const DENO: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
pub const GIT_COMMIT_HASH: &str = env!("GIT_COMMIT_HASH");
|
||||||
pub const TYPESCRIPT: &str = crate::js::TS_VERSION;
|
pub const TYPESCRIPT: &str = crate::js::TS_VERSION;
|
||||||
|
|
||||||
pub fn v8() -> &'static str {
|
pub fn v8() -> &'static str {
|
||||||
|
|
Loading…
Reference in a new issue