diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-16 09:43:28 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-06-16 13:10:43 +0200 |
commit | e284e630bf57338a1f02323a2f8c3d126a4c5769 (patch) | |
tree | 9b8b4ff957a22808b8bab04e6c6d4b1fb650e410 /build_scripts/utils.py | |
parent | cd1022b1216dbf67bb553b7fc65106d91e95643d (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/utils.py')
-rw-r--r-- | build_scripts/utils.py | 22 |
1 files changed, 16 insertions, 6 deletions
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. |