build: Make version gathering similar to timestamps gathering

This commit is contained in:
mintsuki 2024-04-10 15:01:57 +02:00
parent df0d9d48d2
commit 9f98cf150a
5 changed files with 18 additions and 32 deletions

1
.gitignore vendored
View File

@ -31,6 +31,7 @@
/configure /configure
/configure.ac.save /configure.ac.save
/timestamps /timestamps
/version
/build-aux /build-aux
/aclocal.m4 /aclocal.m4
/*~ /*~

View File

@ -335,7 +335,7 @@ distclean: clean
.PHONY: maintainer-clean .PHONY: maintainer-clean
maintainer-clean: distclean maintainer-clean: distclean
cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/lib/stb_image.h decompressor/tinf tinf stb freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure timestamps build-aux *'~' autom4te.cache aclocal.m4 *.tar* cd '$(call SHESCAPE,$(SRCDIR))' && rm -rf common/flanterm common/lib/stb_image.h decompressor/tinf tinf stb freestanding-headers common/cc-runtime decompressor/cc-runtime limine-efi configure timestamps version build-aux *'~' autom4te.cache aclocal.m4 *.tar*
.PHONY: common-uefi-x86-64 .PHONY: common-uefi-x86-64
common-uefi-x86-64: common-uefi-x86-64:

View File

@ -2,6 +2,9 @@
set -ex set -ex
LC_ALL=C
export LC_ALL
srcdir="$(dirname "$0")" srcdir="$(dirname "$0")"
test -z "$srcdir" && srcdir=. test -z "$srcdir" && srcdir=.
@ -66,7 +69,7 @@ if ! [ -f version ]; then
rm -f common/lib/stb_image.h.orig rm -f common/lib/stb_image.h.orig
fi fi
# Create timestamps file # Create timestamps and version file
if git log -1 >/dev/null 2>&1; then if git log -1 >/dev/null 2>&1; then
cat >timestamps <<EOF cat >timestamps <<EOF
REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')" REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
@ -80,6 +83,17 @@ if ! test -f timestamps; then
exit 1 exit 1
fi fi
if git describe --exact-match --tags $(git log -n1 --pretty='%h') >/dev/null 2>&1; then
git describe --exact-match --tags $(git log -n1 --pretty='%h') | sed 's/^v//g' >version
elif git log -n1 --pretty='%h' >/dev/null 2>&1; then
echo g$(git log -n1 --pretty='%h') >version
fi
if ! test -f version; then
echo "error: Not a Git repository and 'version' file missing."
exit 1
fi
for auxfile in $AUXFILES; do for auxfile in $AUXFILES; do
rm -f build-aux/$auxfile rm -f build-aux/$auxfile
done done

View File

@ -1,4 +1,4 @@
AC_INIT([Limine], [m4_esyscmd([./version.sh])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/]) AC_INIT([Limine], [m4_esyscmd([cat version | tr -d \\n])], [https://github.com/limine-bootloader/limine/issues], [limine], [https://limine-bootloader.org/])
AC_PREREQ([2.69]) AC_PREREQ([2.69])

View File

@ -1,29 +0,0 @@
#! /bin/sh
LC_ALL=C
export LC_ALL
srcdir="$(dirname "$0")"
test -z "$srcdir" && srcdir=.
cd "$srcdir"
if [ -f version ]; then
printf '%s' "$(cat version)"
exit 0
fi
if ! [ -d .git ] || ! git log -n1 --pretty='%h' >/dev/null 2>&1; then
printf 'UNVERSIONED'
exit 0
fi
tmpfile="$(mktemp)"
if ! git describe --exact-match --tags $(git log -n1 --pretty='%h') >"$tmpfile" 2>/dev/null; then
echo g$(git log -n1 --pretty='%h') >"$tmpfile"
fi
printf '%s' "$(sed 's/^v//g' <"$tmpfile")"
rm -f "$tmpfile"