2023-03-01 17:58:09 +00:00
|
|
|
#!/bin/bash -ex
|
|
|
|
|
|
|
|
ARTIFACTS_LIST=($ARTIFACTS)
|
|
|
|
|
2023-06-27 01:42:00 +01:00
|
|
|
BUNDLE_DIR=build/bundle
|
|
|
|
mkdir build
|
|
|
|
|
2023-03-01 17:58:09 +00:00
|
|
|
# Set up the base artifact to combine into.
|
|
|
|
BASE_ARTIFACT=${ARTIFACTS_LIST[0]}
|
|
|
|
BASE_ARTIFACT_ARCH="${BASE_ARTIFACT##*-}"
|
2023-06-27 01:42:00 +01:00
|
|
|
mv $BASE_ARTIFACT $BUNDLE_DIR
|
2023-03-01 17:58:09 +00:00
|
|
|
|
|
|
|
# Executable binary paths that need to be combined.
|
|
|
|
BIN_PATHS=(citra citra-room citra-qt.app/Contents/MacOS/citra-qt)
|
|
|
|
|
|
|
|
# Dylib paths that need to be combined.
|
|
|
|
IFS=$'\n'
|
2023-06-27 01:42:00 +01:00
|
|
|
DYLIB_PATHS=($(cd $BUNDLE_DIR && find . -name '*.dylib'))
|
2023-03-01 17:58:09 +00:00
|
|
|
unset IFS
|
|
|
|
|
|
|
|
# Combine all of the executable binaries and dylibs.
|
|
|
|
for OTHER_ARTIFACT in "${ARTIFACTS_LIST[@]:1}"; do
|
|
|
|
OTHER_ARTIFACT_ARCH="${OTHER_ARTIFACT##*-}"
|
|
|
|
|
|
|
|
for BIN_PATH in "${BIN_PATHS[@]}"; do
|
2023-06-27 01:42:00 +01:00
|
|
|
lipo -create -output $BUNDLE_DIR/$BIN_PATH $BUNDLE_DIR/$BIN_PATH $OTHER_ARTIFACT/$BIN_PATH
|
2023-03-01 17:58:09 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
for DYLIB_PATH in "${DYLIB_PATHS[@]}"; do
|
|
|
|
# Only merge if the libraries do not have conflicting arches, otherwise it will fail.
|
2023-06-27 01:42:00 +01:00
|
|
|
DYLIB_INFO=`file $BUNDLE_DIR/$DYLIB_PATH`
|
|
|
|
OTHER_DYLIB_INFO=`file $OTHER_ARTIFACT/$DYLIB_PATH`
|
2023-03-01 17:58:09 +00:00
|
|
|
if ! [[ "$DYLIB_INFO" =~ "$OTHER_ARTIFACT_ARCH" ]] && ! [[ "$OTHER_DYLIB_INFO" =~ "$BASE_ARTIFACT_ARCH" ]]; then
|
2023-06-27 01:42:00 +01:00
|
|
|
lipo -create -output $BUNDLE_DIR/$DYLIB_PATH $BUNDLE_DIR/$DYLIB_PATH $OTHER_ARTIFACT/$DYLIB_PATH
|
2023-03-01 17:58:09 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
2023-05-31 11:01:12 +01:00
|
|
|
# Re-sign executables and bundles after combining.
|
|
|
|
APP_PATHS=(citra citra-room citra-qt.app)
|
|
|
|
for APP_PATH in "${APP_PATHS[@]}"; do
|
2023-06-27 01:42:00 +01:00
|
|
|
codesign --deep -fs - $BUNDLE_DIR/$APP_PATH
|
2023-05-31 11:01:12 +01:00
|
|
|
done
|