.travis-upload.sh 6.1 KB

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