aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-06-16 09:43:28 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-06-16 13:10:43 +0200
commite284e630bf57338a1f02323a2f8c3d126a4c5769 (patch)
tree9b8b4ff957a22808b8bab04e6c6d4b1fb650e410 /build_scripts
parentcd1022b1216dbf67bb553b7fc65106d91e95643d (diff)
build scripts: Extract helper functions to patch executables
Prepare for adding more binaries. Task-number: PYSIDE-1378 Change-Id: I1e3a39db28da19fe9a307145d599d7448428652d Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'build_scripts')
-rw-r--r--build_scripts/platforms/linux.py8
-rw-r--r--build_scripts/platforms/macos.py14
-rw-r--r--build_scripts/utils.py22
3 files changed, 28 insertions, 16 deletions
diff --git a/build_scripts/platforms/linux.py b/build_scripts/platforms/linux.py
index cafddbc07..442506d81 100644
--- a/build_scripts/platforms/linux.py
+++ b/build_scripts/platforms/linux.py
@@ -38,7 +38,7 @@
#############################################################################
from ..utils import (copydir, copyfile, copy_icu_libs, find_files_using_glob,
- linux_set_rpaths, linux_get_rpaths, rpaths_has_origin)
+ linux_patch_executable)
from ..config import config
from ..versions import PYSIDE
@@ -91,11 +91,7 @@ def prepare_standalone_package_linux(self, vars):
# Patching designer to use the Qt libraries provided in the wheel
if config.is_internal_pyside_build():
designer_path = "{st_build_dir}/{st_package_name}/designer".format(**vars)
- rpaths = linux_get_rpaths(designer_path)
- if not rpaths or not rpaths_has_origin(rpaths):
- rpaths.insert(0, '$ORIGIN/../lib')
- new_rpaths_string = ":".join(rpaths)
- linux_set_rpaths(self._patchelf_path, designer_path, new_rpaths_string)
+ linux_patch_executable(self._patchelf_path, designer_path)
if self.is_webengine_built(built_modules):
copydir("{qt_lib_execs_dir}",
diff --git a/build_scripts/platforms/macos.py b/build_scripts/platforms/macos.py
index b1e0911f3..6db0ef2b7 100644
--- a/build_scripts/platforms/macos.py
+++ b/build_scripts/platforms/macos.py
@@ -44,6 +44,15 @@ from ..config import config
from ..versions import PYSIDE
+def _macos_patch_executable(name, vars=None):
+ """ Patch an executable to run with the Qt libraries. """
+ upper_name = name[0:1].upper() + name[1:]
+ bundle = f"{{st_build_dir}}/{{st_package_name}}/{upper_name}.app".format(**vars)
+ binary = f"{bundle}/Contents/MacOS/{upper_name}"
+ rpath = "@loader_path/../../../Qt/lib"
+ macos_add_rpath(rpath, binary)
+
+
def prepare_standalone_package_macos(self, vars):
built_modules = vars['built_modules']
@@ -80,10 +89,7 @@ def prepare_standalone_package_macos(self, vars):
# Patching designer to use the Qt libraries provided in the wheel
if config.is_internal_pyside_build():
- designer_bundle = "{st_build_dir}/{st_package_name}/Designer.app".format(**vars)
- designer_binary = f"{designer_bundle}/Contents/MacOS/Designer"
- rpath = "@loader_path/../../../Qt/lib"
- macos_add_rpath(rpath, designer_binary)
+ _macos_patch_executable('designer', vars)
# <qt>/lib/* -> <setup>/{st_package_name}/Qt/lib
if self.qt_is_framework_build():
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 614fe336a..4f22f7d7b 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -974,12 +974,7 @@ def copy_icu_libs(patchelf, destination_lib_dir):
# Patch the QtCore library to find the copied over ICU libraries
# (if necessary).
log.info("Checking if QtCore library needs a new rpath to make it work with ICU libs.")
- rpaths = linux_get_rpaths(qt_core_library_path)
- if not rpaths or not rpaths_has_origin(rpaths):
- log.info('Patching QtCore library to contain $ORIGIN rpath.')
- rpaths.insert(0, '$ORIGIN')
- new_rpaths_string = ":".join(rpaths)
- linux_set_rpaths(patchelf, qt_core_library_path, new_rpaths_string)
+ linux_prepend_rpath(patchelf, qt_core_library_path, '$ORIGIN')
def linux_run_read_elf(executable_path):
@@ -1001,6 +996,21 @@ def linux_set_rpaths(patchelf, executable_path, rpath_string):
raise RuntimeError(f"Error patching rpath in {executable_path}")
+def linux_prepend_rpath(patchelf, executable_path, new_path):
+ """ Prepends a path to the rpaths of the executable unless it has ORIGIN. """
+ rpaths = linux_get_rpaths(executable_path)
+ if not rpaths or not rpaths_has_origin(rpaths):
+ rpaths.insert(0, new_path)
+ new_rpaths_string = ":".join(rpaths)
+ linux_set_rpaths(patchelf, executable_path, new_rpaths_string)
+ result = True
+
+
+def linux_patch_executable(patchelf, executable_path):
+ """ Patch an executable to run with the Qt libraries. """
+ linux_prepend_rpath(patchelf, executable_path, '$ORIGIN/../lib')
+
+
def linux_get_dependent_libraries(executable_path):
"""
Returns a list of libraries that executable_path depends on.