.travis-upload.sh 6.2 KB

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