mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Embed git hash using vergen instead of mach (#30030)
Embed the git hash into the servo binary using vergen instead of using custom Python code in mach. The benefit here is ones less difference between a normal cargo run and building via mach in addition to removing a bunch of code.
This commit is contained in:
parent
17a5b9200d
commit
2ecdb8f45e
8 changed files with 79 additions and 54 deletions
|
@ -31,6 +31,7 @@ libloading = "0.5"
|
|||
[build-dependencies]
|
||||
gl_generator = "0.14"
|
||||
serde_json = { workspace = true }
|
||||
vergen = { version = "8.0.0", features = [ "git", "gitcl" ]}
|
||||
|
||||
[features]
|
||||
debugmozjs = ["libservo/debugmozjs"]
|
||||
|
|
|
@ -7,11 +7,24 @@ use serde_json::{self, Value};
|
|||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::path::PathBuf;
|
||||
use vergen::EmitBuilder;
|
||||
|
||||
fn main() {
|
||||
let target = env::var("TARGET").unwrap();
|
||||
let dest = PathBuf::from(&env::var("OUT_DIR").unwrap());
|
||||
|
||||
if let Err(error) = EmitBuilder::builder()
|
||||
.fail_on_error()
|
||||
.git_sha(true /* short */)
|
||||
.emit()
|
||||
{
|
||||
println!(
|
||||
"cargo:warning=Could not generate git version information: {:?}",
|
||||
error
|
||||
);
|
||||
println!("cargo:rustc-env=VERGEN_GIT_SHA=nogit");
|
||||
}
|
||||
|
||||
// Generate GL bindings
|
||||
// For now, we only support EGL, and only on Windows and Android.
|
||||
if target.contains("android") || target.contains("windows") {
|
||||
|
|
|
@ -185,12 +185,11 @@ pub struct ServoGlue {
|
|||
}
|
||||
|
||||
pub fn servo_version() -> String {
|
||||
let cargo_version = env!("CARGO_PKG_VERSION");
|
||||
let git_info = option_env!("GIT_INFO");
|
||||
match git_info {
|
||||
Some(info) => format!("Servo {}{}", cargo_version, info),
|
||||
None => format!("Servo {}", cargo_version),
|
||||
}
|
||||
format!(
|
||||
"Servo {}-{}",
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("VERGEN_GIT_SHA")
|
||||
)
|
||||
}
|
||||
|
||||
/// Test if a url is valid.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue