diff options
-rw-r--r-- | Swift/Packaging/appimage/build_appimage.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/Swift/Packaging/appimage/build_appimage.py b/Swift/Packaging/appimage/build_appimage.py index e188c4f..b49ef7f 100644 --- a/Swift/Packaging/appimage/build_appimage.py +++ b/Swift/Packaging/appimage/build_appimage.py @@ -19,4 +19,6 @@ # Pass `--qt5=False` to the tool to build against legacy Qt4. +# +# To include newer libstdc++.so or similar libs in an AppImage, use -li parameters. -from plumbum import local, FG, BG, colors, commands +from plumbum import local, FG, BG, RETCODE, colors, commands import click @@ -40,3 +42,4 @@ resources_dir = os.path.join(git_working_dir, "Swift/resources/") @click.option('--qt5', default=True, type=bool, help='Build with Qt5.') -def build_appimage(qt5): +@click.option('--includelib', '-il', type=click.Path(), multiple=True, help='Copy extra library into AppImage.') +def build_appimage(qt5, includelib): print(colors.bold & colors.info | "Switch to git working directory root " + git_working_dir) @@ -55,3 +58,3 @@ def build_appimage(qt5): print(colors.bold & colors.info | "Building Swift") - scons['qt5={}'.format("1" if qt5 else "0"), 'Swift'] & FG + scons['qt5={0}'.format("1" if qt5 else "0"), 'Swift'] & FG @@ -78,3 +81,3 @@ def build_appimage(qt5): print(colors.bold & colors.info | "Install Swift to AppDir") - scons['qt5={}'.format("1" if qt5 else "0"), 'Swift', 'SWIFT_INSTALLDIR=' + swift_install_dir , swift_install_dir] & FG + scons['qt5={0}'.format("1" if qt5 else "0"), 'Swift', 'SWIFT_INSTALLDIR=' + swift_install_dir , swift_install_dir] & FG @@ -119,2 +122,7 @@ def build_appimage(qt5): + if includelib: + for includelib_path in includelib: + print(colors.bold & colors.info | "Copy " + includelib_path + " to AppDir.") + local['cp']('-v', '-L', includelib_path, os.path.join(swift_install_dir, "lib")) + print(colors.bold & colors.info | "Download https://github.com/AppImage/AppImageKit/raw/appimagetool/master/resources/AppRun to " + os.path.join(appdir_path, 'AppRun')) @@ -134,3 +142,8 @@ def build_appimage(qt5): print(colors.bold & colors.info | "Download appimagetool to /tmp/appimagetool and make it executable") - local['wget']['-O', '/tmp/appimagetool', 'https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-' + ("x86_64.AppImage" if swift_architecture_string == ".amd64": else "i686.AppImage")] & FG + appimage_url_suffix = "" + if swift_architecture_string == ".amd64": + appimage_url_suffix = "x86_64.AppImage" + else: + appimage_url_suffix = "i686.AppImage" + local['wget']['-O', '/tmp/appimagetool', 'https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-' + appimage_url_suffix] & FG local['chmod']['a+x', '/tmp/appimagetool']() @@ -144,3 +157,5 @@ def build_appimage(qt5): local['strip']('-g', appdir_swift_im_binary) - local['objcopy']('--add-gnu-debuglink', debug_symbol_path, os.path.join(swift_install_dir, 'bin/swift-im')) + debuglink_retcode = local['objcopy']['--add-gnu-debuglink', debug_symbol_path, os.path.join(swift_install_dir, 'bin/swift-im')] & RETCODE + if debuglink_retcode != 0: + print(colors.bold & colors.warn | "Failed to create debuglink in binary.") |