Enable cargo env vars when there is no .git
But still disable git env vars. This change requires vergen 5.1.4 or later.
This commit is contained in:
parent
55e398c10a
commit
62f053de9e
|
|
@ -1397,9 +1397,9 @@ checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "git2"
|
name = "git2"
|
||||||
version = "0.13.17"
|
version = "0.13.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1d250f5f82326884bd39c2853577e70a121775db76818ffa452ed1e80de12986"
|
checksum = "b483c6c2145421099df1b4efd50e0f6205479a072199460eff852fa15e5603c7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
@ -1873,9 +1873,9 @@ checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libgit2-sys"
|
name = "libgit2-sys"
|
||||||
version = "0.12.18+1.1.0"
|
version = "0.12.19+1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3da6a42da88fc37ee1ecda212ffa254c25713532980005d5f7c0b0fbe7e6e885"
|
checksum = "f322155d574c8b9ebe991a04f6908bb49e68a79463338d24a43d6274cb6443e6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
|
|
@ -4052,9 +4052,9 @@ checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "vergen"
|
name = "vergen"
|
||||||
version = "5.1.2"
|
version = "5.1.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0277ffac28b64e449a7a8c369ddd8591647c5a2d1fd513eebd6a153ff4c40ea4"
|
checksum = "575b693376dacf6a9825ab3e61a033cf0e94040e620fca8447b055ef8ce82d2b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ sentry = { version = "0.21.0", default-features = false, features = ["backtrace"
|
||||||
sentry-tracing = { git = "https://github.com/kellpossible/sentry-tracing.git", rev = "f1a4a4a16b5ff1022ae60be779eb3fb928ce9b0f" }
|
sentry-tracing = { git = "https://github.com/kellpossible/sentry-tracing.git", rev = "f1a4a4a16b5ff1022ae60be779eb3fb928ce9b0f" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
vergen = { version = "5.1.2", default-features = false, features = ["cargo", "git"] }
|
vergen = { version = "5.1.4", default-features = false, features = ["cargo", "git"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
abscissa_core = { version = "0.5", features = ["testing"] }
|
abscissa_core = { version = "0.5", features = ["testing"] }
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,47 @@
|
||||||
use vergen::{vergen, Config, ShaKind};
|
use vergen::{vergen, Config, SemverKind, ShaKind};
|
||||||
|
|
||||||
|
/// Disable vergen env vars that could cause spurious reproducible build
|
||||||
|
/// failures
|
||||||
|
fn disable_non_reproducible(_config: &mut Config) {
|
||||||
|
/*
|
||||||
|
Currently, these features are disabled in `Cargo.toml`
|
||||||
|
|
||||||
|
// We don't use build or host-specific env vars, because they can break
|
||||||
|
// reproducible builds.
|
||||||
|
*config.build_mut().enabled_mut() = false;
|
||||||
|
*config.rustc mut().host_triple_mut() = false;
|
||||||
|
|
||||||
|
// It's ok for reproducible builds to depend on the build OS. But most other
|
||||||
|
// sysinfo should not change reproducible builds, so we disable it.
|
||||||
|
*config.sysinfo mut().user_mut() = false;
|
||||||
|
*config.sysinfo mut().memory_mut() = false;
|
||||||
|
*config.sysinfo mut().cpu_vendor_mut() = false;
|
||||||
|
*config.sysinfo mut().cpu_core_count_mut() = false;
|
||||||
|
*config.sysinfo mut().cpu_name_mut() = false;
|
||||||
|
*config.sysinfo mut().cpu_brand_mut() = false;
|
||||||
|
*config.sysinfo mut().cpu_frequency_mut() = false;
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut config = Config::default();
|
let mut config = Config::default();
|
||||||
|
disable_non_reproducible(&mut config);
|
||||||
*config.cargo_mut().features_mut() = false;
|
|
||||||
*config.cargo_mut().profile_mut() = false;
|
|
||||||
|
|
||||||
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
*config.git_mut().sha_kind_mut() = ShaKind::Short;
|
||||||
|
|
||||||
|
// Disable env vars we aren't using right now
|
||||||
|
*config.cargo_mut().features_mut() = false;
|
||||||
|
|
||||||
|
// Disable git if we're building with an invalid `zebra/.git`
|
||||||
match vergen(config) {
|
match vergen(config) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(e) => eprintln!(
|
Err(e) => {
|
||||||
"skipping detailed git and target info due to vergen error: {:?}",
|
eprintln!(
|
||||||
e
|
"git error in vergen build script: skipping git env vars: {:?}",
|
||||||
),
|
e
|
||||||
|
);
|
||||||
|
*config.git_mut().enabled_mut() = false;
|
||||||
|
vergen(config).expect("non-git vergen should succeed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,6 +220,8 @@ impl Application for ZebradApp {
|
||||||
// cargo or git tag + short commit
|
// cargo or git tag + short commit
|
||||||
("version", Some(app_version().to_string())),
|
("version", Some(app_version().to_string())),
|
||||||
// git
|
// git
|
||||||
|
// git env vars can be skipped if there is no `.git` during the
|
||||||
|
// build, so they must all be optional
|
||||||
("branch", option_env!("VERGEN_GIT_BRANCH").map(Into::into)),
|
("branch", option_env!("VERGEN_GIT_BRANCH").map(Into::into)),
|
||||||
("git commit", Self::git_commit().map(Into::into)),
|
("git commit", Self::git_commit().map(Into::into)),
|
||||||
(
|
(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue