Add comprehensive git environment variables for build scripts

This commit is contained in:
2025-08-15 23:27:26 +02:00
parent caebd0eeda
commit 809c4efece

View File

@@ -57,7 +57,12 @@ build_rust_component() {
. ~/.cargo/env . ~/.cargo/env
# Set git version for components that use git_version macro # Set git version for components that use git_version macro
export GIT_DESCRIBE=$(cd "$COMPONENTS_DIR/$component_name" && git describe --tags --always --dirty=-modified 2>/dev/null || echo "unknown") # Many git_version crates check these environment variables first
export VERGEN_GIT_DESCRIBE=$(cd "$COMPONENTS_DIR/$component_name" && git describe --tags --always --dirty=-modified 2>/dev/null || echo "unknown")
export GIT_VERSION=$(cd "$COMPONENTS_DIR/$component_name" && git describe --tags --always --dirty=-modified 2>/dev/null || echo "unknown")
export VERGEN_GIT_BRANCH=$(cd "$COMPONENTS_DIR/$component_name" && git branch --show-current 2>/dev/null || echo "main")
export VERGEN_GIT_COMMIT_TIMESTAMP=$(cd "$COMPONENTS_DIR/$component_name" && git log -1 --format=%ct 2>/dev/null || echo "0")
export VERGEN_GIT_SHA=$(cd "$COMPONENTS_DIR/$component_name" && git rev-parse HEAD 2>/dev/null || echo "unknown")
# Build with musl target for static linking # Build with musl target for static linking
cargo build --release --target x86_64-unknown-linux-musl cargo build --release --target x86_64-unknown-linux-musl