16
16
#
17
17
# Builds and runs the tests, meant to be used on a bash environment.
18
18
19
+ usage (){
20
+ echo " Usage: $0 [options]
21
+ options:
22
+ -b, build path default: ios_unity
23
+ -s, source path default: .
24
+ -p, framework platform default: ${SUPPORTED_PLATFORMS[@]}
25
+ -a, framework architecture default: ${SUPPORTED_ARCHITECTURES[@]}
26
+ -c, cmake extra default: " "
27
+ example:
28
+ build_scripts/ios/build.sh -b ios_build -s . -a arm64"
29
+ }
30
+
31
+ set -e
32
+
33
+ readonly SUPPORTED_PLATFORMS=(device) # simulator) only support device arch for now
34
+ readonly SUPPORTED_ARCHITECTURES=" arm64;armv7" # ;x86_64;i386" only support device arch for now
35
+ # readonly DEVICE_ARCHITECTURES="arm64;armv7" only support device arch for now
36
+ # readonly SIMULATOR_ARCHITECTURES="arm64;x86_64;i386" only support device arch for now
37
+
38
+ # build default value
39
+ buildpath=" ios_unity"
40
+ sourcepath=" ."
41
+ platforms=(" ${SUPPORTED_PLATFORMS[@]} " )
42
+ cmake_extra=" "
43
+
19
44
# Enable utf8 output
20
45
export LANG=en_US.UTF-8
21
46
47
+ # check options
48
+ IFS=' ,' # split options on ',' characters
49
+ while getopts " hb:s:p:a:c:" opt; do
50
+ case $opt in
51
+ h)
52
+ usage
53
+ exit 0
54
+ ;;
55
+ b)
56
+ buildpath=$OPTARG
57
+ ;;
58
+ s)
59
+ sourcepath=$OPTARG
60
+ if [[ ! -d " ${sourcepath} " ]]; then
61
+ echo " Source path ${sourcepath} not found."
62
+ exit 2
63
+ fi
64
+ ;;
65
+ p)
66
+ platforms=($OPTARG )
67
+ for platform in ${platforms[@]} ; do
68
+ if [[ ! " ${SUPPORTED_PLATFORMS[@]} " =~ " ${platform} " ]]; then
69
+ echo " invalid platform: ${platform} "
70
+ echo " Supported platforms are: ${SUPPORTED_PLATFORMS[@]} "
71
+ exit 2
72
+ fi
73
+ done
74
+ ;;
75
+ a)
76
+ architectures=($OPTARG )
77
+ for arch in ${architectures[@]} ; do
78
+ if [[ ! " ${SUPPORTED_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
79
+ echo " invalid architecture: ${arch} "
80
+ echo " Supported architectures are: ${SUPPORTED_ARCHITECTURES[@]} "
81
+ exit 2
82
+ fi
83
+ done
84
+ ;;
85
+ c)
86
+ cmake_extra=$OPTARG
87
+ ;;
88
+ * )
89
+ echo " unknown parameter"
90
+ exit 2
91
+ ;;
92
+ esac
93
+ done
94
+ echo " *********************** Build Unity iOS SDK *******************************"
95
+ echo " build path: ${buildpath} "
96
+ echo " source path: ${sourcepath} "
97
+ echo " build platforms: ${platforms[@]} "
98
+ echo " cmake extras: ${cmake_extra} "
99
+ echo " ***************************************************************************"
100
+ sourcepath=$( cd ${sourcepath} && pwd) # full path
101
+ buildpath=$( mkdir -p ${buildpath} && cd ${buildpath} && pwd) # full path
102
+
22
103
# Stop display commands being run.
23
104
set +x
24
105
@@ -42,23 +123,16 @@ CMAKE_OPTIONS="${CMAKE_OPTIONS} -DUNITY_ROOT_DIR=${UNITY_ROOT_DIR}"
42
123
CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_UNITY_BUILD_TESTS=ON"
43
124
CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_CPP_BUILD_STUB_TESTS=ON" # enable a stub gtest target to get abseil-cpp working.
44
125
45
- printf " #################################################################\n"
46
- date
47
- printf " Building config 'unity' on platform 'ios' with option ''.\n"
48
- printf " #################################################################\n"
49
-
50
- DIR=ios_unity
51
-
52
126
# Display commands being run.
53
127
set -x
54
128
55
129
# Make a directory to work in (if doesn't exist)
56
- mkdir -p " $DIR "
130
+ mkdir -p " $buildpath "
57
131
58
- pushd " $DIR "
132
+ pushd " $buildpath "
59
133
60
134
# Configure cmake with option value
61
- cmake -DCMAKE_TOOLCHAIN_FILE=.. /cmake/unity_ios.cmake .. ${CMAKE_OPTIONS}
135
+ cmake ${sourcepath} -DCMAKE_TOOLCHAIN_FILE=${sourcepath} /cmake/unity_ios.cmake -DCMAKE_OSX_ARCHITECTURES= $SUPPORTED_ARCHITECTURES ${CMAKE_OPTIONS} ${cmake_extra }
62
136
check_exit_code $?
63
137
64
138
# Build the SDK
0 commit comments