.travis-upload.sh 6.0 KB

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