build: Use timestamps file based on last commit date instead of host date

This commit is contained in:
mintsuki 2024-04-08 11:43:39 +02:00
parent aaee2e151f
commit a1ca6f15d4
4 changed files with 18 additions and 6 deletions

1
.gitignore vendored
View File

@ -30,6 +30,7 @@
!/common/font.bin
/configure
/configure.ac.save
/timestamps
/build-aux
/aclocal.m4
/*~

View File

@ -335,7 +335,7 @@ distclean: clean
.PHONY: maintainer-clean
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 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 build-aux *'~' autom4te.cache aclocal.m4 *.tar*
.PHONY: common-uefi-x86-64
common-uefi-x86-64:

View File

@ -66,6 +66,20 @@ if ! [ -f version ]; then
rm -f common/lib/stb_image.h.orig
fi
# Create timestamps file
if git log -1 >/dev/null 2>&1; then
cat >timestamps <<EOF
REGEN_DATE="$(git log -1 --pretty=%cd --date='format:%B %Y')"
SOURCE_DATE_EPOCH="$(git log -1 --pretty=%ct)"
SOURCE_DATE_EPOCH_TOUCH="$(git log -1 --pretty=%cI | sed 's/-//g;s/T//g;s/://g;s/[0-9][0-9]+.*//g')"
EOF
fi
if ! test -f timestamps; then
echo "error: Not a Git repository and 'timestamps' file missing."
exit 1
fi
for auxfile in $AUXFILES; do
rm -f build-aux/$auxfile
done

View File

@ -10,13 +10,10 @@ BUILDDIR="$(pwd -P)"
AC_SUBST([SRCDIR])
AC_SUBST([BUILDDIR])
REGEN_DATE="m4_esyscmd([date '+%B %Y' | tr -d '\n'])"
. "$SRCDIR"/timestamps
AC_SUBST([REGEN_DATE])
SOURCE_DATE_EPOCH="m4_esyscmd([if git log -1 >/dev/null 2>&1; then git log -1 --pretty=%ct | tr -d '\n'; else printf 1546300800; fi])"
AC_SUBST([SOURCE_DATE_EPOCH])
SOURCE_DATE_EPOCH_TOUCH="m4_esyscmd([if git log -1 >/dev/null 2>&1; then git log -1 --pretty=%cI | sed 's/-//g;s/T//g;s/://g;s/[0-9][0-9]+.*//g' | tr -d '\n'; else printf 201901010000; fi])"
AC_SUBST([SOURCE_DATE_EPOCH_TOUCH])
AC_CANONICAL_HOST