diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2015-01-30 18:56:12 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-02-15 06:19:33 -0800 |
commit | f6dbed1fc6c71251e1937cb1b63e96ff7a8251c3 (patch) | |
tree | 709da15b9ead9d44198953765e06409355b43d56 /subsurface-gen-version.pri | |
parent | 27b4d10f91e4cab61756747d5b8d0f17a29d3e7a (diff) | |
download | subsurface-f6dbed1fc6c71251e1937cb1b63e96ff7a8251c3.tar.gz |
qmake: use a dedicated build script to generate ssrf-version.h
- added ./scripts/write-version
- subsurface-gen-version.pri is much simpler now
- .git/HEAD is no longer used explicitly in .pro/.pri files
- the version_h rule is called on each 'make' invocation
but recompilation will occur only if ssrf-version.h
is updated by ./scripts/write-version
- qmake now depends on the existence of ssrf-version.h
so it creates an empty one on Makefile generation so
that a warning is not shown
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-gen-version.pri')
-rw-r--r-- | subsurface-gen-version.pri | 48 |
1 files changed, 12 insertions, 36 deletions
diff --git a/subsurface-gen-version.pri b/subsurface-gen-version.pri index 7d4cda513..8e3f06a7e 100644 --- a/subsurface-gen-version.pri +++ b/subsurface-gen-version.pri @@ -1,40 +1,16 @@ # Generate the ssrf-version.h file -VERSION_FILE = ssrf-version.h macx: VER_OS = darwin unix: !macx: VER_OS = linux win32: VER_OS = win -exists(.git/HEAD): { - win32: SET_GIT_DIR = set GIT_DIR - else: SET_GIT_DIR = GIT_DIR - GIT_HEAD = .git/HEAD - VERSION_SCRIPT = $$PWD/scripts/get-version - # always use linux here -------------------vvv so we get the true full version - FULL_VERSION = "`$$VERSION_SCRIPT linux`" - VERSION = $$system("sh scripts/get-version full || echo $${VERSION}") - PRODVERSION_STRING = $$system("sh scripts/get-version win $$FULL_VERSION || echo $${VERSION}.0.0-git") - VERSION_STRING = $$system("sh scripts/get-version linux $$FULL_VERSION || echo $${VERSION}-git") - version_h.depends = $$VERSION_SCRIPT $$PWD/.git/$$system("$$SET_GIT_DIR=$$PWD/.git git rev-parse --symbolic-full-name HEAD") - version_h.commands = echo \\$${LITERAL_HASH}define VERSION_STRING \\\"`GIT_DIR=$$PWD/.git $$VERSION_SCRIPT $$VER_OS || echo $$VERSION-git`\\\" > ${QMAKE_FILE_OUT} - version_h.commands += $$escape_expand(\\n)$$escape_expand(\\t) - version_h.commands += echo \\$${LITERAL_HASH}define GIT_VERSION_STRING \\\"`GIT_DIR=$$PWD/.git $$VERSION_SCRIPT linux || echo $$VERSION-git`\\\" >> ${QMAKE_FILE_OUT} - version_h.commands += $$escape_expand(\\n)$$escape_expand(\\t) - version_h.commands += echo \\$${LITERAL_HASH}define CANONICAL_VERSION_STRING \\\"`GIT_DIR=$$PWD/.git $$VERSION_SCRIPT full || echo $$VERSION-git`\\\" >> ${QMAKE_FILE_OUT} - version_h.input = GIT_HEAD - version_h.output = $$VERSION_FILE - version_h.variable_out = GENERATED_FILES - version_h.CONFIG = ignore_no_exist - QMAKE_EXTRA_COMPILERS += version_h -} else { - # This is probably a package - exists(.gitversion): { - FULL_VERSION = $$system("cat .gitversion") - } else { - FULL_VERSION = $$VERSION - } - CANONICAL_VERSION = $$system("sh scripts/get-version full $$FULL_VERSION") - OS_USABLE_VERSION = $$system("sh scripts/get-version $$VER_OS $$FULL_VERSION") - system(echo \\$${LITERAL_HASH}define VERSION_STRING \\\"$$OS_USABLE_VERSION\\\" > $$VERSION_FILE) - system(echo \\$${LITERAL_HASH}define GIT_VERSION_STRING \\\"$$FULL_VERSION\\\" >> $$VERSION_FILE) - system(echo \\$${LITERAL_HASH}define CANONICAL_VERSION_STRING \\\"$$CANONICAL_VERSION\\\" >> $$VERSION_FILE) - QMAKE_CLEAN += $$VERSION_FILE -} + +# use a compiler target that has a phony input and is forced on each `make` invocation +# the resulted file is not a link target and is cleared with `make clean` +PHONY_DEPS = . +version_h.input = PHONY_DEPS +version_h.depends = FORCE +version_h.output = $$VERSION_FILE +version_h.commands = cd $$PWD && sh $$PWD/scripts/write-version $$VERSION_FILE $$VERSION $$VER_OS +silent: version_h.commands = @echo Checking $$VERSION_FILE && $$version_h.commads +version_h.CONFIG += no_link +QMAKE_EXTRA_COMPILERS += version_h +QMAKE_CLEAN += $$VERSION_FILE |