forked from qt-creator/qt-creator
Build/deploy: Move llvm deployment to deploy.py
Moving things away from deployqtHelper_mac.sh Change-Id: Ifadbf763fdbf12b5e22fc037986eb1b018b96aef Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -269,47 +269,52 @@ def copyPreservingLinks(source, destination):
|
|||||||
else:
|
else:
|
||||||
shutil.copy(source, destination)
|
shutil.copy(source, destination)
|
||||||
|
|
||||||
def deploy_clang(install_dir, llvm_install_dir, chrpath_bin):
|
def deploy_clang(qtc_binary_path, llvm_install_dir, chrpath_bin):
|
||||||
|
print("Copying clang...")
|
||||||
|
|
||||||
# contains pairs of (source, target directory)
|
# contains pairs of (source, target directory)
|
||||||
deployinfo = []
|
deployinfo = []
|
||||||
resourcesource = os.path.join(llvm_install_dir, 'lib', 'clang')
|
resourcesource = os.path.join(llvm_install_dir, 'lib', 'clang')
|
||||||
if common.is_windows_platform():
|
if common.is_windows_platform():
|
||||||
clangbindirtarget = os.path.join(install_dir, 'bin', 'clang', 'bin')
|
clang_targetdir = os.path.join(qtc_binary_path, 'clang')
|
||||||
if not os.path.exists(clangbindirtarget):
|
clangbinary_targetdir = os.path.join(clang_targetdir, 'bin')
|
||||||
os.makedirs(clangbindirtarget)
|
resourcetarget = os.path.join(clang_targetdir, 'lib', 'clang')
|
||||||
clanglibdirtarget = os.path.join(install_dir, 'bin', 'clang', 'lib')
|
elif common.is_linux_platform():
|
||||||
if not os.path.exists(clanglibdirtarget):
|
clang_targetdir = os.path.join(qtc_binary_path, '..', 'libexec', 'qtcreator', 'clang')
|
||||||
os.makedirs(clanglibdirtarget)
|
clangbinary_targetdir = os.path.join(clang_targetdir, 'bin')
|
||||||
for binary in ['clangd', 'clang-tidy', 'clazy-standalone', 'clang-format']:
|
resourcetarget = os.path.join(clang_targetdir, 'lib', 'clang')
|
||||||
binary_filepath = os.path.join(llvm_install_dir, 'bin', binary + '.exe')
|
# ClazyPlugin. On RHEL ClazyPlugin is in lib64, so check both
|
||||||
if os.path.exists(binary_filepath):
|
clanglibs_targetdir = os.path.join(clang_targetdir, 'lib')
|
||||||
deployinfo.append((binary_filepath, clangbindirtarget))
|
|
||||||
resourcetarget = os.path.join(clanglibdirtarget, 'clang')
|
|
||||||
else:
|
|
||||||
# clang binaries -> clang libexec
|
|
||||||
clangbinary_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'bin')
|
|
||||||
if not os.path.exists(clangbinary_targetdir):
|
|
||||||
os.makedirs(clangbinary_targetdir)
|
|
||||||
for binary in ['clangd', 'clang-tidy', 'clazy-standalone', 'clang-format']:
|
|
||||||
binary_filepath = os.path.join(llvm_install_dir, 'bin', binary)
|
|
||||||
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)))
|
|
||||||
clanglibs_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'lib')
|
|
||||||
# support libraries (for clazy) -> clang libexec
|
|
||||||
if not os.path.exists(clanglibs_targetdir):
|
if not os.path.exists(clanglibs_targetdir):
|
||||||
os.makedirs(clanglibs_targetdir)
|
os.makedirs(clanglibs_targetdir)
|
||||||
# on RHEL ClazyPlugin is in lib64
|
|
||||||
for lib_pattern in ['lib64/ClazyPlugin.so', 'lib/ClazyPlugin.so']:
|
for lib_pattern in ['lib64/ClazyPlugin.so', 'lib/ClazyPlugin.so']:
|
||||||
for lib in glob(os.path.join(llvm_install_dir, lib_pattern)):
|
for lib in glob(os.path.join(llvm_install_dir, lib_pattern)):
|
||||||
deployinfo.append((lib, clanglibs_targetdir))
|
deployinfo.append((lib, clanglibs_targetdir))
|
||||||
resourcetarget = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'lib', 'clang')
|
else:
|
||||||
|
clang_targetdir = os.path.join(qtc_binary_path, 'Contents', 'Resources', 'libexec', 'clang')
|
||||||
|
clanglibs_targetdir = os.path.join(clang_targetdir, 'lib')
|
||||||
|
clangbinary_targetdir = os.path.join(clang_targetdir, 'bin')
|
||||||
|
resourcetarget = os.path.join(clang_targetdir, 'lib', 'clang')
|
||||||
|
# ClazyPlugin
|
||||||
|
clanglibs_targetdir = os.path.join(clang_targetdir, 'lib')
|
||||||
|
if not os.path.exists(clanglibs_targetdir):
|
||||||
|
os.makedirs(clanglibs_targetdir)
|
||||||
|
clazy_plugin = os.path.join(llvm_install_dir, 'lib', 'ClazyPlugin.dylib')
|
||||||
|
deployinfo.append((clazy_plugin, clanglibs_targetdir))
|
||||||
|
|
||||||
|
# collect binaries
|
||||||
|
if not os.path.exists(clangbinary_targetdir):
|
||||||
|
os.makedirs(clangbinary_targetdir)
|
||||||
|
for binary in ['clangd', 'clang-tidy', 'clazy-standalone', 'clang-format']:
|
||||||
|
binary_filepath = os.path.join(llvm_install_dir, 'bin', with_exe_ext(binary))
|
||||||
|
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 not common.is_windows_platform() and 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)))
|
||||||
|
|
||||||
print("copying clang...")
|
|
||||||
for source, target in deployinfo:
|
for source, target in deployinfo:
|
||||||
print(source, '->', target)
|
print(source, '->', target)
|
||||||
copyPreservingLinks(source, target)
|
copyPreservingLinks(source, target)
|
||||||
@@ -318,7 +323,6 @@ def deploy_clang(install_dir, llvm_install_dir, chrpath_bin):
|
|||||||
# libclang was statically compiled, so there is no need for the RPATHs
|
# libclang was statically compiled, so there is no need for the RPATHs
|
||||||
# and they are confusing when fixing RPATHs later in the process.
|
# and they are confusing when fixing RPATHs later in the process.
|
||||||
# Also fix clazy-standalone RPATH.
|
# Also fix clazy-standalone RPATH.
|
||||||
print("fixing Clang RPATHs...")
|
|
||||||
for source, target in deployinfo:
|
for source, target in deployinfo:
|
||||||
filename = os.path.basename(source)
|
filename = os.path.basename(source)
|
||||||
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, filename)
|
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, filename)
|
||||||
@@ -328,6 +332,12 @@ def deploy_clang(install_dir, llvm_install_dir, chrpath_bin):
|
|||||||
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, os.path.basename(source))
|
targetfilepath = target if not os.path.isdir(target) else os.path.join(target, os.path.basename(source))
|
||||||
subprocess.check_call([chrpath_bin, '-d', targetfilepath])
|
subprocess.check_call([chrpath_bin, '-d', targetfilepath])
|
||||||
|
|
||||||
|
if common.is_mac_platform():
|
||||||
|
# fix RPATH of clazy-standalone
|
||||||
|
clazy_dest = os.path.join(clangbinary_targetdir, 'clazy-standalone')
|
||||||
|
subprocess.call(['xcrun', 'install_name_tool', '-add_rpath', '@loader_path/../lib', clazy_dest], stderr=subprocess.DEVNULL)
|
||||||
|
subprocess.call(['xcrun', 'install_name_tool', '-delete_rpath', '/Users/qt/work/build/libclang/lib', clazy_dest], stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
print(resourcesource, '->', resourcetarget)
|
print(resourcesource, '->', resourcetarget)
|
||||||
if (os.path.exists(resourcetarget)):
|
if (os.path.exists(resourcetarget)):
|
||||||
shutil.rmtree(resourcetarget)
|
shutil.rmtree(resourcetarget)
|
||||||
@@ -428,6 +438,8 @@ def main():
|
|||||||
deploy_imports(qtcreator_binary_path, qt_install)
|
deploy_imports(qtcreator_binary_path, qt_install)
|
||||||
deploy_translations(qtcreator_binary_path, qt_install)
|
deploy_translations(qtcreator_binary_path, qt_install)
|
||||||
deploy_qt_conf_files(qtcreator_binary_path)
|
deploy_qt_conf_files(qtcreator_binary_path)
|
||||||
|
if args.llvm_path:
|
||||||
|
deploy_clang(qtcreator_binary_path, args.llvm_path, chrpath_bin)
|
||||||
|
|
||||||
if common.is_mac_platform():
|
if common.is_mac_platform():
|
||||||
deploy_mac(args)
|
deploy_mac(args)
|
||||||
@@ -444,9 +456,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
copy_qt_libs(qt_deploy_prefix, qt_install.bin, qt_install.lib)
|
copy_qt_libs(qt_deploy_prefix, qt_install.bin, qt_install.lib)
|
||||||
|
|
||||||
if args.llvm_path:
|
|
||||||
deploy_clang(install_dir, args.llvm_path, chrpath_bin)
|
|
||||||
|
|
||||||
if args.elfutils_path:
|
if args.elfutils_path:
|
||||||
deploy_elfutils(install_dir, chrpath_bin, args)
|
deploy_elfutils(install_dir, chrpath_bin, args)
|
||||||
if not common.is_windows_platform():
|
if not common.is_windows_platform():
|
||||||
|
|||||||
@@ -7,35 +7,11 @@
|
|||||||
[ $(uname -s) != "Darwin" ] && echo "Run this script on Mac OS X" && exit 2;
|
[ $(uname -s) != "Darwin" ] && echo "Run this script on Mac OS X" && exit 2;
|
||||||
|
|
||||||
app_path="$1"
|
app_path="$1"
|
||||||
resource_path="$app_path/Contents/Resources"
|
|
||||||
libexec_path="$app_path/Contents/Resources/libexec"
|
libexec_path="$app_path/Contents/Resources/libexec"
|
||||||
bin_src="$2"
|
bin_src="$2"
|
||||||
|
|
||||||
echo "Deploying Qt"
|
echo "Deploying Qt"
|
||||||
|
|
||||||
# copy clang if needed
|
|
||||||
if [ $LLVM_INSTALL_DIR ]; then
|
|
||||||
if [ "$LLVM_INSTALL_DIR"/bin/clangd -nt "$libexec_path"/clang/bin/clangd ]; then
|
|
||||||
echo "- Copying clang"
|
|
||||||
mkdir -p "$app_path/Contents/Frameworks" || exit 1
|
|
||||||
# use recursive copy to make it copy symlinks as symlinks
|
|
||||||
mkdir -p "$libexec_path/clang/bin"
|
|
||||||
mkdir -p "$libexec_path/clang/lib"
|
|
||||||
cp -Rf "$LLVM_INSTALL_DIR"/lib/clang "$libexec_path/clang/lib/" || exit 1
|
|
||||||
cp -Rf "$LLVM_INSTALL_DIR"/lib/ClazyPlugin.dylib "$libexec_path/clang/lib/" || exit 1
|
|
||||||
clangdsource="$LLVM_INSTALL_DIR"/bin/clangd
|
|
||||||
cp -Rf "$clangdsource" "$libexec_path/clang/bin/" || exit 1
|
|
||||||
clangtidysource="$LLVM_INSTALL_DIR"/bin/clang-tidy
|
|
||||||
cp -Rf "$clangtidysource" "$libexec_path/clang/bin/" || exit 1
|
|
||||||
clangformatsource="$LLVM_INSTALL_DIR"/bin/clang-format
|
|
||||||
cp -Rf "$clangformatsource" "$libexec_path/clang/bin/" || exit 1
|
|
||||||
clazysource="$LLVM_INSTALL_DIR"/bin/clazy-standalone
|
|
||||||
cp -Rf "$clazysource" "$libexec_path/clang/bin/" || exit 1
|
|
||||||
install_name_tool -add_rpath "@executable_path/../lib" "$libexec_path/clang/bin/clazy-standalone" 2> /dev/null
|
|
||||||
install_name_tool -delete_rpath "/Users/qt/work/build/libclang/lib" "$libexec_path/clang/bin/clazy-standalone" 2> /dev/null
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#### macdeployqt
|
#### macdeployqt
|
||||||
|
|
||||||
if [ ! -d "$app_path/Contents/Frameworks/QtCore.framework" ]; then
|
if [ ! -d "$app_path/Contents/Frameworks/QtCore.framework" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user