-
Notifications
You must be signed in to change notification settings - Fork 53
/
build-ios.sh
executable file
·101 lines (84 loc) · 2.76 KB
/
build-ios.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/sh
# 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
if [ "$1" == "clean" ]; then
echo "build-ios.sh: cleaning previous build artifacts"
rm -f CMakeCache.txt *.cmake
rm -rf out
rm -rf .buildtools
# make clean
shift
fi
BUILD_TYPE="Debug"
if [ "$1" == "release" ]; then
BUILD_TYPE="Release"
shift
elif [ "$1" == "debug" ]; then
BUILD_TYPE="Debug"
shift
fi
# Set Architecture: arm64, arm64e or x86_64
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
fi
# 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
IOS_PLAT="iphonesimulator"
if [ -n "$1" ] && [ "$1" != "device" ]; then
IOS_PLAT="$1"
elif [ "$1" == "device" ]; then
IOS_PLAT="iphoneos"
fi
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
fi
echo "deployment target = $DEPLOYMENT_TARGET"
echo "force reset deployment target = $FORCE_RESET_DEPLOYMENT_TARGET"
# Install build tools and recent sqlite3
FILE=".buildtools"
if [ ! -f $FILE ]; then
tools/setup-buildtools-apple.sh ios
# Assume that the build tools have been successfully installed
echo > $FILE
fi
if [ -f /usr/bin/gcc ]; then
echo "gcc version: `gcc --version`"
fi
if [ -f /usr/bin/clang ]; then
echo "clang version: `clang --version`"
fi
mkdir -p out
cd out
CMAKE_PACKAGE_TYPE=tgz
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}"
eval $cmake_cmd
make
make package