aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2017-08-10 11:29:22 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2017-08-21 09:29:23 +0000
commit8aca0dec116c6b321373f5636b34036530ac6e4b (patch)
tree1f42efbaa1f59a58916589dd9d4afe717c7bcfc9 /sources
parent94dd6e146f3cc63c5b80ad7cd2ee5221b9502265 (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')
-rw-r--r--sources/pyside2/CMakeLists.txt46
-rw-r--r--sources/pyside2/PySide2/__init__.py.in4
2 files changed, 50 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)
diff --git a/sources/pyside2/PySide2/__init__.py.in b/sources/pyside2/PySide2/__init__.py.in
index 99deb35e2..ffe017587 100644
--- a/sources/pyside2/PySide2/__init__.py.in
+++ b/sources/pyside2/PySide2/__init__.py.in
@@ -4,6 +4,10 @@ __all__ = list("Qt" + body for body in
__version__ = "@BINDING_API_VERSION_FULL@"
__version_info__ = (@BINDING_API_MAJOR_VERSION@, @BINDING_API_MINOR_VERSION@, @BINDING_API_MICRO_VERSION@, "@BINDING_API_RELEASE_LEVEL@", @BINDING_API_SERIAL@)
+@PYSIDE_BUILD_DATE@
+@PYSIDE_BUILD_COMMIT_DATE@
+@PYSIDE_BUILD_COMMIT_HASH@
+@PYSIDE_BUILD_COMMIT_HASH_DESCRIBED@
def _setupQtDirectories():
import sys