2022-04-19 11:23:39 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-01-14 18:07:15 +01:00
|
|
|
# Copyright (C) The Qt Company Ltd.
|
2022-08-19 15:59:36 +02:00
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2020-06-04 15:47:29 +02:00
|
|
|
import argparse
|
2020-11-23 11:11:19 +01:00
|
|
|
import collections
|
2012-01-05 17:55:55 +01:00
|
|
|
import os
|
2016-11-28 18:33:27 +02:00
|
|
|
import locale
|
2012-01-05 17:55:55 +01:00
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
import shutil
|
|
|
|
from glob import glob
|
|
|
|
|
2015-07-03 16:05:06 +02:00
|
|
|
import common
|
|
|
|
|
2012-03-13 13:20:00 +01:00
|
|
|
debug_build = False
|
2016-11-28 18:33:27 +02:00
|
|
|
encoding = locale.getdefaultlocale()[1]
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2020-06-04 15:47:29 +02:00
|
|
|
def get_args():
|
|
|
|
parser = argparse.ArgumentParser(description='Deploy Qt Creator dependencies for packaging')
|
2020-06-05 11:56:19 +02:00
|
|
|
parser.add_argument('--elfutils-path',
|
|
|
|
help='Path to elfutils installation for use by perfprofiler (Windows, Linux)')
|
2020-06-17 15:15:18 +02:00
|
|
|
parser.add_argument('--llvm-path',
|
2023-07-25 14:53:18 +02:00
|
|
|
help='Path to LLVM installation')
|
2020-11-23 11:11:19 +01:00
|
|
|
parser.add_argument('qtcreator_binary', help='Path to Qt Creator binary (or the app bundle on macOS)')
|
2020-06-04 15:47:29 +02:00
|
|
|
parser.add_argument('qmake_binary', help='Path to qmake binary')
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
args.qtcreator_binary = os.path.abspath(args.qtcreator_binary)
|
2020-11-23 11:11:19 +01:00
|
|
|
if common.is_mac_platform():
|
|
|
|
if not args.qtcreator_binary.lower().endswith(".app"):
|
|
|
|
args.qtcreator_binary = args.qtcreator_binary + ".app"
|
|
|
|
check = os.path.isdir
|
|
|
|
else:
|
|
|
|
check = os.path.isfile
|
|
|
|
if common.is_windows_platform() and not args.qtcreator_binary.lower().endswith(".exe"):
|
|
|
|
args.qtcreator_binary = args.qtcreator_binary + ".exe"
|
|
|
|
|
|
|
|
if not check(args.qtcreator_binary):
|
2020-06-04 15:47:29 +02:00
|
|
|
print('Cannot find Qt Creator binary.')
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
args.qmake_binary = which(args.qmake_binary)
|
|
|
|
if not args.qmake_binary:
|
|
|
|
print('Cannot find qmake binary.')
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
return args
|
|
|
|
|
2023-07-26 09:07:15 +02:00
|
|
|
def with_exe_ext(filepath):
|
|
|
|
return filepath + '.exe' if common.is_windows_platform() else filepath
|
|
|
|
|
2012-01-05 17:55:55 +01:00
|
|
|
def which(program):
|
|
|
|
def is_exe(fpath):
|
|
|
|
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
|
|
|
|
|
2015-10-28 11:29:10 +01:00
|
|
|
fpath = os.path.dirname(program)
|
2012-01-05 17:55:55 +01:00
|
|
|
if fpath:
|
|
|
|
if is_exe(program):
|
|
|
|
return program
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2012-01-05 17:55:55 +01:00
|
|
|
if is_exe(program + ".exe"):
|
|
|
|
return program + ".exe"
|
|
|
|
else:
|
|
|
|
for path in os.environ["PATH"].split(os.pathsep):
|
|
|
|
exe_file = os.path.join(path, program)
|
|
|
|
if is_exe(exe_file):
|
|
|
|
return exe_file
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2012-01-05 17:55:55 +01:00
|
|
|
if is_exe(exe_file + ".exe"):
|
|
|
|
return exe_file + ".exe"
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
2012-03-13 13:20:00 +01:00
|
|
|
def is_debug(fpath):
|
2012-12-07 09:43:34 +01:00
|
|
|
# match all Qt Core dlls from Qt4, Qt5beta2 and Qt5rc1 and later
|
|
|
|
# which all have the number at different places
|
|
|
|
coredebug = re.compile(r'Qt[1-9]?Core[1-9]?d[1-9]?.dll')
|
2012-01-05 17:55:55 +01:00
|
|
|
# bootstrap exception
|
2012-12-11 09:21:04 +01:00
|
|
|
if coredebug.search(fpath):
|
2012-01-05 17:55:55 +01:00
|
|
|
return True
|
2021-04-17 23:24:04 +03:00
|
|
|
# try to use dumpbin (MSVC) or objdump (MinGW), otherwise ship all .dlls
|
|
|
|
if which('dumpbin'):
|
2020-06-17 15:15:18 +02:00
|
|
|
output = subprocess.check_output(['dumpbin', '/imports', fpath])
|
2021-04-17 23:24:04 +03:00
|
|
|
elif which('objdump'):
|
|
|
|
output = subprocess.check_output(['objdump', '-p', fpath])
|
|
|
|
else:
|
2020-06-17 15:15:18 +02:00
|
|
|
return debug_build
|
2021-04-17 23:24:04 +03:00
|
|
|
return coredebug.search(output.decode(encoding)) != None
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-10-28 11:29:10 +01:00
|
|
|
def is_ignored_windows_file(use_debug, basepath, filename):
|
2012-03-13 13:20:00 +01:00
|
|
|
ignore_patterns = ['.lib', '.pdb', '.exp', '.ilk']
|
2016-03-07 11:14:19 +01:00
|
|
|
if use_debug:
|
|
|
|
ignore_patterns.extend(['libEGL.dll', 'libGLESv2.dll'])
|
|
|
|
else:
|
|
|
|
ignore_patterns.extend(['libEGLd.dll', 'libGLESv2d.dll'])
|
2012-01-05 17:55:55 +01:00
|
|
|
for ip in ignore_patterns:
|
|
|
|
if filename.endswith(ip):
|
2012-03-13 13:20:00 +01:00
|
|
|
return True
|
2015-10-28 11:29:10 +01:00
|
|
|
if filename.endswith('.dll'):
|
|
|
|
filepath = os.path.join(basepath, filename)
|
|
|
|
if use_debug != is_debug(filepath):
|
|
|
|
return True
|
2012-03-13 13:20:00 +01:00
|
|
|
return False
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-10-28 11:29:10 +01:00
|
|
|
def ignored_qt_lib_files(path, filenames):
|
2022-12-16 11:23:54 +01:00
|
|
|
# Qt ships some unneeded object files in the qml plugins
|
|
|
|
# On Windows we also do not want to ship the wrong debug/release .dlls or .lib files etc
|
2023-07-26 14:19:37 +02:00
|
|
|
# And get rid of debug info directories (.dSYM) on macOS
|
|
|
|
if common.is_linux_platform():
|
2022-12-16 11:23:54 +01:00
|
|
|
return [fn for fn in filenames if fn.endswith('.cpp.o')]
|
2023-07-26 14:19:37 +02:00
|
|
|
if common.is_mac_platform():
|
|
|
|
return [fn for fn in filenames if fn.endswith('.dylib.dSYM')]
|
2022-12-16 11:23:54 +01:00
|
|
|
return [fn for fn in filenames
|
|
|
|
if fn.endswith('.cpp.obj') or is_ignored_windows_file(debug_build, path, fn)]
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2023-07-26 14:38:08 +02:00
|
|
|
def copy_qt_libs(target_qt_prefix_path, qt_bin_dir, qt_libs_dir):
|
2016-11-28 18:33:27 +02:00
|
|
|
print("copying Qt libraries...")
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2012-01-05 17:55:55 +01:00
|
|
|
libraries = glob(os.path.join(qt_libs_dir, '*.dll'))
|
|
|
|
else:
|
|
|
|
libraries = glob(os.path.join(qt_libs_dir, '*.so.*'))
|
|
|
|
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2015-10-29 10:21:41 +01:00
|
|
|
lib_dest = os.path.join(target_qt_prefix_path)
|
2012-01-05 17:55:55 +01:00
|
|
|
else:
|
2015-10-29 10:21:41 +01:00
|
|
|
lib_dest = os.path.join(target_qt_prefix_path, 'lib')
|
|
|
|
|
|
|
|
if not os.path.exists(lib_dest):
|
|
|
|
os.makedirs(lib_dest)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2016-03-07 11:14:19 +01:00
|
|
|
libraries = [lib for lib in libraries if not is_ignored_windows_file(debug_build, '', lib)]
|
2012-01-05 17:55:55 +01:00
|
|
|
|
|
|
|
for library in libraries:
|
2016-11-28 18:33:27 +02:00
|
|
|
print(library, '->', lib_dest)
|
2012-01-05 17:55:55 +01:00
|
|
|
if os.path.islink(library):
|
|
|
|
linkto = os.readlink(library)
|
|
|
|
try:
|
2015-10-29 10:21:41 +01:00
|
|
|
os.symlink(linkto, os.path.join(lib_dest, os.path.basename(library)))
|
2015-10-28 11:29:10 +01:00
|
|
|
except OSError:
|
2020-06-04 15:47:29 +02:00
|
|
|
pass
|
2012-01-05 17:55:55 +01:00
|
|
|
else:
|
2015-10-29 10:21:41 +01:00
|
|
|
shutil.copy(library, lib_dest)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2023-07-26 09:07:15 +02:00
|
|
|
|
|
|
|
def deploy_qtdiag(qtc_binary_path, qt_install):
|
2016-11-28 18:33:27 +02:00
|
|
|
print("Copying qtdiag")
|
2023-07-26 09:07:15 +02:00
|
|
|
qtdiag_src = os.path.join(qt_install.bin, with_exe_ext('qtdiag'))
|
|
|
|
destdir = (qtc_binary_path if common.is_windows_platform()
|
|
|
|
else os.path.join(qtc_binary_path, 'Contents', 'MacOS') if common.is_mac_platform()
|
|
|
|
else os.path.join(qtc_binary_path, '..', 'lib', 'Qt', 'bin'))
|
|
|
|
if not os.path.exists(destdir):
|
|
|
|
os.makedirs(destdir)
|
|
|
|
shutil.copy(qtdiag_src, destdir)
|
|
|
|
if common.is_mac_platform():
|
|
|
|
# fix RPATHs
|
|
|
|
qtdiag_dest = os.path.join(destdir, 'qtdiag')
|
|
|
|
subprocess.check_call(['xcrun', 'install_name_tool', '-add_rpath', '@loader_path/../Frameworks', qtdiag_dest])
|
|
|
|
subprocess.check_call(['xcrun', 'install_name_tool', '-delete_rpath', '@loader_path/../lib', qtdiag_dest])
|
2016-09-02 14:36:12 +02:00
|
|
|
|
|
|
|
|
2023-07-26 14:19:37 +02:00
|
|
|
def deploy_plugins(qtc_binary_path, qt_install):
|
|
|
|
plugins = ['assetimporters', 'accessible', 'codecs', 'designer', 'iconengines', 'imageformats', 'platformthemes',
|
|
|
|
'platforminputcontexts', 'platforms', 'printsupport', 'qmltooling', 'sqldrivers', 'styles',
|
|
|
|
'xcbglintegrations',
|
|
|
|
'wayland-decoration-client',
|
|
|
|
'wayland-graphics-integration-client',
|
|
|
|
'wayland-shell-integration',
|
|
|
|
'tls'
|
|
|
|
]
|
|
|
|
print("Copying plugins:", plugins)
|
|
|
|
destdir = (os.path.join(qtc_binary_path, 'plugins') if common.is_windows_platform()
|
|
|
|
else os.path.join(qtc_binary_path, 'Contents', 'PlugIns') if common.is_mac_platform()
|
|
|
|
else os.path.join(qtc_binary_path, '..', 'lib', 'Qt', 'plugins'))
|
|
|
|
for plugin in plugins:
|
|
|
|
target = os.path.join(destdir, plugin)
|
|
|
|
if (os.path.exists(target)):
|
|
|
|
shutil.rmtree(target)
|
|
|
|
pluginPath = os.path.join(qt_install.plugins, plugin)
|
|
|
|
if (os.path.exists(pluginPath)):
|
|
|
|
print('{0} -> {1}'.format(pluginPath, target))
|
|
|
|
common.copytree(pluginPath, target, ignore=ignored_qt_lib_files, symlinks=True)
|
|
|
|
|
|
|
|
|
2023-07-26 14:38:08 +02:00
|
|
|
def deploy_imports(qtc_binary_path, qt_install):
|
|
|
|
print("Copying qt quick 2 imports")
|
|
|
|
destdir = (os.path.join(qtc_binary_path, 'qml') if common.is_windows_platform()
|
|
|
|
else os.path.join(qtc_binary_path, 'Contents', 'Imports', 'qtquick2') if common.is_mac_platform()
|
|
|
|
else os.path.join(qtc_binary_path, '..', 'lib', 'Qt', 'qml'))
|
|
|
|
if (os.path.exists(destdir)):
|
|
|
|
shutil.rmtree(destdir)
|
|
|
|
print('{0} -> {1}'.format(qt_install.qml, destdir))
|
|
|
|
common.copytree(qt_install.qml, destdir, ignore=ignored_qt_lib_files, symlinks=True)
|
|
|
|
|
|
|
|
|
2023-07-26 16:06:41 +02:00
|
|
|
def qt_conf_contents():
|
|
|
|
if common.is_linux_platform():
|
|
|
|
return '''[Paths]
|
|
|
|
Prefix={0}
|
|
|
|
Binaries=bin
|
|
|
|
Libraries=lib
|
|
|
|
Plugins=plugins
|
|
|
|
Qml2Imports=qml
|
|
|
|
'''
|
|
|
|
if common.is_windows_platform():
|
|
|
|
return '''[Paths]
|
|
|
|
Prefix={0}
|
|
|
|
Binaries=.
|
|
|
|
Libraries=.
|
|
|
|
Plugins=plugins
|
|
|
|
Qml2Imports=qml
|
|
|
|
'''
|
|
|
|
return '''[Paths]
|
|
|
|
Prefix={0}
|
|
|
|
Binaries=MacOS
|
|
|
|
Libraries=Frameworks
|
|
|
|
Plugins=PlugIns
|
|
|
|
Qml2Imports=Imports/qtquick2
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
2015-10-29 10:21:41 +01:00
|
|
|
def add_qt_conf(target_path, qt_prefix_path):
|
|
|
|
qtconf_filepath = os.path.join(target_path, 'qt.conf')
|
|
|
|
prefix_path = os.path.relpath(qt_prefix_path, target_path).replace('\\', '/')
|
2015-10-19 12:34:24 +02:00
|
|
|
print('Creating qt.conf in "{0}":'.format(qtconf_filepath))
|
|
|
|
f = open(qtconf_filepath, 'w')
|
2023-07-26 16:06:41 +02:00
|
|
|
f.write(qt_conf_contents().format(prefix_path))
|
2012-11-12 13:10:37 +01:00
|
|
|
f.close()
|
|
|
|
|
2023-07-26 16:06:41 +02:00
|
|
|
|
|
|
|
def deploy_qt_conf_files(qtc_binary_path):
|
|
|
|
if common.is_linux_platform():
|
|
|
|
qt_prefix_path = os.path.join(qtc_binary_path, '..', 'lib', 'Qt')
|
|
|
|
add_qt_conf(os.path.join(qtc_binary_path, '..', 'libexec', 'qtcreator'), qt_prefix_path)
|
|
|
|
add_qt_conf(os.path.join(qtc_binary_path, '..', 'lib', 'Qt', 'bin'), qt_prefix_path) # qtdiag
|
|
|
|
add_qt_conf(qtc_binary_path, qt_prefix_path) # QtC itself
|
|
|
|
if common.is_windows_platform():
|
|
|
|
add_qt_conf(qtc_binary_path, qtc_binary_path) # QtC itself, libexec, and qtdiag etc
|
|
|
|
if common.is_mac_platform():
|
|
|
|
qt_prefix_path = os.path.join(qtc_binary_path, 'Contents')
|
|
|
|
qtc_resources_path = os.path.join(qtc_binary_path, 'Contents', 'Resources')
|
|
|
|
add_qt_conf(os.path.join(qtc_resources_path, 'libexec'), qt_prefix_path)
|
|
|
|
add_qt_conf(os.path.join(qtc_resources_path, 'libexec', 'ios'), qt_prefix_path)
|
|
|
|
# The Prefix path for a qt.conf in Contents/Resources/ is handled specially/funny by Qt,
|
|
|
|
# relative paths are resolved relative to Contents/, so we must enforces Prefix=.
|
|
|
|
add_qt_conf(qtc_resources_path, qtc_resources_path) # QtC itself
|
|
|
|
|
|
|
|
|
2023-07-26 14:56:08 +02:00
|
|
|
def deploy_translations(qtc_binary_path, qt_install):
|
|
|
|
print("Copying translations...")
|
|
|
|
translations = glob(os.path.join(qt_install.translations, '*.qm'))
|
|
|
|
destdir = (os.path.join(qtc_binary_path, 'Contents', 'Resources', 'translations') if common.is_mac_platform()
|
|
|
|
else os.path.join(qtc_binary_path, '..', 'share', 'qtcreator', 'translations'))
|
2012-12-06 11:59:04 +01:00
|
|
|
for translation in translations:
|
2023-07-26 14:56:08 +02:00
|
|
|
print(translation, '->', destdir)
|
|
|
|
shutil.copy(translation, destdir)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-06-23 13:29:31 +02:00
|
|
|
def copyPreservingLinks(source, destination):
|
|
|
|
if os.path.islink(source):
|
|
|
|
linkto = os.readlink(source)
|
|
|
|
destFilePath = destination
|
|
|
|
if os.path.isdir(destination):
|
|
|
|
destFilePath = os.path.join(destination, os.path.basename(source))
|
|
|
|
os.symlink(linkto, destFilePath)
|
|
|
|
else:
|
|
|
|
shutil.copy(source, destination)
|
|
|
|
|
2022-05-24 13:35:00 +02:00
|
|
|
def deploy_clang(install_dir, llvm_install_dir, chrpath_bin):
|
2015-07-09 17:19:23 +02:00
|
|
|
# contains pairs of (source, target directory)
|
|
|
|
deployinfo = []
|
2016-08-17 13:36:51 +02:00
|
|
|
resourcesource = os.path.join(llvm_install_dir, 'lib', 'clang')
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2016-08-17 13:36:51 +02:00
|
|
|
clangbindirtarget = os.path.join(install_dir, 'bin', 'clang', 'bin')
|
|
|
|
if not os.path.exists(clangbindirtarget):
|
|
|
|
os.makedirs(clangbindirtarget)
|
|
|
|
clanglibdirtarget = os.path.join(install_dir, 'bin', 'clang', 'lib')
|
|
|
|
if not os.path.exists(clanglibdirtarget):
|
|
|
|
os.makedirs(clanglibdirtarget)
|
2022-06-27 15:26:03 +02:00
|
|
|
for binary in ['clangd', 'clang-tidy', 'clazy-standalone', 'clang-format']:
|
2020-12-16 13:23:23 +01:00
|
|
|
binary_filepath = os.path.join(llvm_install_dir, 'bin', binary + '.exe')
|
2020-12-09 14:12:20 +01:00
|
|
|
if os.path.exists(binary_filepath):
|
|
|
|
deployinfo.append((binary_filepath, clangbindirtarget))
|
2016-08-17 13:36:51 +02:00
|
|
|
resourcetarget = os.path.join(clanglibdirtarget, 'clang')
|
2014-02-11 13:39:13 +01:00
|
|
|
else:
|
2020-07-14 16:58:24 +02:00
|
|
|
# clang binaries -> clang libexec
|
2016-08-17 13:36:51 +02:00
|
|
|
clangbinary_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'bin')
|
|
|
|
if not os.path.exists(clangbinary_targetdir):
|
|
|
|
os.makedirs(clangbinary_targetdir)
|
2022-06-27 15:26:03 +02:00
|
|
|
for binary in ['clangd', 'clang-tidy', 'clazy-standalone', 'clang-format']:
|
2020-07-14 16:58:24 +02:00
|
|
|
binary_filepath = os.path.join(llvm_install_dir, 'bin', binary)
|
2020-12-09 14:12:20 +01:00
|
|
|
if os.path.exists(binary_filepath):
|
|
|
|
deployinfo.append((binary_filepath, clangbinary_targetdir))
|
|
|
|
# add link target if binary is actually a symlink (to a binary in the same directory)
|
|
|
|
if os.path.islink(binary_filepath):
|
|
|
|
linktarget = os.readlink(binary_filepath)
|
|
|
|
deployinfo.append((os.path.join(os.path.dirname(binary_filepath), linktarget),
|
|
|
|
os.path.join(clangbinary_targetdir, linktarget)))
|
2020-07-14 16:58:24 +02:00
|
|
|
clanglibs_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'lib')
|
|
|
|
# support libraries (for clazy) -> clang libexec
|
|
|
|
if not os.path.exists(clanglibs_targetdir):
|
|
|
|
os.makedirs(clanglibs_targetdir)
|
2020-08-10 12:07:27 +02:00
|
|
|
# on RHEL ClazyPlugin is in lib64
|
2022-06-21 13:34:04 +02:00
|
|
|
for lib_pattern in ['lib64/ClazyPlugin.so', 'lib/ClazyPlugin.so']:
|
2020-08-10 12:07:27 +02:00
|
|
|
for lib in glob(os.path.join(llvm_install_dir, lib_pattern)):
|
2020-07-14 16:58:24 +02:00
|
|
|
deployinfo.append((lib, clanglibs_targetdir))
|
2016-08-17 13:36:51 +02:00
|
|
|
resourcetarget = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'lib', 'clang')
|
2015-07-09 17:19:23 +02:00
|
|
|
|
2022-05-24 13:35:00 +02:00
|
|
|
print("copying clang...")
|
2015-07-09 17:19:23 +02:00
|
|
|
for source, target in deployinfo:
|
2016-11-28 18:33:27 +02:00
|
|
|
print(source, '->', target)
|
2015-07-09 17:19:23 +02:00
|
|
|
copyPreservingLinks(source, target)
|
2015-07-03 16:05:06 +02:00
|
|
|
|
|
|
|
if common.is_linux_platform():
|
|
|
|
# libclang was statically compiled, so there is no need for the RPATHs
|
2020-07-14 16:58:24 +02:00
|
|
|
# and they are confusing when fixing RPATHs later in the process.
|
|
|
|
# Also fix clazy-standalone RPATH.
|
|
|
|
print("fixing Clang RPATHs...")
|
2015-07-03 16:05:06 +02:00
|
|
|
for source, target in deployinfo:
|
2020-07-14 16:58:24 +02:00
|
|
|
filename = os.path.basename(source)
|
|
|
|
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, filename)
|
|
|
|
if filename == 'clazy-standalone':
|
|
|
|
subprocess.check_call([chrpath_bin, '-r', '$ORIGIN/../lib', targetfilepath])
|
|
|
|
elif not os.path.islink(target):
|
2015-07-03 16:05:06 +02:00
|
|
|
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, os.path.basename(source))
|
|
|
|
subprocess.check_call([chrpath_bin, '-d', targetfilepath])
|
|
|
|
|
2016-11-28 18:33:27 +02:00
|
|
|
print(resourcesource, '->', resourcetarget)
|
2014-02-11 13:39:13 +01:00
|
|
|
if (os.path.exists(resourcetarget)):
|
|
|
|
shutil.rmtree(resourcetarget)
|
2015-07-03 16:05:06 +02:00
|
|
|
common.copytree(resourcesource, resourcetarget, symlinks=True)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2020-06-05 11:56:19 +02:00
|
|
|
def deploy_elfutils(qtc_install_dir, chrpath_bin, args):
|
|
|
|
if common.is_mac_platform():
|
|
|
|
return
|
|
|
|
|
2023-03-22 09:38:48 +01:00
|
|
|
libs = ['elf', 'dw']
|
|
|
|
version = '1'
|
|
|
|
|
2020-06-05 11:56:19 +02:00
|
|
|
def lib_name(name, version):
|
|
|
|
return ('lib' + name + '.so.' + version if common.is_linux_platform()
|
|
|
|
else name + '.dll')
|
|
|
|
|
2023-03-22 09:38:48 +01:00
|
|
|
def find_elfutils_lib_path(path):
|
|
|
|
for root, _, files in os.walk(path):
|
|
|
|
if lib_name('elf', version) in files:
|
|
|
|
return root
|
|
|
|
return path
|
|
|
|
|
|
|
|
elfutils_lib_path = find_elfutils_lib_path(os.path.join(args.elfutils_path, 'lib'))
|
2020-06-05 11:56:19 +02:00
|
|
|
if common.is_linux_platform():
|
|
|
|
install_path = os.path.join(qtc_install_dir, 'lib', 'elfutils')
|
|
|
|
backends_install_path = install_path
|
|
|
|
elif common.is_windows_platform():
|
|
|
|
install_path = os.path.join(qtc_install_dir, 'bin')
|
|
|
|
backends_install_path = os.path.join(qtc_install_dir, 'lib', 'elfutils')
|
|
|
|
libs.append('eu_compat')
|
|
|
|
if not os.path.exists(install_path):
|
|
|
|
os.makedirs(install_path)
|
|
|
|
if not os.path.exists(backends_install_path):
|
|
|
|
os.makedirs(backends_install_path)
|
|
|
|
# copy main libs
|
|
|
|
libs = [os.path.join(elfutils_lib_path, lib_name(lib, version)) for lib in libs]
|
|
|
|
for lib in libs:
|
|
|
|
print(lib, '->', install_path)
|
|
|
|
shutil.copy(lib, install_path)
|
|
|
|
# fix rpath
|
|
|
|
if common.is_linux_platform():
|
|
|
|
relative_path = os.path.relpath(backends_install_path, install_path)
|
|
|
|
subprocess.check_call([chrpath_bin, '-r', os.path.join('$ORIGIN', relative_path),
|
|
|
|
os.path.join(install_path, lib_name('dw', version))])
|
|
|
|
# copy backend files
|
|
|
|
# only non-versioned, we never dlopen the versioned ones
|
|
|
|
files = glob(os.path.join(elfutils_lib_path, 'elfutils', '*ebl_*.*'))
|
|
|
|
versioned_files = glob(os.path.join(elfutils_lib_path, 'elfutils', '*ebl_*.*-*.*.*'))
|
|
|
|
unversioned_files = [file for file in files if file not in versioned_files]
|
|
|
|
for file in unversioned_files:
|
|
|
|
print(file, '->', backends_install_path)
|
|
|
|
shutil.copy(file, backends_install_path)
|
|
|
|
|
2020-11-23 11:11:19 +01:00
|
|
|
def deploy_mac(args):
|
|
|
|
(_, qt_install) = get_qt_install_info(args.qmake_binary)
|
|
|
|
|
|
|
|
env = dict(os.environ)
|
|
|
|
if args.llvm_path:
|
|
|
|
env['LLVM_INSTALL_DIR'] = args.llvm_path
|
|
|
|
|
|
|
|
script_path = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
deployqtHelper_mac = os.path.join(script_path, 'deployqtHelper_mac.sh')
|
|
|
|
common.check_print_call([deployqtHelper_mac, args.qtcreator_binary, qt_install.bin,
|
|
|
|
qt_install.translations, qt_install.plugins, qt_install.qml],
|
|
|
|
env=env)
|
|
|
|
|
|
|
|
def get_qt_install_info(qmake_binary):
|
|
|
|
qt_install_info = common.get_qt_install_info(qmake_binary)
|
|
|
|
QtInstallInfo = collections.namedtuple('QtInstallInfo', ['bin', 'lib', 'plugins',
|
|
|
|
'qml', 'translations'])
|
|
|
|
return (qt_install_info,
|
|
|
|
QtInstallInfo(bin=qt_install_info['QT_INSTALL_BINS'],
|
|
|
|
lib=qt_install_info['QT_INSTALL_LIBS'],
|
|
|
|
plugins=qt_install_info['QT_INSTALL_PLUGINS'],
|
|
|
|
qml=qt_install_info['QT_INSTALL_QML'],
|
|
|
|
translations=qt_install_info['QT_INSTALL_TRANSLATIONS']))
|
|
|
|
|
2012-01-05 17:55:55 +01:00
|
|
|
def main():
|
2020-06-04 15:47:29 +02:00
|
|
|
args = get_args()
|
2023-07-26 09:07:15 +02:00
|
|
|
chrpath_bin = None
|
|
|
|
if common.is_linux_platform():
|
|
|
|
chrpath_bin = which('chrpath')
|
|
|
|
if chrpath_bin == None:
|
|
|
|
print("Cannot find required binary 'chrpath'.")
|
|
|
|
sys.exit(2)
|
|
|
|
|
2023-07-26 14:19:37 +02:00
|
|
|
if common.is_windows_platform():
|
|
|
|
global debug_build
|
|
|
|
debug_build = is_debug(args.qtcreator_binary)
|
|
|
|
|
2023-07-26 09:07:15 +02:00
|
|
|
(qt_install_info, qt_install) = get_qt_install_info(args.qmake_binary)
|
|
|
|
# <qtc>/bin for Win/Lin, <path>/<appname>.app for macOS
|
|
|
|
qtcreator_binary_path = (args.qtcreator_binary if common.is_mac_platform()
|
|
|
|
else os.path.dirname(args.qtcreator_binary))
|
|
|
|
|
|
|
|
deploy_qtdiag(qtcreator_binary_path, qt_install)
|
2023-07-26 14:19:37 +02:00
|
|
|
deploy_plugins(qtcreator_binary_path, qt_install)
|
2023-07-26 14:38:08 +02:00
|
|
|
deploy_imports(qtcreator_binary_path, qt_install)
|
2023-07-26 14:56:08 +02:00
|
|
|
deploy_translations(qtcreator_binary_path, qt_install)
|
2023-07-26 16:06:41 +02:00
|
|
|
deploy_qt_conf_files(qtcreator_binary_path)
|
2023-07-26 09:07:15 +02:00
|
|
|
|
2020-11-23 11:11:19 +01:00
|
|
|
if common.is_mac_platform():
|
|
|
|
deploy_mac(args)
|
|
|
|
return
|
|
|
|
|
2018-01-24 14:21:38 +01:00
|
|
|
install_dir = os.path.abspath(os.path.join(qtcreator_binary_path, '..'))
|
2015-10-29 10:21:41 +01:00
|
|
|
if common.is_linux_platform():
|
|
|
|
qt_deploy_prefix = os.path.join(install_dir, 'lib', 'Qt')
|
|
|
|
else:
|
|
|
|
qt_deploy_prefix = os.path.join(install_dir, 'bin')
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2015-07-03 16:05:06 +02:00
|
|
|
if common.is_windows_platform():
|
2023-07-26 14:38:08 +02:00
|
|
|
copy_qt_libs(qt_deploy_prefix, qt_install.bin, qt_install.bin)
|
2012-03-14 17:28:02 +01:00
|
|
|
else:
|
2023-07-26 14:38:08 +02:00
|
|
|
copy_qt_libs(qt_deploy_prefix, qt_install.bin, qt_install.lib)
|
2023-07-26 14:56:08 +02:00
|
|
|
|
2020-06-17 15:15:18 +02:00
|
|
|
if args.llvm_path:
|
2022-05-24 13:35:00 +02:00
|
|
|
deploy_clang(install_dir, args.llvm_path, chrpath_bin)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
2020-06-05 11:56:19 +02:00
|
|
|
if args.elfutils_path:
|
|
|
|
deploy_elfutils(install_dir, chrpath_bin, args)
|
2015-07-03 16:05:06 +02:00
|
|
|
if not common.is_windows_platform():
|
2016-11-28 18:33:27 +02:00
|
|
|
print("fixing rpaths...")
|
2015-10-29 10:21:41 +01:00
|
|
|
common.fix_rpaths(install_dir, os.path.join(qt_deploy_prefix, 'lib'), qt_install_info, chrpath_bin)
|
2012-01-05 17:55:55 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2020-11-23 11:11:19 +01:00
|
|
|
main()
|