summaryrefslogtreecommitdiff
path: root/.travis/macos/upload.sh
diff options
context:
space:
mode:
Diffstat (limited to '.travis/macos/upload.sh')
-rwxr-xr-x.travis/macos/upload.sh110
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
5REV_NAME="citra-osx-${GITDATE}-${GITREV}"
6ARCHIVE_NAME="${REV_NAME}.tar.gz"
7COMPRESSION_FLAGS="-czvf"
8
9mkdir "$REV_NAME"
10
11cp build/src/citra/citra "$REV_NAME"
12cp -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
18dylibbundler -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
28brew install coreutils || brew upgrade coreutils || true
29
30REV_NAME_ALT=$REV_NAME/
31# grealpath is located in coreutils, there is no "realpath" for OS X :(
32QT_BREWS_PATH=$(grealpath "$(brew --prefix qt5)")
33BREW_PATH=$(brew --prefix)
34QT_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.
40declare -a macos_libs=("QtCore" "QtWidgets" "QtGui" "QtOpenGL" "QtPrintSupport")
41
42for macos_lib in "${macos_libs[@]}"
43do
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
64done
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...
70declare -a macos_plugins=("Plugins/platforms/libqcocoa.dylib")
71
72for macos_lib in "${macos_plugins[@]}"
73do
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
87done
88
89for macos_lib in "${macos_libs[@]}"
90do
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"
93done
94
95# Make the citra-qt.app application launch a debugging terminal.
96# Store away the actual binary
97mv ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt-bin
98
99cat > ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt <<EOL
100#!/usr/bin/env bash
101cd "\`dirname "\$0"\`"
102chmod +x citra-qt-bin
103open citra-qt-bin --args "\$@"
104EOL
105# Content that will serve as the launching script for citra (within the .app folder)
106
107# Make the launching script executable
108chmod +x ${REV_NAME_ALT}citra-qt.app/Contents/MacOS/citra-qt
109
110. .travis/common/post-upload.sh