diff options
Diffstat (limited to '.travis/macos/upload.sh')
| -rwxr-xr-x | .travis/macos/upload.sh | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/.travis/macos/upload.sh b/.travis/macos/upload.sh new file mode 100755 index 000000000..19c80fdf0 --- /dev/null +++ b/.travis/macos/upload.sh | |||
| @@ -0,0 +1,110 @@ | |||
| 1 | #!/bin/bash -ex | ||
| 2 | |||
| 3 | . .travis/common/pre-upload.sh | ||
| 4 | |||
| 5 | REV_NAME="citra-osx-${GITDATE}-${GITREV}" | ||
| 6 | ARCHIVE_NAME="${REV_NAME}.tar.gz" | ||
| 7 | COMPRESSION_FLAGS="-czvf" | ||
| 8 | |||
| 9 | mkdir "$REV_NAME" | ||
| 10 | |||
| 11 | cp build/src/citra/citra "$REV_NAME" | ||
| 12 | cp -r build/src/citra_qt/citra-qt.app "$REV_NAME" | ||
| 13 | |||
| 14 | # move qt libs into app bundle for deployment | ||
| 15 | $(brew --prefix)/opt/qt5/bin/macdeployqt "${REV_NAME}/citra-qt.app" | ||
| 16 | |||
| 17 | # move SDL2 libs into folder for deployment | ||
| 18 | dylibbundler -b -x "${REV_NAME}/citra" -cd -d "${REV_NAME}/libs" -p "@executable_path/libs/" | ||
| 19 | |||
| 20 | # Make the changes to make the citra-qt app standalone (i.e. not dependent on the current brew installation). | ||
| 21 | # To do this, the absolute references to each and every QT framework must be re-written to point to the local frameworks | ||
| 22 | # (in the Contents/Frameworks folder). | ||
| 23 | # The "install_name_tool" is used to do so. | ||
| 24 | |||
| 25 | # Coreutils is a hack to coerce Homebrew to point to the absolute Cellar path (symlink dereferenced). i.e: | ||
| 26 | # ls -l /usr/local/opt/qt5:: /usr/local/opt/qt5 -> ../Cellar/qt5/5.6.1-1 | ||
| 27 | # grealpath ../Cellar/qt5/5.6.1-1:: /usr/local/Cellar/qt5/5.6.1-1 | ||
| 28 | brew install coreutils || brew upgrade coreutils || true | ||
| 29 | |||
| 30 | REV_NAME_ALT=$REV_NAME/ | ||
| 31 | # grealpath is located in coreutils, there is no "realpath" for OS X :( | ||
| 32 | QT_BREWS_PATH=$(grealpath "$(brew --prefix qt5)") | ||
| 33 | BREW_PATH=$(brew --prefix) | ||
| 34 | QT_VERSION_NUM=5 | ||
| 35 | |||
| 36 | $BREW_PATH/opt/qt5/bin/macdeployqt "${REV_NAME_ALT}citra-qt.app" \ | ||
| 37 | -executable="${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt" | ||
| 38 | |||
| 39 | # These are the files that macdeployqt packed into Contents/Frameworks/ - we don't want those, so we replace them. | ||
| 40 | declare -a macos_libs=("QtCore" "QtWidgets" "QtGui" "QtOpenGL" "QtPrintSupport") | ||
| 41 | |||
| 42 | for macos_lib in "${macos_libs[@]}" | ||
| 43 | do | ||
| 44 | SC_FRAMEWORK_PART=$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib | ||
| 45 | # Replace macdeployqt versions of the Frameworks with our own (from /usr/local/opt/qt5/lib/) | ||
| 46 | cp "$BREW_PATH/opt/qt5/lib/$SC_FRAMEWORK_PART" "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART" | ||
| 47 | |||
| 48 | # Replace references within the embedded Framework files with "internal" versions. | ||
| 49 | for macos_lib2 in "${macos_libs[@]}" | ||
| 50 | do | ||
| 51 | # Since brew references both the non-symlinked and symlink paths of QT5, it needs to be duplicated. | ||
| 52 | # /usr/local/Cellar/qt5/5.6.1-1/lib and /usr/local/opt/qt5/lib both resolve to the same files. | ||
| 53 | # So the two lines below are effectively duplicates when resolved as a path, but as strings, they aren't. | ||
| 54 | RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2 | ||
| 55 | install_name_tool -change \ | ||
| 56 | $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \ | ||
| 57 | @executable_path/../Frameworks/$RM_FRAMEWORK_PART \ | ||
| 58 | "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART" | ||
| 59 | install_name_tool -change \ | ||
| 60 | "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \ | ||
| 61 | @executable_path/../Frameworks/$RM_FRAMEWORK_PART \ | ||
| 62 | "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$SC_FRAMEWORK_PART" | ||
| 63 | done | ||
| 64 | done | ||
| 65 | |||
| 66 | # Handles `This application failed to start because it could not find or load the Qt platform plugin "cocoa"` | ||
| 67 | # Which manifests itself as: | ||
| 68 | # "Exception Type: EXC_CRASH (SIGABRT) | Exception Codes: 0x0000000000000000, 0x0000000000000000 | Exception Note: EXC_CORPSE_NOTIFY" | ||
| 69 | # There may be more dylibs needed to be fixed... | ||
| 70 | declare -a macos_plugins=("Plugins/platforms/libqcocoa.dylib") | ||
| 71 | |||
| 72 | for macos_lib in "${macos_plugins[@]}" | ||
| 73 | do | ||
| 74 | install_name_tool -id @executable_path/../$macos_lib "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib" | ||
| 75 | for macos_lib2 in "${macos_libs[@]}" | ||
| 76 | do | ||
| 77 | RM_FRAMEWORK_PART=$macos_lib2.framework/Versions/$QT_VERSION_NUM/$macos_lib2 | ||
| 78 | install_name_tool -change \ | ||
| 79 | $QT_BREWS_PATH/lib/$RM_FRAMEWORK_PART \ | ||
| 80 | @executable_path/../Frameworks/$RM_FRAMEWORK_PART \ | ||
| 81 | "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib" | ||
| 82 | install_name_tool -change \ | ||
| 83 | "$BREW_PATH/opt/qt5/lib/$RM_FRAMEWORK_PART" \ | ||
| 84 | @executable_path/../Frameworks/$RM_FRAMEWORK_PART \ | ||
| 85 | "${REV_NAME_ALT}citra-qt.app/Contents/$macos_lib" | ||
| 86 | done | ||
| 87 | done | ||
| 88 | |||
| 89 | for macos_lib in "${macos_libs[@]}" | ||
| 90 | do | ||
| 91 | # Debugging info for Travis-CI | ||
| 92 | otool -L "${REV_NAME_ALT}citra-qt.app/Contents/Frameworks/$macos_lib.framework/Versions/$QT_VERSION_NUM/$macos_lib" | ||
| 93 | done | ||
| 94 | |||
| 95 | # Make the citra-qt.app application launch a debugging terminal. | ||
| 96 | # Store away the actual binary | ||
| 97 | mv ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt-bin | ||
| 98 | |||
| 99 | cat > ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt <<EOL | ||
| 100 | #!/usr/bin/env bash | ||
| 101 | cd "\`dirname "\$0"\`" | ||
| 102 | chmod +x citra-qt-bin | ||
| 103 | open citra-qt-bin --args "\$@" | ||
| 104 | EOL | ||
| 105 | # Content that will serve as the launching script for citra (within the .app folder) | ||
| 106 | |||
| 107 | # Make the launching script executable | ||
| 108 | chmod +x ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt | ||
| 109 | |||
| 110 | . .travis/common/post-upload.sh | ||