1616#
1717# Builds and runs the tests, meant to be used on a bash environment.
1818
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+ example:
27+ build_scripts/ios/build.sh -b ios_build -s . -a arm64"
28+ }
29+
30+ set -e
31+
32+ readonly SUPPORTED_PLATFORMS=(device) # simulator) only support device arch for now
33+ readonly SUPPORTED_ARCHITECTURES=" arm64;armv7" # ;x86_64;i386" only support device arch for now
34+ # readonly DEVICE_ARCHITECTURES="arm64;armv7" only support device arch for now
35+ # readonly SIMULATOR_ARCHITECTURES="arm64;x86_64;i386" only support device arch for now
36+
37+ # build default value
38+ buildpath=" ios_unity"
39+ sourcepath=" ."
40+ platforms=(" ${SUPPORTED_PLATFORMS[@]} " )
41+
1942# Enable utf8 output
2043export LANG=en_US.UTF-8
2144
45+ # check options
46+ IFS=' ,' # split options on ',' characters
47+ while getopts " :b:s:a" opt; do
48+ case $opt in
49+ h)
50+ usage
51+ exit 0
52+ ;;
53+ b)
54+ buildpath=$OPTARG
55+ ;;
56+ s)
57+ sourcepath=$OPTARG
58+ if [[ ! -d " ${sourcepath} " ]]; then
59+ echo " Source path ${sourcepath} not found."
60+ exit 2
61+ fi
62+ ;;
63+ p)
64+ platforms=($OPTARG )
65+ for platform in ${platforms[@]} ; do
66+ if [[ ! " ${SUPPORTED_PLATFORMS[@]} " =~ " ${platform} " ]]; then
67+ echo " invalid platform: ${platform} "
68+ echo " Supported platforms are: ${SUPPORTED_PLATFORMS[@]} "
69+ exit 2
70+ fi
71+ done
72+ ;;
73+ a)
74+ architectures=($OPTARG )
75+ for arch in ${architectures[@]} ; do
76+ if [[ ! " ${SUPPORTED_ARCHITECTURES[@]} " =~ " ${arch} " ]]; then
77+ echo " invalid architecture: ${arch} "
78+ echo " Supported architectures are: ${SUPPORTED_ARCHITECTURES[@]} "
79+ exit 2
80+ fi
81+ done
82+ ;;
83+ * )
84+ echo " unknown parameter"
85+ exit 2
86+ ;;
87+ esac
88+ done
89+ echo " *********************** Build Unity iOS SDK *******************************"
90+ echo " build path: ${buildpath} "
91+ echo " source path: ${sourcepath} "
92+ echo " build platforms: ${platforms[@]} "
93+ echo " ***************************************************************************"
94+ sourcepath=$( cd ${sourcepath} && pwd) # full path
95+ buildpath=$( mkdir -p ${buildpath} && cd ${buildpath} && pwd) # full path
96+
2297# Stop display commands being run.
2398set +x
2499
@@ -42,23 +117,16 @@ CMAKE_OPTIONS="${CMAKE_OPTIONS} -DUNITY_ROOT_DIR=${UNITY_ROOT_DIR}"
42117CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_UNITY_BUILD_TESTS=ON"
43118CMAKE_OPTIONS=" ${CMAKE_OPTIONS} -DFIREBASE_CPP_BUILD_STUB_TESTS=ON" # enable a stub gtest target to get abseil-cpp working.
44119
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-
52120# Display commands being run.
53121set -x
54122
55123# Make a directory to work in (if doesn't exist)
56- mkdir -p " $DIR "
124+ mkdir -p " $buildpath "
57125
58- pushd " $DIR "
126+ pushd " $buildpath "
59127
60128 # Configure cmake with option value
61- cmake -DCMAKE_TOOLCHAIN_FILE=.. /cmake/unity_ios.cmake .. ${CMAKE_OPTIONS}
129+ cmake -DCMAKE_TOOLCHAIN_FILE=${sourcepath} /cmake/unity_ios.cmake -DCMAKE_OSX_ARCHITECTURES= $SUPPORTED_ARCHITECTURES .. ${CMAKE_OPTIONS}
62130 check_exit_code $?
63131
64132 # Build the SDK
0 commit comments