From fa86c7f1c412778bc66b9844e8192f84a68ad850 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 28 Feb 2024 10:30:55 -0700 Subject: [PATCH] Support for vergen information when vendoring --- build.rs | 14 +++++++++----- debian/rules | 6 +----- justfile | 12 ++++++++---- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/build.rs b/build.rs index 3628d6ab..ccaa98fd 100644 --- a/build.rs +++ b/build.rs @@ -2,10 +2,14 @@ fn main() -> Result<(), Box> { // Rebuild if i18n files change println!("cargo:rerun-if-changed=i18n"); - vergen::EmitBuilder::builder() - .fail_on_error() - .git_commit_date() - .git_sha(true) - .emit()?; + // Emit version information (if not cached by just vendor) + let mut vergen = vergen::EmitBuilder::builder(); + if std::env::var_os("VERGEN_GIT_COMMIT_DATE").is_none() { + vergen.git_commit_date(); + } + if std::env::var_os("VERGEN_GIT_SHA").is_none() { + vergen.git_sha(true); + } + vergen.fail_on_error().emit()?; Ok(()) } diff --git a/debian/rules b/debian/rules index cd437fa6..b49099ec 100755 --- a/debian/rules +++ b/debian/rules @@ -8,11 +8,7 @@ export VENDOR ?= 1 override_dh_auto_clean: if ! ischroot && test "${VENDOR}" = "1"; then \ - mkdir -p .cargo; \ - cargo vendor | head -n -1 > .cargo/config; \ - echo 'directory = "vendor"' >> .cargo/config; \ - tar pcf vendor.tar vendor; \ - rm -rf vendor; \ + just vendor; \ fi override_dh_auto_build: diff --git a/justfile b/justfile index d802b6ce..83b7fa56 100644 --- a/justfile +++ b/justfile @@ -76,10 +76,14 @@ uninstall: vendor: mkdir -p .cargo cargo vendor --sync Cargo.toml \ - | head -n -1 > .cargo/config - echo 'directory = "vendor"' >> .cargo/config - tar pcf vendor.tar vendor - rm -rf vendor + | head -n -1 > .cargo/config.toml + echo 'directory = "vendor"' >> .cargo/config.toml + echo >> .cargo/config.toml + echo '[env]' >> .cargo/config.toml + echo "VERGEN_GIT_COMMIT_DATE = \"$(git log -1 --pretty=format:'%cs' HEAD)\"" >> .cargo/config.toml + echo "VERGEN_GIT_SHA = \"$(git rev-parse --short HEAD)\"" >> .cargo/config.toml + tar pcf vendor.tar .cargo vendor + rm -rf .cargo vendor # Extracts vendored dependencies vendor-extract: