Skip to content

Commit

Permalink
chore: Add support for iphone simulator on arm64.
Browse files Browse the repository at this point in the history
  • Loading branch information
iphydf committed Jan 28, 2025
1 parent 83eb381 commit 96e87eb
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion qtox/build_opus.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "opus" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s ios-i386 ios-x86_64" "$@"
parse_arch --dep "opus" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s iphonesimulator-arm64 iphonesimulator-x86_64" "$@"

if [ "$LIB_TYPE" = "shared" ]; then
ENABLE_STATIC=--disable-static
Expand Down
2 changes: 1 addition & 1 deletion qtox/build_sodium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "sodium" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s ios-i386 ios-x86_64" "$@"
parse_arch --dep "sodium" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s iphonesimulator-arm64 iphonesimulator-x86_64" "$@"

if [ "$LIB_TYPE" = "shared" ]; then
ENABLE_STATIC=--disable-static
Expand Down
19 changes: 13 additions & 6 deletions qtox/build_utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,19 @@ parse_arch() {
DEP_PREFIX="${DEP_PREFIX:-/work}"
mkdir -p "$DEP_PREFIX"
HOST_OPTION="--host=arm64-apple-darwin"
if [ "$ARCH" = "i386" ] || [ "$ARCH" = "x86_64" ]; then
XC_SDK="iphonesimulator"
else
XC_SDK="iphoneos"
fi
IOS_FLAGS="-miphoneos-version-min=$IOS_MINIMUM_SUPPORTED_VERSION -arch $ARCH -isysroot $(xcrun --sdk "$XC_SDK" --show-sdk-path)"
IOS_FLAGS="-miphoneos-version-min=$IOS_MINIMUM_SUPPORTED_VERSION -arch $ARCH -isysroot $(xcrun --sdk iphoneos --show-sdk-path)"
CROSS_LDFLAG="$IOS_FLAGS"
CROSS_CFLAG="$IOS_FLAGS"
CROSS_CPPFLAG="$IOS_FLAGS"
CROSS_CXXFLAG="$IOS_FLAGS"
MAKE_JOBS="$(sysctl -n hw.ncpu)"
CMAKE_TOOLCHAIN_FILE=""
elif [[ "$SCRIPT_ARCH" == "iphonesimulator-"* ]]; then
ARCH="${SCRIPT_ARCH#iphonesimulator-}"
DEP_PREFIX="${DEP_PREFIX:-/work}"
mkdir -p "$DEP_PREFIX"
HOST_OPTION="--host=arm64-apple-darwin"
IOS_FLAGS="-arch $ARCH -isysroot $(xcrun --sdk iphonesimulator --show-sdk-path)"
CROSS_LDFLAG="$IOS_FLAGS"
CROSS_CFLAG="$IOS_FLAGS"
CROSS_CPPFLAG="$IOS_FLAGS"
Expand Down
9 changes: 5 additions & 4 deletions qtox/build_vpx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ readonly SCRIPT_DIR="$(dirname "$(realpath "$0")")"

source "$SCRIPT_DIR/build_utils.sh"

parse_arch --dep "vpx" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s ios-i386 ios-x86_64" "$@"
parse_arch --dep "vpx" --supported "linux-aarch64 linux-x86_64 win32 win64 macos-x86_64 macos-arm64 ios-arm64 ios-armv7 ios-armv7s iphonesimulator-arm64 iphonesimulator-x86_64" "$@"

if [ "$SCRIPT_ARCH" == "win64" ]; then
# There is a bug in gcc that breaks avx512 on 64-bit Windows https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54412
Expand Down Expand Up @@ -44,11 +44,11 @@ elif [ "$SCRIPT_ARCH" == "ios-armv7s" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="armv7s-darwin-gcc"
elif [ "$SCRIPT_ARCH" == "ios-i386" ]; then
elif [ "$SCRIPT_ARCH" == "iphonesimulator-arm64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="x86-iphonesimulator-gcc"
elif [ "$SCRIPT_ARCH" == "ios-x86_64" ]; then
TARGET_ARG="arm64-iphonesimulator-gcc"
elif [ "$SCRIPT_ARCH" == "iphonesimulator-x86_64" ]; then
ARCH_FLAGS=""
CROSS_ARG=""
TARGET_ARG="x86_64-iphonesimulator-gcc"
Expand All @@ -75,6 +75,7 @@ fi

"$SCRIPT_DIR/download/download_vpx.sh"

patch -p1 < "$SCRIPT_DIR/patches/vpx.patch"
CFLAGS="-O2 $ARCH_FLAGS $CROSS_CFLAG" \
CXXFLAGS="-O2 $CROSS_CXXFLAG" \
LDFLAGS="$CROSS_LDFLAG" \
Expand Down
24 changes: 24 additions & 0 deletions qtox/patches/vpx.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --color -u -r external/vpx/build/make/configure.sh vpx/build/make/configure.sh
--- external/vpx/build/make/configure.sh 2024-10-23 19:24:57
+++ vpx/build/make/configure.sh 2025-01-28 01:05:32
@@ -996,8 +996,6 @@
add_ldflags "-arch ${toolchain%%-*}"
;;
*-iphonesimulator-*)
- add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
- add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
iossim_sdk_dir="$(show_darwin_sdk_path iphonesimulator)"
if [ -d "${iossim_sdk_dir}" ]; then
add_cflags "-isysroot ${iossim_sdk_dir}"
diff --color -u -r external/vpx/configure vpx/configure
--- external/vpx/configure 2024-10-23 19:24:57
+++ vpx/configure 2025-01-28 01:03:20
@@ -141,7 +141,7 @@
all_platforms="${all_platforms} x86-darwin15-gcc"
all_platforms="${all_platforms} x86-darwin16-gcc"
all_platforms="${all_platforms} x86-darwin17-gcc"
-all_platforms="${all_platforms} x86-iphonesimulator-gcc"
+all_platforms="${all_platforms} arm64-iphonesimulator-gcc"
all_platforms="${all_platforms} x86-linux-gcc"
all_platforms="${all_platforms} x86-linux-icc"
all_platforms="${all_platforms} x86-os2-gcc"

0 comments on commit 96e87eb

Please sign in to comment.