summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2017-12-07 14:20:59 -0800
committerJason Gerecke <killertofu@gmail.com>2017-12-15 11:02:53 -0800
commit7d6bded43bab93f8cc882c4e8b0fdc834e44208e (patch)
tree66572b51300177ae84e78120d9e69aab6b187958
parent061519df07f23f96b5211ba71a851bb626881fb4 (diff)
downloadxf86-input-wacom-7d6bded43bab93f8cc882c4e8b0fdc834e44208e.tar.gz
Use git-version-gen for build-time version strings
Currently the driver uses macros like PACKAGE_VERSION whenever it needs to print out a version string. These macros are only updated whenever the autoconf.sh script is run, however. As a practical result, this means that the version information which is built into development versions of the driver is often inaccurate. To fix this, we define a new BUILD_VERSION macro which is updated whenever git reports a changed version number. In addition to having `xsetwacom -V` report the precise build, we also have the X log print out the build number to augment the MAJOR/MINOR/PATCH data that is normally printed. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
-rw-r--r--Makefile.am16
-rw-r--r--configure.ac1
-rwxr-xr-xgit-version-gen56
-rw-r--r--src/wcmConfig.c1
-rw-r--r--tools/xsetwacom.c3
5 files changed, 73 insertions, 4 deletions
diff --git a/Makefile.am b/Makefile.am
index 2293d88..3843af0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,13 +24,16 @@ DISTCHECK_CONFIGURE_FLAGS = --with-sdkdir='$${includedir}/xorg' \
SUBDIRS = conf doc src man include tools test
MAINTAINERCLEANFILES = ChangeLog INSTALL
+BUILT_SOURCES = config-ver.h
+CLEANFILES = config-ver.h
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = xorg-wacom.pc
-EXTRA_DIST = GPL
+EXTRA_DIST = GPL \
+ version
-.PHONY: ChangeLog INSTALL
+.PHONY: ChangeLog INSTALL FORCE
INSTALL:
$(INSTALL_CMD)
@@ -39,3 +42,12 @@ ChangeLog:
$(CHANGELOG_CMD)
dist-hook: ChangeLog INSTALL
+
+config-ver.h: version
+ if ! grep -qs "^#define BUILD_VERSION \"$$(cat version)\"$$" "$@"; then \
+ sed -i '/^#define BUILD_VERSION /d' "$@" 2>/dev/null; \
+ echo "#define BUILD_VERSION \"$$(cat version | tr -d '\n')\"" >> "$@"; \
+ fi
+
+version: FORCE
+ if test -x $(srcdir)/git-version-gen; then $(srcdir)/git-version-gen -u; fi
diff --git a/configure.ac b/configure.ac
index 906b9d7..b17cbe0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -29,6 +29,7 @@ AC_INIT([xf86-input-wacom],
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
+AH_BOTTOM([#include "config-ver.h"])
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip])
diff --git a/git-version-gen b/git-version-gen
new file mode 100755
index 0000000..65e599c
--- /dev/null
+++ b/git-version-gen
@@ -0,0 +1,56 @@
+#!/bin/sh
+
+DIRECTORY=$(basename "$(dirname "$(readlink -mn "$0")")")
+VERFILE="version"
+DEF_VER="$DIRECTORY"
+TAG_PREFIX="xf86-input-wacom-"
+LF='
+'
+UPDATE=0
+FORCE=0
+
+
+for ARG in "$@"; do
+ if test "${ARG}" = "-u"; then UPDATE=1;
+ elif test "${ARG}" = "-f"; then UPDATE=1; FORCE=1;
+ fi
+done
+
+# First see if we're in a git directory and try git-describe, then
+# try the $VERFILE file if present (included in release tarballs),
+# and finally the default.
+if test -d "${GIT_DIR:-.git}" -o -f .git &&
+ VN=$(git describe --match "${TAG_PREFIX}*" --abbrev=7 HEAD 2>/dev/null) &&
+ case "${VN}" in
+ *${LF}*) (exit 1) ;;
+ ${TAG_PREFIX}*)
+ git update-index -q --refresh
+ test -z "$(git diff-index --name-only HEAD --)" ||
+ VN="${VN}-dirty" ;;
+ esac
+then
+ VN=$(echo "${VN}" | sed -e "s/${TAG_PREFIX}//");
+ VN=$(echo "${VN}" | sed -e 's/-/./g');
+elif test -f "${VERFILE}"
+then
+ VN=$(cat ${VERFILE}) || VN="$DEF_VER"
+else
+ VN="${DEF_VER}"
+fi
+
+VN=$(expr "${VN}" : v*'\(.*\)')
+
+echo ${VN}
+
+if test "${UPDATE}" -ne 0; then
+ SAVED_VERSION=""
+ if test -f "${VERFILE}"; then
+ SAVED_VERSION=$(cat "${VERFILE}")
+ fi
+ if test "${SAVED_VERSION}" != "${VN}"; then
+ FORCE=1
+ fi
+ if test "${FORCE}" -ne 0; then
+ echo "${VN}" > "${VERFILE}"
+ fi
+fi
diff --git a/src/wcmConfig.c b/src/wcmConfig.c
index 6b269bb..2402952 100644
--- a/src/wcmConfig.c
+++ b/src/wcmConfig.c
@@ -738,6 +738,7 @@ static pointer wcmPlug(pointer module, pointer options, int* errmaj,
{
xf86AddInputDriver(&WACOM, module, 0);
+ xf86Msg(X_INFO, "Build version: " BUILD_VERSION "\n");
usbListModels();
return module;
diff --git a/tools/xsetwacom.c b/tools/xsetwacom.c
index 44e8a14..c098b5f 100644
--- a/tools/xsetwacom.c
+++ b/tools/xsetwacom.c
@@ -753,8 +753,7 @@ static void usage(void)
static void version(void)
{
- printf("%d.%d.%d\n", PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR,
- PACKAGE_VERSION_PATCHLEVEL);
+ printf(BUILD_VERSION "\n");
}
static XDevice* find_device(Display *display, char *name)