Skip to content

Commit

Permalink
Support for vergen information when vendoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Feb 28, 2024
1 parent 8cb92d3 commit 162b9e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
14 changes: 9 additions & 5 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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(())
}
6 changes: 1 addition & 5 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 8 additions & 4 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,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:
Expand Down

0 comments on commit 162b9e0

Please sign in to comment.