upload.sh 4.7 KB

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