create_macos_build_ava.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/bin/bash
  2. set -e
  3. if [ "$#" -lt 7 ]; then
  4. echo "usage <BASE_DIR> <TEMP_DIRECTORY> <OUTPUT_DIRECTORY> <ENTITLEMENTS_FILE_PATH> <VERSION> <SOURCE_REVISION_ID> <CONFIGURATION> <EXTRA_ARGS>"
  5. exit 1
  6. fi
  7. mkdir -p "$1"
  8. mkdir -p "$2"
  9. mkdir -p "$3"
  10. BASE_DIR=$(readlink -f "$1")
  11. TEMP_DIRECTORY=$(readlink -f "$2")
  12. OUTPUT_DIRECTORY=$(readlink -f "$3")
  13. ENTITLEMENTS_FILE_PATH=$(readlink -f "$4")
  14. VERSION=$5
  15. SOURCE_REVISION_ID=$6
  16. CONFIGURATION=$7
  17. EXTRA_ARGS=$8
  18. if [ "$VERSION" == "1.1.0" ];
  19. then
  20. RELEASE_TAR_FILE_NAME=ryujinx-$CONFIGURATION-$VERSION+$SOURCE_REVISION_ID-macos_universal.app.tar
  21. else
  22. RELEASE_TAR_FILE_NAME=ryujinx-$VERSION-macos_universal.app.tar
  23. fi
  24. ARM64_APP_BUNDLE="$TEMP_DIRECTORY/output_arm64/Ryujinx.app"
  25. X64_APP_BUNDLE="$TEMP_DIRECTORY/output_x64/Ryujinx.app"
  26. UNIVERSAL_APP_BUNDLE="$OUTPUT_DIRECTORY/Ryujinx.app"
  27. EXECUTABLE_SUB_PATH=Contents/MacOS/Ryujinx
  28. rm -rf "$TEMP_DIRECTORY"
  29. mkdir -p "$TEMP_DIRECTORY"
  30. DOTNET_COMMON_ARGS=(-p:DebugType=embedded -p:SourceRevisionId="$SOURCE_REVISION_ID" --self-contained true $EXTRA_ARGS)
  31. dotnet restore
  32. dotnet build -c "$CONFIGURATION" src/Ryujinx
  33. dotnet publish -c "$CONFIGURATION" -r osx-arm64 -o "$TEMP_DIRECTORY/publish_arm64" "${DOTNET_COMMON_ARGS[@]}" src/Ryujinx
  34. dotnet publish -c "$CONFIGURATION" -r osx-x64 -o "$TEMP_DIRECTORY/publish_x64" "${DOTNET_COMMON_ARGS[@]}" src/Ryujinx
  35. # Get rid of the support library for ARMeilleure for x64 (that's only for arm64)
  36. rm -rf "$TEMP_DIRECTORY/publish_x64/libarmeilleure-jitsupport.dylib"
  37. # Get rid of libsoundio from arm64 builds as we don't have a arm64 variant
  38. # TODO: remove this once done
  39. rm -rf "$TEMP_DIRECTORY/publish_arm64/libsoundio.dylib"
  40. pushd "$BASE_DIR/distribution/macos"
  41. ./create_app_bundle.sh "$TEMP_DIRECTORY/publish_x64" "$TEMP_DIRECTORY/output_x64" "$ENTITLEMENTS_FILE_PATH"
  42. ./create_app_bundle.sh "$TEMP_DIRECTORY/publish_arm64" "$TEMP_DIRECTORY/output_arm64" "$ENTITLEMENTS_FILE_PATH"
  43. popd
  44. rm -rf "$UNIVERSAL_APP_BUNDLE"
  45. mkdir -p "$OUTPUT_DIRECTORY"
  46. # Let's copy one of the two different app bundle and remove the executable
  47. cp -R "$ARM64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE"
  48. rm "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH"
  49. # Make it libraries universal
  50. python3 "$BASE_DIR/distribution/macos/construct_universal_dylib.py" "$ARM64_APP_BUNDLE" "$X64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" "**/*.dylib"
  51. if ! [ -x "$(command -v lipo)" ];
  52. then
  53. if ! [ -x "$(command -v llvm-lipo-14)" ];
  54. then
  55. LIPO=llvm-lipo
  56. else
  57. LIPO=llvm-lipo-14
  58. fi
  59. else
  60. LIPO=lipo
  61. fi
  62. # Make the executable universal
  63. $LIPO "$ARM64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" "$X64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -output "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -create
  64. # Patch up the Info.plist to have appropriate version
  65. #sed -r -i.bck "s/\%\%RYUJINX_BUILD_VERSION\%\%/$VERSION/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist"
  66. sed -r -i.bck "s/\%\%RYUJINX_BUILD_GIT_HASH\%\%/$SOURCE_REVISION_ID/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist"
  67. rm "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist.bck"
  68. # Now sign it
  69. if ! [ -x "$(command -v codesign)" ];
  70. then
  71. if ! [ -x "$(command -v rcodesign)" ];
  72. then
  73. echo "Cannot find rcodesign on your system, please install rcodesign."
  74. exit 1
  75. fi
  76. # NOTE: Currently require https://github.com/indygreg/apple-platform-rs/pull/44 to work on other OSes.
  77. # cargo install --git "https://github.com/marysaka/apple-platform-rs" --branch "fix/adhoc-app-bundle" apple-codesign --bin "rcodesign"
  78. echo "Using rcodesign for ad-hoc signing"
  79. rcodesign sign --entitlements-xml-path "$ENTITLEMENTS_FILE_PATH" "$UNIVERSAL_APP_BUNDLE"
  80. else
  81. echo "Using codesign for ad-hoc signing"
  82. codesign --entitlements "$ENTITLEMENTS_FILE_PATH" -f --deep -s - "$UNIVERSAL_APP_BUNDLE"
  83. fi
  84. echo "Creating archive"
  85. pushd "$OUTPUT_DIRECTORY"
  86. tar --exclude "Ryujinx.app/Contents/MacOS/Ryujinx" -cvf "$RELEASE_TAR_FILE_NAME" Ryujinx.app 1> /dev/null
  87. python3 "$BASE_DIR/distribution/misc/add_tar_exec.py" "$RELEASE_TAR_FILE_NAME" "Ryujinx.app/Contents/MacOS/Ryujinx" "Ryujinx.app/Contents/MacOS/Ryujinx"
  88. gzip -9 < "$RELEASE_TAR_FILE_NAME" > "$RELEASE_TAR_FILE_NAME.gz"
  89. rm "$RELEASE_TAR_FILE_NAME"
  90. # Create legacy update package for Avalonia to not left behind old testers.
  91. #if [ "$VERSION" != "1.1.0" ];
  92. #then
  93. # cp $RELEASE_TAR_FILE_NAME.gz test-ava-ryujinx-$VERSION-macos_universal.app.tar.gz
  94. #fi
  95. popd
  96. echo "Done"