Improve gitrev handling.

This commit is contained in:
Markus F.X.J. Oberhumer 2016-09-26 10:35:29 +02:00
parent bd54499537
commit aee52d3880
4 changed files with 12 additions and 3 deletions

View File

@ -37,7 +37,10 @@ if test "$TRAVIS_OS_NAME" = "linux"; then
cp "$TRAVIS_BUILD_DIR/deps/upx-testsuite/files/packed/amd64-linux.elf/upx-3.91" upx391.out
upx_391="$PWD/upx391.out"
fi
$upx --version
$upx --help
cd /; cd "$TRAVIS_BUILD_DIR/deps/upx-testsuite/files" || exit 1
ls -l packed/*/upx-3.91*
$upx -l packed/*/upx-3.91*

View File

@ -47,9 +47,10 @@ upx_SOURCES := $(sort $(wildcard $(srcdir)/*.cpp))
upx_OBJECTS := $(notdir $(upx_SOURCES:.cpp=$(objext)))
ifneq ($(wildcard $(top_srcdir)/.git/.),)
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=6 HEAD || echo "ERROR"))
UPX_VERSION_GITREV := $(strip $(shell cd '$(top_srcdir)' && git rev-parse --short=6 HEAD || echo 'ERROR'))
ifneq ($(UPX_VERSION_GITREV),)
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)"'
x := $(strip $(shell cd '$(top_srcdir)' && git diff --exit-code HEAD >/dev/null && echo '' || echo '+'))
DEFS += '-DUPX_VERSION_GITREV="$(UPX_VERSION_GITREV)$(x)"'
endif
endif

View File

@ -384,7 +384,11 @@ void show_version(int x)
UNUSED(x);
UNUSED(v);
fprintf(fp, "upx %s\n", UPX_VERSION_STRING);
fprintf(fp, "upx %s\n", UPX_VERSION_STRING
#if defined(UPX_VERSION_GITREV)
"-" UPX_VERSION_GITREV
#endif
);
#if (WITH_NRV)
v = upx_nrv_version_string();
if (v != NULL && v[0])

View File

@ -1353,6 +1353,7 @@ __acc_static_noinline void upx_sanity_check(void)
assert(memcmp(UPX_VERSION_DATE_ISO, UPX_VERSION_YEAR, 4) == 0);
assert(memcmp(&UPX_VERSION_DATE[sizeof(UPX_VERSION_DATE)-1 - 4], UPX_VERSION_YEAR, 4) == 0);
#if defined(UPX_VERSION_GITREV)
COMPILE_TIME_ASSERT(sizeof(UPX_VERSION_GITREV) <= 7 + 1)
assert(strlen(UPX_VERSION_GITREV) >= 5);
assert(strlen(UPX_VERSION_GITREV) <= 7);
#endif