aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/utils.py
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-10-01 16:49:32 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-12-07 15:24:41 +0100
commit9eb3e39486e95bce008fee9ae48df230273fa433 (patch)
treeff58cef05db3fedb27536507b20185be4454cb73 /build_scripts/utils.py
parent0a40ebb1defe14bb3d7a308657777a11058cf182 (diff)
setup.py: CMake: Remove host python dependency for version parsing
When cross-compiling, the python interpreter found by CMake is the device one (or at least it's supposed to be), which means we can't use it to execute python scripts on the host machine to extract shiboken and pyside version information. Instead of keeping the version numbers in python files, place them into new .cmake.conf files that CMake can include in CMake projects directly. This aligns with storing version information like Qt6 does. setup.py and coin_build_instructions need version info as well, so they will now parse the set() assignments in pyside6/.cmake.conf. Ideally we would have called cmake with a minimal project that outputs those values, but we don't have access to the CMake executable path within coin_build_instructions.py, so we rely on parsing instead. Qt Conan integration does the same, so we should be good, the .cmake.conf file format is unlikely to change and cause breakages. We also modify shiboken_version.py and pyside_version.py to use the new variables when calling configure_file(), because we still ship those files in the wheels. Amends b57c557c8cd1012851f8a245075591dc33be425b Pick-to: 6.2 Change-Id: Icc830069cd459c214ec253840ba6754ece50854e Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r--build_scripts/utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 10af2725f..c4a99edee 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -1238,3 +1238,22 @@ def get_ci_qmake_path(ci_install_dir, ci_host_os):
return f"{qmake_path}\\bin\\qmake.exe"
else:
return f"{qmake_path}/bin/qmake"
+
+
+def parse_cmake_conf_assignments_by_key(source_dir):
+ """
+ Parses a .cmake.conf file that contains set(foo "bar") assignments
+ and returns a dict with those assignments transformed to keys and
+ values.
+ """
+
+ d = {}
+ contents = (Path(source_dir) / ".cmake.conf").read_text()
+ matches = re.findall(r'set\((.+?) "(.*?)"\)', contents)
+ for m in matches:
+ key = m[0]
+ value = m[1]
+ if key and value:
+ d[key] = value
+ return d
+