.travis-upload.sh 6.0 KB

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