.travis-upload.sh 6.2 KB

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