2019-09-11 19:27:06 +03:00
|
|
|
#!/bin/sh
|
|
|
|
|
2024-05-30 00:03:49 +03:00
|
|
|
# The expected iOS build invocation is:
|
|
|
|
# build-ios.sh [clean] [release|debug] ${ARCH} ${PLATFORM}
|
|
|
|
# where
|
|
|
|
# ARCH = arm64|arm64e|x86_64
|
|
|
|
# PLATFORM = iphoneos|iphonesimulator|xros|xrsimulator
|
|
|
|
|
2020-05-06 21:58:41 +03:00
|
|
|
if [ "$1" == "clean" ]; then
|
2024-05-30 00:03:49 +03:00
|
|
|
echo "build-ios.sh: cleaning previous build artifacts"
|
|
|
|
rm -f CMakeCache.txt *.cmake
|
|
|
|
rm -rf out
|
|
|
|
rm -rf .buildtools
|
|
|
|
# make clean
|
|
|
|
shift
|
2020-05-06 21:58:41 +03:00
|
|
|
fi
|
|
|
|
|
2019-09-11 19:27:06 +03:00
|
|
|
BUILD_TYPE="Debug"
|
2024-05-30 00:03:49 +03:00
|
|
|
if [ "$1" == "release" ]; then
|
|
|
|
BUILD_TYPE="Release"
|
|
|
|
shift
|
|
|
|
elif [ "$1" == "debug" ]; then
|
|
|
|
BUILD_TYPE="Debug"
|
|
|
|
shift
|
2019-09-11 19:27:06 +03:00
|
|
|
fi
|
|
|
|
|
2021-02-05 00:15:53 +03:00
|
|
|
# Set Architecture: arm64, arm64e or x86_64
|
2024-05-30 00:03:49 +03:00
|
|
|
IOS_ARCH=$(/usr/bin/uname -m)
|
|
|
|
if [ "$1" == "arm64" ]; then
|
|
|
|
IOS_ARCH="arm64"
|
|
|
|
shift
|
|
|
|
elif [ "$1" == "arm64e" ]; then
|
|
|
|
IOS_ARCH="arm64e"
|
|
|
|
shift
|
|
|
|
elif [ "$1" == "x86_64" ]; then
|
|
|
|
IOS_ARCH="x86_64"
|
|
|
|
shift
|
2020-02-05 01:27:51 +03:00
|
|
|
fi
|
|
|
|
|
2024-05-30 00:03:49 +03:00
|
|
|
# the last param is expected to specify the platform name: iphoneos|iphonesimulator|xros|xrsimulator
|
|
|
|
# so if it is non-empty and it is not "device", we take it as a valid platform name
|
|
|
|
# otherwise we fall back to old iOS logic which only supported iphoneos|iphonesimulator
|
2021-02-05 00:15:53 +03:00
|
|
|
IOS_PLAT="iphonesimulator"
|
2024-05-30 00:03:49 +03:00
|
|
|
if [ -n "$1" ] && [ "$1" != "device" ]; then
|
|
|
|
IOS_PLAT="$1"
|
|
|
|
elif [ "$1" == "device" ]; then
|
|
|
|
IOS_PLAT="iphoneos"
|
2021-02-05 00:15:53 +03:00
|
|
|
fi
|
|
|
|
|
2024-05-30 00:03:49 +03:00
|
|
|
echo "IOS_ARCH = $IOS_ARCH, IOS_PLAT = $IOS_PLAT, BUILD_TYPE = $BUILD_TYPE"
|
|
|
|
|
|
|
|
FORCE_RESET_DEPLOYMENT_TARGET=NO
|
|
|
|
DEPLOYMENT_TARGET=""
|
|
|
|
|
|
|
|
if [ "$IOS_PLAT" == "iphoneos" ] || [ "$IOS_PLAT" == "iphonesimulator" ]; then
|
|
|
|
SYS_NAME="iOS"
|
|
|
|
DEPLOYMENT_TARGET="$IOS_DEPLOYMENT_TARGET"
|
|
|
|
if [ -z "$DEPLOYMENT_TARGET" ]; then
|
|
|
|
DEPLOYMENT_TARGET="10.0"
|
|
|
|
FORCE_RESET_DEPLOYMENT_TARGET=YES
|
|
|
|
fi
|
|
|
|
elif [ "$IOS_PLAT" == "xros" ] || [ "$IOS_PLAT" == "xrsimulator" ]; then
|
|
|
|
SYS_NAME="visionOS"
|
|
|
|
DEPLOYMENT_TARGET="$XROS_DEPLOYMENT_TARGET"
|
|
|
|
if [ -z "$DEPLOYMENT_TARGET" ]; then
|
|
|
|
DEPLOYMENT_TARGET="1.0"
|
|
|
|
FORCE_RESET_DEPLOYMENT_TARGET=YES
|
|
|
|
fi
|
2023-01-28 10:43:03 +03:00
|
|
|
fi
|
2024-05-30 00:03:49 +03:00
|
|
|
|
|
|
|
echo "deployment target = $DEPLOYMENT_TARGET"
|
|
|
|
echo "force reset deployment target = $FORCE_RESET_DEPLOYMENT_TARGET"
|
2020-02-05 01:27:51 +03:00
|
|
|
|
2019-09-11 19:27:06 +03:00
|
|
|
# Install build tools and recent sqlite3
|
2024-05-30 00:03:49 +03:00
|
|
|
FILE=".buildtools"
|
2019-09-11 19:27:06 +03:00
|
|
|
if [ ! -f $FILE ]; then
|
2020-05-06 21:58:41 +03:00
|
|
|
tools/setup-buildtools-apple.sh ios
|
2024-05-30 00:03:49 +03:00
|
|
|
# Assume that the build tools have been successfully installed
|
|
|
|
echo > $FILE
|
2019-09-11 19:27:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /usr/bin/gcc ]; then
|
2024-05-30 00:03:49 +03:00
|
|
|
echo "gcc version: `gcc --version`"
|
2019-09-11 19:27:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -f /usr/bin/clang ]; then
|
2024-05-30 00:03:49 +03:00
|
|
|
echo "clang version: `clang --version`"
|
2019-09-11 19:27:06 +03:00
|
|
|
fi
|
|
|
|
|
|
|
|
mkdir -p out
|
|
|
|
cd out
|
|
|
|
|
2019-09-26 19:59:33 +03:00
|
|
|
CMAKE_PACKAGE_TYPE=tgz
|
|
|
|
|
2024-05-30 00:03:49 +03:00
|
|
|
cmake_cmd="cmake -DCMAKE_OSX_SYSROOT=$IOS_PLAT -DCMAKE_SYSTEM_NAME=$SYS_NAME -DCMAKE_IOS_ARCH_ABI=$IOS_ARCH -DCMAKE_OSX_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DBUILD_IOS=YES -DIOS_ARCH=$IOS_ARCH -DIOS_PLAT=$IOS_PLAT -DIOS_DEPLOYMENT_TARGET=$DEPLOYMENT_TARGET -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_PACKAGE_TYPE=$CMAKE_PACKAGE_TYPE -DFORCE_RESET_DEPLOYMENT_TARGET=$FORCE_RESET_DEPLOYMENT_TARGET $CMAKE_OPTS .."
|
|
|
|
echo "${cmake_cmd}"
|
2022-07-30 00:04:39 +03:00
|
|
|
eval $cmake_cmd
|
|
|
|
|
2019-09-11 19:27:06 +03:00
|
|
|
make
|
|
|
|
|
|
|
|
make package
|