77
88set -euo pipefail
99
10- PLATFORMS=(" iphoneos" " iphonesimulator" )
11- PLATFORM_FLAGS=(" OS" " SIMULATOR" )
10+ PLATFORMS=(" ios" " simulator" " macos" )
11+ PLATFORM_FLAGS=(" OS64" " SIMULATORARM64" " MAC_ARM64" )
12+ PLATFORM_TARGET=(" 17.0" " 17.0" " 10.15" )
1213SOURCE_ROOT_DIR=" "
1314OUTPUT=" cmake-out"
1415MODE=" Release"
1516TOOLCHAIN=" "
16- BUCK2=" buck2"
17+ BUCK2=$( which buck2)
1718PYTHON=$( which python3)
18- FLATC=" flatc"
19- IOS_DEPLOYMENT_TARGET=" 17.0"
19+ FLATC=$( which flatc)
2020COREML=OFF
2121CUSTOM=OFF
2222MPS=OFF
@@ -42,10 +42,10 @@ usage() {
4242 echo " Options:"
4343 echo " --output=DIR Output directory. Default: 'cmake-out'"
4444 echo " --Debug Use Debug build mode. Default: 'Release'"
45- echo " --toolchain=FILE Cmake toolchain file. Default: '\$ SOURCE_ROOT_DIR/third-party/pytorch/ cmake/iOS .cmake'"
46- echo " --buck2=FILE Buck2 executable path. Default: '/tmp/ buck2' "
45+ echo " --toolchain=FILE Cmake toolchain file. Default: '\$ SOURCE_ROOT_DIR/third-party/ios- cmake/ios.toolchain .cmake'"
46+ echo " --buck2=FILE Buck2 executable path. Default: Path of buck2 found in the current \$ PATH "
4747 echo " --python=FILE Python executable path. Default: Path of python3 found in the current \$ PATH"
48- echo " --flatc=FILE FlatBuffers Compiler executable path. Default: ' \$ SOURCE_ROOT_DIR/third-party/flatbuffers/cmake-out/flatc' "
48+ echo " --flatc=FILE FlatBuffers Compiler executable path. Default: Path of flatc found in the current \$ PATH "
4949 echo " --coreml Include this flag to build the Core ML backend."
5050 echo " --custom Include this flag to build the Custom backend."
5151 echo " --mps Include this flag to build the Metal Performance Shaders backend."
@@ -68,7 +68,6 @@ for arg in "$@"; do
6868 --buck2=* ) BUCK2=" ${arg#* =} " ;;
6969 --python=* ) PYTHON=" ${arg#* =} " ;;
7070 --flatc=* ) FLATC=" ${arg#* =} " ;;
71- --ios-deployment-target=* ) IOS_DEPLOYMENT_TARGET=" ${arg#* =} " ;;
7271 --coreml) COREML=ON ;;
7372 --custom) CUSTOM=ON ;;
7473 --mps) MPS=ON ;;
@@ -92,14 +91,10 @@ if [[ -z "$SOURCE_ROOT_DIR" ]]; then
9291fi
9392
9493if [[ -z " $TOOLCHAIN " ]]; then
95- TOOLCHAIN=" $SOURCE_ROOT_DIR /third-party/pytorch/ cmake/iOS .cmake"
94+ TOOLCHAIN=" $SOURCE_ROOT_DIR /third-party/ios- cmake/ios.toolchain .cmake"
9695fi
9796[[ -f " $TOOLCHAIN " ]] || { echo >&2 " Toolchain file $TOOLCHAIN does not exist." ; exit 1; }
9897
99- if [[ -z " $FLATC " ]]; then
100- FLATC=" $SOURCE_ROOT_DIR /third-party/flatbuffers/cmake-out/flatc"
101- fi
102-
10398check_command () {
10499 command -v " $1 " > /dev/null 2>&1 || { echo >&2 " $1 is not installed" ; exit 1; }
105100}
@@ -117,6 +112,7 @@ rm -rf "$OUTPUT" && mkdir -p "$OUTPUT" && cd "$OUTPUT" || exit 1
117112cmake_build () {
118113 local platform=$1
119114 local platform_flag=$2
115+ local platform_target=$3
120116 echo " Building for $platform with flag $platform_flag "
121117 mkdir " $platform " && cd " $platform " || exit 1
122118 cmake " $SOURCE_ROOT_DIR " -G Xcode \
@@ -132,20 +128,23 @@ cmake_build() {
132128 -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
133129 -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
134130 -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" $( pwd) " \
135- -DIOS_DEPLOYMENT_TARGET=" $IOS_DEPLOYMENT_TARGET " \
136131 -DEXECUTORCH_BUILD_COREML=$COREML \
137132 -DEXECUTORCH_BUILD_CUSTOM=$CUSTOM \
138133 -DEXECUTORCH_BUILD_MPS=$MPS \
139134 -DEXECUTORCH_BUILD_OPTIMIZED=$OPTIMIZED \
140135 -DEXECUTORCH_BUILD_QUANTIZED=$QUANTIZED \
141136 -DEXECUTORCH_BUILD_XNNPACK=$XNNPACK \
142- ${platform_flag: +-DIOS_PLATFORM=$platform_flag }
143- cmake --build . --config $MODE
137+ ${platform_flag: +-DPLATFORM=$platform_flag } \
138+ ${platform_target: +-DDEPLOYMENT_TARGET=$platform_target } \
139+ --log-level=VERBOSE
140+ cmake --build . \
141+ --config $MODE \
142+ --verbose
144143 cd ..
145144}
146145
147146for index in ${! PLATFORMS[*]} ; do
148- cmake_build " ${PLATFORMS[$index]} " " ${PLATFORM_FLAGS[$index]} "
147+ cmake_build " ${PLATFORMS[$index]} " " ${PLATFORM_FLAGS[$index]} " " ${PLATFORM_TARGET[$index]} "
149148done
150149
151150echo " Exporting headers"
0 commit comments