Generate Git version info at call to make

Prior to this change, the Git version was only getting generated when
the call was made to autoreconf. This was resulting in stale version
info.

This change, by contrast, generates the build info at the call to make.
While this doesn't completely eliminate the stale version issue, it's
easier to work around, by simply running `make clean`, `make`.
reverse-scroll
nirenjan 2022-04-26 23:49:26 -07:00
parent 251ccfde0d
commit 24ce9bc97b
5 changed files with 24 additions and 5 deletions

1
.gitattributes vendored 100644
View File

@ -0,0 +1 @@
/version-info ident

View File

@ -24,12 +24,25 @@ pkgconfig_DATA =
TESTS = TESTS =
EXTRA_DIST = EXTRA_DIST =
CLEANFILES = CLEANFILES =
BUILT_SOURCES =
x52includedir = $(includedir)/libx52 x52includedir = $(includedir)/libx52
x52include_HEADERS = x52include_HEADERS =
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/tap-driver.sh
########################################################################
# Get build version
########################################################################
BUILT_SOURCES += version-info.h
CLEANFILES += version-info.h
version-info.h: ${top_srcdir}/version-info
${top_srcdir}/version-info ${top_srcdir} >$@
########################################################################
# Include automake stubs
########################################################################
include libx52/Makefile.am include libx52/Makefile.am
include libx52util/Makefile.am include libx52util/Makefile.am
include libx52io/Makefile.am include libx52io/Makefile.am
@ -89,7 +102,7 @@ EXTRA_DIST += \
LICENSE \ LICENSE \
README.md \ README.md \
config.rpath \ config.rpath \
configure.version \ version-info \
Version \ Version \
gettext.h \ gettext.h \
usb-ids.h \ usb-ids.h \

View File

@ -15,6 +15,7 @@
#include "libusb.h" #include "libusb.h"
#include "hidapi.h" #include "hidapi.h"
#include "libx52io.h" #include "libx52io.h"
#include "version-info.h"
static void print_sysinfo(void) static void print_sysinfo(void)
{ {
@ -74,6 +75,8 @@ int main(int argc, char **argv)
puts("================"); puts("================");
printf("Package version: %s\n", VERSION); printf("Package version: %s\n", VERSION);
printf("Build version: %s\n", BUILD_VERSION); printf("Build version: %s\n", BUILD_VERSION);
printf("Built on: %s\n", BUILD_DATE);
printf("version-info %s\n", BUILD_VERSION_INFO_IDENT);
puts(""); puts("");
puts("Built against:"); puts("Built against:");

View File

@ -26,8 +26,6 @@ AX_GCC_FUNC_ATTRIBUTE([format])
AX_GCC_FUNC_ATTRIBUTE([noreturn]) AX_GCC_FUNC_ATTRIBUTE([noreturn])
AC_C_TYPEOF AC_C_TYPEOF
AC_DEFINE([BUILD_VERSION], ["m4_esyscmd([./configure.version])"], [Build version])
AC_MSG_NOTICE([Detected host OS is ${host_os}]) AC_MSG_NOTICE([Detected host OS is ${host_os}])
build_linux=no build_linux=no
# Detect target system # Detect target system

View File

@ -1,4 +1,5 @@
#!/bin/sh #!/bin/sh
# Generate the build_info.h header
# Use the Git version if Git is available, otherwise fallback to Version # Use the Git version if Git is available, otherwise fallback to Version
top_srcdir="${1-.}" top_srcdir="${1-.}"
@ -13,7 +14,6 @@ version="${top_srcdir}/Version"
if ! test -n "${GIT_DIR}" if ! test -n "${GIT_DIR}"
then then
GIT_DIR="${top_srcdir}/.git" GIT_DIR="${top_srcdir}/.git"
export GIT_DIR
fi fi
if test -d "${GIT_DIR}" if test -d "${GIT_DIR}"
@ -31,4 +31,8 @@ then
fi fi
fi fi
printf "%s" "${DESCRIBE}" cat <<EOM
#define BUILD_VERSION "${DESCRIBE}"
#define BUILD_DATE "$(date +%Y-%m-%dT%H:%M:%S%z)"
EOM
echo '#define BUILD_VERSION_INFO_IDENT "$Id$"'