From 24ce9bc97bf0a6d73f810247d648f56599de0ea2 Mon Sep 17 00:00:00 2001 From: nirenjan Date: Tue, 26 Apr 2022 23:49:26 -0700 Subject: [PATCH] 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`. --- .gitattributes | 1 + Makefile.am | 15 ++++++++++++++- bugreport/bugreport.c | 3 +++ configure.ac | 2 -- configure.version => version-info | 8 ++++++-- 5 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 .gitattributes rename configure.version => version-info (76%) diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..5675f86 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +/version-info ident diff --git a/Makefile.am b/Makefile.am index c4fdd2b..22c31f5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,12 +24,25 @@ pkgconfig_DATA = TESTS = EXTRA_DIST = CLEANFILES = +BUILT_SOURCES = x52includedir = $(includedir)/libx52 x52include_HEADERS = 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 libx52util/Makefile.am include libx52io/Makefile.am @@ -89,7 +102,7 @@ EXTRA_DIST += \ LICENSE \ README.md \ config.rpath \ - configure.version \ + version-info \ Version \ gettext.h \ usb-ids.h \ diff --git a/bugreport/bugreport.c b/bugreport/bugreport.c index d160688..ccca5e3 100644 --- a/bugreport/bugreport.c +++ b/bugreport/bugreport.c @@ -15,6 +15,7 @@ #include "libusb.h" #include "hidapi.h" #include "libx52io.h" +#include "version-info.h" static void print_sysinfo(void) { @@ -74,6 +75,8 @@ int main(int argc, char **argv) puts("================"); printf("Package version: %s\n", 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("Built against:"); diff --git a/configure.ac b/configure.ac index e24c1c3..b5a02dd 100644 --- a/configure.ac +++ b/configure.ac @@ -26,8 +26,6 @@ AX_GCC_FUNC_ATTRIBUTE([format]) AX_GCC_FUNC_ATTRIBUTE([noreturn]) AC_C_TYPEOF -AC_DEFINE([BUILD_VERSION], ["m4_esyscmd([./configure.version])"], [Build version]) - AC_MSG_NOTICE([Detected host OS is ${host_os}]) build_linux=no # Detect target system diff --git a/configure.version b/version-info similarity index 76% rename from configure.version rename to version-info index ff6c3e7..9ff6929 100755 --- a/configure.version +++ b/version-info @@ -1,4 +1,5 @@ #!/bin/sh +# Generate the build_info.h header # Use the Git version if Git is available, otherwise fallback to Version top_srcdir="${1-.}" @@ -13,7 +14,6 @@ version="${top_srcdir}/Version" if ! test -n "${GIT_DIR}" then GIT_DIR="${top_srcdir}/.git" - export GIT_DIR fi if test -d "${GIT_DIR}" @@ -31,4 +31,8 @@ then fi fi -printf "%s" "${DESCRIBE}" +cat <