diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-08-10 11:29:22 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2017-08-21 09:29:23 +0000 |
commit | 8aca0dec116c6b321373f5636b34036530ac6e4b (patch) | |
tree | 1f42efbaa1f59a58916589dd9d4afe717c7bcfc9 /sources/pyside2/CMakeLists.txt | |
parent | 94dd6e146f3cc63c5b80ad7cd2ee5221b9502265 (diff) |
Add commit info and build date to installed package
This change adds four new properties to the top-level PySide2 package:
__build_date__ - the date when the package was built in iso8601 format
__build_commit_date__ - the date of the top-level commit used to
build the package
__build_commit_hash__ - the SHA1 hash of the top-level commit
__build_commit_hash_described__ - the result of 'git describe commmit'
If git is not found on the system when the build is done, the last
three properties will not be present.
Note that all this info is computed at cmake configuration time, which
means that currently the properties will not be updated unless the
CMakeLists.txt file is touched, or a full reconfiguration is done.
If PySide2 is built using the setup.py script, the cmake
reconfiguration is always done.
Task-number: PYSIDE-557
Change-Id: I7db67fa34973e7976b21e3d1d36237577b3c6e32
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/CMakeLists.txt')
-rw-r--r-- | sources/pyside2/CMakeLists.txt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index 7799c0c7a..f5e4102c4 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -159,6 +159,52 @@ else() CACHE STRING "PySide version [full]" FORCE) endif() +string(TIMESTAMP PYSIDE_BUILD_DATE "%Y-%m-%dT%H:%M:%S+00:00" UTC) +if (PYSIDE_BUILD_DATE) + set(PYSIDE_BUILD_DATE "__build_date__ = '${PYSIDE_BUILD_DATE}'") +endif() + +find_package(Git) +if(GIT_FOUND) + # Check if current source folder is inside a git repo, so that commit information can be + # queried. + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse --git-dir + OUTPUT_VARIABLE PYSIDE_SOURCE_IS_INSIDE_REPO + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(PYSIDE_SOURCE_IS_INSIDE_REPO) + # Force git dates to be UTC-based. + set(ENV{TZ} UTC) + execute_process( + COMMAND ${GIT_EXECUTABLE} --no-pager show --date=format-local:%Y-%m-%dT%H:%M:%S+00:00 -s --format=%cd HEAD + OUTPUT_VARIABLE PYSIDE_BUILD_COMMIT_DATE + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(PYSIDE_BUILD_COMMIT_DATE) + set(PYSIDE_BUILD_COMMIT_DATE "__build_commit_date__ = '${PYSIDE_BUILD_COMMIT_DATE}'") + endif() + unset(ENV{TZ}) + + execute_process( + COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + OUTPUT_VARIABLE PYSIDE_BUILD_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(PYSIDE_BUILD_COMMIT_HASH) + set(PYSIDE_BUILD_COMMIT_HASH "__build_commit_hash__ = '${PYSIDE_BUILD_COMMIT_HASH}'") + endif() + + execute_process( + COMMAND ${GIT_EXECUTABLE} describe HEAD + OUTPUT_VARIABLE PYSIDE_BUILD_COMMIT_HASH_DESCRIBED + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(PYSIDE_BUILD_COMMIT_HASH_DESCRIBED) + set(PYSIDE_BUILD_COMMIT_HASH_DESCRIBED "__build_commit_hash_described__ = '${PYSIDE_BUILD_COMMIT_HASH_DESCRIBED}'") + endif() + + endif() +endif() + include(PySideModules) macro(COLLECT_MODULE_IF_FOUND shortname) |