2022-12-01 14:08:43 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$#" -ne 6 ]; then
|
|
|
|
echo "usage <BASE_DIR> <TEMP_DIRECTORY> <OUTPUT_DIRECTORY> <ENTITLEMENTS_FILE_PATH> <VERSION> <SOURCE_REVISION_ID>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-03-12 17:21:21 +01:00
|
|
|
mkdir -p "$1"
|
|
|
|
mkdir -p "$2"
|
|
|
|
mkdir -p "$3"
|
|
|
|
|
|
|
|
BASE_DIR=$(readlink -f "$1")
|
|
|
|
TEMP_DIRECTORY=$(readlink -f "$2")
|
|
|
|
OUTPUT_DIRECTORY=$(readlink -f "$3")
|
|
|
|
ENTITLEMENTS_FILE_PATH=$(readlink -f "$4")
|
2022-12-01 14:08:43 +01:00
|
|
|
VERSION=$5
|
|
|
|
SOURCE_REVISION_ID=$6
|
|
|
|
|
|
|
|
RELEASE_TAR_FILE_NAME=Ryujinx-$VERSION-macos_universal.app.tar
|
2023-03-12 17:21:21 +01:00
|
|
|
ARM64_APP_BUNDLE="$TEMP_DIRECTORY/output_arm64/Ryujinx.app"
|
|
|
|
X64_APP_BUNDLE="$TEMP_DIRECTORY/output_x64/Ryujinx.app"
|
|
|
|
UNIVERSAL_APP_BUNDLE="$OUTPUT_DIRECTORY/Ryujinx.app"
|
2022-12-01 14:08:43 +01:00
|
|
|
EXECUTABLE_SUB_PATH=Contents/MacOS/Ryujinx
|
|
|
|
|
2023-03-12 17:21:21 +01:00
|
|
|
rm -rf "$TEMP_DIRECTORY"
|
|
|
|
mkdir -p "$TEMP_DIRECTORY"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
2023-02-25 12:30:48 +01:00
|
|
|
DOTNET_COMMON_ARGS="-p:DebugType=embedded -p:Version=$VERSION -p:SourceRevisionId=$SOURCE_REVISION_ID --self-contained true"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
dotnet restore
|
2023-04-28 10:14:44 +02:00
|
|
|
dotnet build -c Release src/Ryujinx.Ava
|
|
|
|
dotnet publish -c Release -r osx-arm64 -o "$TEMP_DIRECTORY/publish_arm64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava
|
|
|
|
dotnet publish -c Release -r osx-x64 -o "$TEMP_DIRECTORY/publish_x64" $DOTNET_COMMON_ARGS src/Ryujinx.Ava
|
2022-12-01 14:08:43 +01:00
|
|
|
|
2023-04-28 10:14:44 +02:00
|
|
|
# Get rid of the support library for ARMeilleure for x64 (that's only for arm64)
|
2023-03-12 17:21:21 +01:00
|
|
|
rm -rf "$TEMP_DIRECTORY/publish_x64/libarmeilleure-jitsupport.dylib"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
2023-04-28 10:14:44 +02:00
|
|
|
# Get rid of libsoundio from arm64 builds as we don't have a arm64 variant
|
2022-12-01 14:08:43 +01:00
|
|
|
# TODO: remove this once done
|
2023-03-12 17:21:21 +01:00
|
|
|
rm -rf "$TEMP_DIRECTORY/publish_arm64/libsoundio.dylib"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
2023-03-12 17:21:21 +01:00
|
|
|
pushd "$BASE_DIR/distribution/macos"
|
|
|
|
./create_app_bundle.sh "$TEMP_DIRECTORY/publish_x64" "$TEMP_DIRECTORY/output_x64" "$ENTITLEMENTS_FILE_PATH"
|
|
|
|
./create_app_bundle.sh "$TEMP_DIRECTORY/publish_arm64" "$TEMP_DIRECTORY/output_arm64" "$ENTITLEMENTS_FILE_PATH"
|
2022-12-01 14:08:43 +01:00
|
|
|
popd
|
|
|
|
|
2023-03-12 17:21:21 +01:00
|
|
|
rm -rf "$UNIVERSAL_APP_BUNDLE"
|
|
|
|
mkdir -p "$OUTPUT_DIRECTORY"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
# Let's copy one of the two different app bundle and remove the executable
|
2023-03-12 17:21:21 +01:00
|
|
|
cp -R "$ARM64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE"
|
|
|
|
rm "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
# Make it libraries universal
|
2023-03-12 17:21:21 +01:00
|
|
|
python3 "$BASE_DIR/distribution/macos/construct_universal_dylib.py" "$ARM64_APP_BUNDLE" "$X64_APP_BUNDLE" "$UNIVERSAL_APP_BUNDLE" "**/*.dylib"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
if ! [ -x "$(command -v lipo)" ];
|
|
|
|
then
|
|
|
|
if ! [ -x "$(command -v llvm-lipo-14)" ];
|
|
|
|
then
|
|
|
|
LIPO=llvm-lipo
|
|
|
|
else
|
|
|
|
LIPO=llvm-lipo-14
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
LIPO=lipo
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make it the executable universal
|
2023-03-12 17:21:21 +01:00
|
|
|
$LIPO "$ARM64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" "$X64_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -output "$UNIVERSAL_APP_BUNDLE/$EXECUTABLE_SUB_PATH" -create
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
# Patch up the Info.plist to have appropriate version
|
2023-03-12 17:21:21 +01:00
|
|
|
sed -r -i.bck "s/\%\%RYUJINX_BUILD_VERSION\%\%/$VERSION/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist"
|
|
|
|
sed -r -i.bck "s/\%\%RYUJINX_BUILD_GIT_HASH\%\%/$SOURCE_REVISION_ID/g;" "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist"
|
|
|
|
rm "$UNIVERSAL_APP_BUNDLE/Contents/Info.plist.bck"
|
2022-12-01 14:08:43 +01:00
|
|
|
|
|
|
|
# Now sign it
|
|
|
|
if ! [ -x "$(command -v codesign)" ];
|
|
|
|
then
|
|
|
|
if ! [ -x "$(command -v rcodesign)" ];
|
|
|
|
then
|
|
|
|
echo "Cannot find rcodesign on your system, please install rcodesign."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# NOTE: Currently require https://github.com/indygreg/apple-platform-rs/pull/44 to work on other OSes.
|
|
|
|
# cargo install --git "https://github.com/marysaka/apple-platform-rs" --branch "fix/adhoc-app-bundle" apple-codesign --bin "rcodesign"
|
|
|
|
echo "Usign rcodesign for ad-hoc signing"
|
2023-03-12 17:21:21 +01:00
|
|
|
rcodesign sign --entitlements-xml-path "$ENTITLEMENTS_FILE_PATH" "$UNIVERSAL_APP_BUNDLE"
|
2022-12-01 14:08:43 +01:00
|
|
|
else
|
|
|
|
echo "Usign codesign for ad-hoc signing"
|
2023-03-12 17:21:21 +01:00
|
|
|
codesign --entitlements "$ENTITLEMENTS_FILE_PATH" -f --deep -s - "$UNIVERSAL_APP_BUNDLE"
|
2022-12-01 14:08:43 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Creating archive"
|
2023-03-12 17:21:21 +01:00
|
|
|
pushd "$OUTPUT_DIRECTORY"
|
2022-12-01 14:08:43 +01:00
|
|
|
tar --exclude "Ryujinx.app/Contents/MacOS/Ryujinx" -cvf $RELEASE_TAR_FILE_NAME Ryujinx.app 1> /dev/null
|
2023-03-12 17:21:21 +01:00
|
|
|
python3 "$BASE_DIR/distribution/misc/add_tar_exec.py" $RELEASE_TAR_FILE_NAME "Ryujinx.app/Contents/MacOS/Ryujinx" "Ryujinx.app/Contents/MacOS/Ryujinx"
|
2022-12-01 14:08:43 +01:00
|
|
|
gzip -9 < $RELEASE_TAR_FILE_NAME > $RELEASE_TAR_FILE_NAME.gz
|
|
|
|
rm $RELEASE_TAR_FILE_NAME
|
|
|
|
popd
|
|
|
|
|
2023-04-28 10:14:44 +02:00
|
|
|
echo "Done"
|