Make: Support shallow git clones for testing

Since commit 1ec9b94, we derive the version number from git tags with
build-aux/git-version-gen.  When a shallow clone doesn't include a
suitable tag, this fails, and make refuses to build anything.  Since
Travis uses git-clone --depth=50, it'll break as soon as we've got
more than 50 commits since the last release.

Support arbitrarily shallow clones for limited purposes like testing
by falling back from a proper V.N-H version number to UNKNOWN-H.

To guard against use of such builds for other purposes, log a warning
on server startup, and print one on player login.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2017-09-02 17:18:30 +02:00
parent 41ce9e37fd
commit 5e1b590867
4 changed files with 16 additions and 5 deletions

View file

@ -48,12 +48,16 @@ all:
ifeq ($(revctrl),git)
src := $(shell cd $(srcdir) && git ls-files | uniq)
version := $(shell cd $(srcdir) && build-aux/git-version-gen /dev/null)
ifeq ($(version),UNKNOWN)
$(warning cannot figure out version number, falling back to git hash)
version := UNKNOWN-$(shell cd $(srcdir) && git-rev-parse --verify --short HEAD || echo "UNKNOWN")
endif
else
include $(srcdir)/sources.mk
version := $(shell cat $(srcdir)/.tarball-version || echo "UNKNOWN")
endif
ifeq ($(version),UNKNOWN)
$(error cannot figure out version)
$(error cannot figure out version number)
endif
dirs := $(sort $(dir $(src)))
csrc := $(filter %.c, $(src))