mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 08:15:40 +02:00
meson: fix version generation from git
run_command() was only run at configure time, meaning the generated version (that was passed on to the sources via -DYAMBAR_VERSION) became stale. Fix by implementing a shell script that generates a header file, and wrap this in a custom target that is run every time (but the generated file is only updated when the version changes)
This commit is contained in:
parent
e9d5c620a4
commit
c4f9168191
4 changed files with 44 additions and 24 deletions
32
generate-version.sh
Executable file
32
generate-version.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
default_version=${1}
|
||||
src_dir=${2}
|
||||
out_file=${3}
|
||||
|
||||
# echo "default version: ${default_version}"
|
||||
# echo "source directory: ${src_dir}"
|
||||
# echo "output file: ${out_file}"
|
||||
|
||||
if [[ $(command -v git) ]]; then
|
||||
new_version="$(git describe --always --tags) ($(env LC_TIME=C date "+%b %d %Y"), branch '$(git rev-parse --abbrev-ref HEAD)')"
|
||||
else
|
||||
new_version="${default_version}"
|
||||
fi
|
||||
|
||||
new_version="#define YAMBAR_VERSION \"${new_version}\""
|
||||
|
||||
if [[ -f "${out_file}" ]]; then
|
||||
old_version=$(<"${out_file}")
|
||||
else
|
||||
old_version=""
|
||||
fi
|
||||
|
||||
# echo "old version: ${old_version}"
|
||||
# echo "new version: ${new_version}"
|
||||
|
||||
if [[ "${old_version}" != "${new_version}" ]]; then
|
||||
echo "${new_version}" > "${out_file}"
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue