mirror of
https://github.com/systemd/systemd.git
synced 2024-10-31 16:21:26 +03:00
064b8e2c99
vcs_tag() is slow. When the version-tag meson option is set, we can use configure_file() directly to speed up incremental builds. Before (with version-tag set to v247): ``` ‣ Running build script... [1/418] Generating version.h with a custom command real 0m0.521s user 0m0.229s sys 0m0.067s ``` After (with version-tag set to v247): ``` ‣ Running build script... ninja: no work to do. real 0m0.094s user 0m0.048s sys 0m0.022s ```
17 lines
560 B
Bash
Executable File
17 lines
560 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -eu
|
|
set -o pipefail
|
|
|
|
dir="$1"
|
|
fallback="$2"
|
|
|
|
# Apparently git describe has a bug where it always considers the work-tree
|
|
# dirty when invoked with --git-dir (even though 'git status' is happy). Work
|
|
# around this issue by cd-ing to the source directory.
|
|
cd "$dir"
|
|
# Check that we have either .git/ (a normal clone) or a .git file (a work-tree)
|
|
# and that we don't get confused if a tarball is extracted in a higher-level
|
|
# git repository.
|
|
[ -e .git ] && git describe --abbrev=7 --dirty=+ 2>/dev/null | sed 's/^v//' || echo "$fallback"
|