Bring Catalyst support back, properly forcing cross-compilation

This commit is contained in:
Frank Denis 2020-08-06 15:46:52 +02:00
parent 124605f3ae
commit 13b6bf4000

View File

@ -12,6 +12,8 @@ export WATCHOS32_PREFIX="${PREFIX}/tmp/watchos32"
export WATCHOS64_32_PREFIX="${PREFIX}/tmp/watchos64_32" export WATCHOS64_32_PREFIX="${PREFIX}/tmp/watchos64_32"
export WATCHOS_SIMULATOR_I386_PREFIX="${PREFIX}/tmp/watchos-simulator-i386" export WATCHOS_SIMULATOR_I386_PREFIX="${PREFIX}/tmp/watchos-simulator-i386"
export WATCHOS_SIMULATOR_X86_64_PREFIX="${PREFIX}/tmp/watchos-simulator-x86_64" export WATCHOS_SIMULATOR_X86_64_PREFIX="${PREFIX}/tmp/watchos-simulator-x86_64"
export CATALYST_ARM64_PREFIX="${PREFIX}/tmp/catalyst-arm64"
export CATALYST_X86_64_PREFIX="${PREFIX}/tmp/catalyst-x86_64"
export LOG_FILE="${PREFIX}/tmp/build_log" export LOG_FILE="${PREFIX}/tmp/build_log"
export XCODEDIR="$(xcode-select -p)" export XCODEDIR="$(xcode-select -p)"
@ -173,6 +175,32 @@ build_watchos_simulator() {
make -j${PROCESSORS} install || exit 1 make -j${PROCESSORS} install || exit 1
} }
build_catalyst() {
export BASEDIR="${XCODEDIR}/Platforms/MacOSX.platform/Developer"
export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH"
export SDK="${BASEDIR}/SDKs/MacOSX.sdk"
## arm64 catalyst
if [ "$(arch)" = "arm64" ]; then
export CFLAGS="-O2 -arch arm64 -target arm64-apple-ios13.0-macabi -isysroot ${SDK}"
export LDFLAGS="-arch arm64 -target arm64-apple-ios13.0-macabi -isysroot ${SDK}"
make distclean >/dev/null 2>&1
./configure --host=arm-apple-ios --prefix="$CATALYST_ARM64_PREFIX" \
${LIBSODIUM_ENABLE_MINIMAL_FLAG} || exit 1
make -j${PROCESSORS} install || exit 1
fi
## x86_64 catalyst
export CFLAGS="-O2 -arch x86_64 -target x86_64-apple-ios13.0-macabi -isysroot ${SDK}"
export LDFLAGS="-arch x86_64 -target x86_64-apple-ios13.0-macabi -isysroot ${SDK}"
make distclean >/dev/null 2>&1
./configure --host=x86_64-apple-ios --prefix="$CATALYST_X86_64_PREFIX" \
${LIBSODIUM_ENABLE_MINIMAL_FLAG} || exit 1
make -j${PROCESSORS} install || exit 1
}
mkdir -p "${PREFIX}/tmp" mkdir -p "${PREFIX}/tmp"
echo "Building for macOS..." echo "Building for macOS..."
build_macos >"$LOG_FILE" 2>&1 || exit 1 build_macos >"$LOG_FILE" 2>&1 || exit 1
@ -184,6 +212,8 @@ echo "Building for watchOS..."
build_watchos >"$LOG_FILE" 2>&1 || exit 1 build_watchos >"$LOG_FILE" 2>&1 || exit 1
echo "Building for the watchOS simulator..." echo "Building for the watchOS simulator..."
build_watchos_simulator >"$LOG_FILE" 2>&1 || exit 1 build_watchos_simulator >"$LOG_FILE" 2>&1 || exit 1
echo "Building for Catalyst..."
build_catalyst >"$LOG_FILE" 2>&1 || exit 1
echo "Adding the Clibsodium module map for Swift..." echo "Adding the Clibsodium module map for Swift..."
@ -253,12 +283,29 @@ for ext in a dylib; do
-output "${PREFIX}/watchos-simulators/lib/libsodium.${ext}" -output "${PREFIX}/watchos-simulators/lib/libsodium.${ext}"
done done
echo "Bundling Catalyst targets..."
mkdir -p "${PREFIX}/catalyst/lib"
cp -a "${CATALYST_X86_64_PREFIX}/include" "${PREFIX}/catalyst/"
for ext in a dylib; do
if [ "$(arch)" = "arm64" ]; then
lipo -create \
"${CATALYST_ARM64_PREFIX}/lib/libsodium.${ext}" \
"${CATALYST_X86_64_PREFIX}/lib/libsodium.${ext}" \
-output "${PREFIX}/catalyst/lib/libsodium.${ext}"
else
lipo -create \
"${CATALYST_X86_64_PREFIX}/lib/libsodium.${ext}" \
-output "${PREFIX}/catalyst/lib/libsodium.${ext}"
fi
done
echo "Creating Clibsodium.xcframework..." echo "Creating Clibsodium.xcframework..."
rm -rf "${PREFIX}/Clibsodium.xcframework" rm -rf "${PREFIX}/Clibsodium.xcframework"
XCFRAMEWORK_ARGS="" XCFRAMEWORK_ARGS=""
for f in macos ios ios-simulators watchos watchos-simulators; do for f in macos ios ios-simulators watchos watchos-simulators catalyst; do
XCFRAMEWORK_ARGS="${XCFRAMEWORK_ARGS} -library ${PREFIX}/${f}/lib/libsodium.a" XCFRAMEWORK_ARGS="${XCFRAMEWORK_ARGS} -library ${PREFIX}/${f}/lib/libsodium.a"
XCFRAMEWORK_ARGS="${XCFRAMEWORK_ARGS} -headers ${PREFIX}/${f}/include" XCFRAMEWORK_ARGS="${XCFRAMEWORK_ARGS} -headers ${PREFIX}/${f}/include"
done done