@@ -120,28 +120,28 @@ set_cmake_options_override() {
120120
121121for arg in " $@ " ; do
122122 case $arg in
123- -h| --help) usage ;;
124- --Release)
125- if [[ ! " ${MODES[*]:- } " =~ \b Release\b ]]; then
126- MODES+=(" Release" )
127- fi
128- ;;
129- --Debug)
130- if [[ ! " ${MODES[*]:- } " =~ \b Debug\b ]]; then
131- MODES+=(" Debug" )
132- fi
133- ;;
134- --coreml) set_cmake_options_override " EXECUTORCH_BUILD_COREML" ;;
135- --custom) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_CUSTOM" ;;
136- --mps) set_cmake_options_override " EXECUTORCH_BUILD_MPS" ;;
137- --optimized) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_OPTIMIZED" ;;
138- --quantized) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_QUANTIZED" ;;
139- --xnnpack) set_cmake_options_override " EXECUTORCH_BUILD_XNNPACK" ;;
140- --torchao) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_TORCHAO" ;;
141- * )
142- echo -e " \033[31m[error] unknown option: ${arg} \033[0m"
143- exit 1
144- ;;
123+ -h | --help) usage ;;
124+ --Release)
125+ if [[ ! " ${MODES[*]:- } " =~ \b Release\b ]]; then
126+ MODES+=(" Release" )
127+ fi
128+ ;;
129+ --Debug)
130+ if [[ ! " ${MODES[*]:- } " =~ \b Debug\b ]]; then
131+ MODES+=(" Debug" )
132+ fi
133+ ;;
134+ --coreml) set_cmake_options_override " EXECUTORCH_BUILD_COREML" ;;
135+ --custom) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_CUSTOM" ;;
136+ --mps) set_cmake_options_override " EXECUTORCH_BUILD_MPS" ;;
137+ --optimized) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_OPTIMIZED" ;;
138+ --quantized) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_QUANTIZED" ;;
139+ --xnnpack) set_cmake_options_override " EXECUTORCH_BUILD_XNNPACK" ;;
140+ --torchao) set_cmake_options_override " EXECUTORCH_BUILD_KERNELS_TORCHAO" ;;
141+ * )
142+ echo -e " \033[31m[error] unknown option: ${arg} \033[0m"
143+ exit 1
144+ ;;
145145 esac
146146done
147147
@@ -152,59 +152,20 @@ for preset_index in "${!PRESETS[@]}"; do
152152 preset=" ${PRESETS[$preset_index]} "
153153 preset_output_dir=" ${OUTPUT_DIR} /${PRESETS_RELATIVE_OUT_DIR[$preset_index]} "
154154
155- cmake_build () {
156- local platform=$1
157- local platform_flag=$2
158- local platform_target=$3
159- local mode=$4
160- echo " Building for $platform ($mode ) with flag $platform_flag "
161- mkdir -p " $platform " && cd " $platform " || exit 1
162- cmake " $SOURCE_ROOT_DIR " -G Xcode \
163- -DCMAKE_BUILD_TYPE=" $mode " \
164- -DCMAKE_TOOLCHAIN_FILE=" $TOOLCHAIN " \
165- -DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD=" c++17" \
166- -DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY=" libc++" \
167- -DCMAKE_C_FLAGS=" -ffile-prefix-map=$SOURCE_ROOT_DIR =/executorch -fdebug-prefix-map=$SOURCE_ROOT_DIR =/executorch" \
168- -DCMAKE_CXX_FLAGS=" -ffile-prefix-map=$SOURCE_ROOT_DIR =/executorch -fdebug-prefix-map=$SOURCE_ROOT_DIR =/executorch" \
169- -DPYTHON_EXECUTABLE=" $PYTHON " \
170- -DEXECUTORCH_BUILD_COREML=$COREML \
171- -DEXECUTORCH_BUILD_MPS=$MPS \
172- -DEXECUTORCH_BUILD_XNNPACK=$XNNPACK \
173- -DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
174- -DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
175- -DEXECUTORCH_BUILD_EXTENSION_APPLE=ON \
176- -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
177- -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
178- -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
179- -DEXECUTORCH_BUILD_KERNELS_CUSTOM=$CUSTOM \
180- -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=$OPTIMIZED \
181- -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=$QUANTIZED \
182- -DEXECUTORCH_BUILD_KERNELS_TORCHAO=$TORCHAO \
183- -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" $( pwd) " \
184- ${platform_flag: +-DPLATFORM=$platform_flag } \
185- ${platform_target: +-DDEPLOYMENT_TARGET=$platform_target } \
186- --log-level=VERBOSE
187- cmake --build . \
188- --config " $mode " \
189- --verbose
190- cd -
191- }
192-
193- for index in ${! PLATFORMS[*]} ; do
194155 for mode in " ${MODES[@]} " ; do
195156 echo " Building preset ${preset} (${mode} ) in ${preset_output_dir} ..."
196157
197158 # Do NOT add options here. Update the respective presets instead.
198159 cmake -S " ${SOURCE_ROOT_DIR} " \
199- -B " ${preset_output_dir} " \
200- -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" ${preset_output_dir} " \
201- -DCMAKE_BUILD_TYPE=" ${mode} " \
202- ${CMAKE_OPTIONS_OVERRIDE[@]:- } \
203- --preset " ${preset} "
160+ -B " ${preset_output_dir} " \
161+ -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" ${preset_output_dir} " \
162+ -DCMAKE_BUILD_TYPE=" ${mode} " \
163+ ${CMAKE_OPTIONS_OVERRIDE[@]:- } \
164+ --preset " ${preset} "
204165
205166 cmake --build " ${preset_output_dir} " \
206- --config " ${mode} " \
207- -j$( sysctl -n hw.ncpu)
167+ --config " ${mode} " \
168+ -j$( sysctl -n hw.ncpu)
208169 done
209170done
210171
@@ -214,8 +175,8 @@ mkdir -p "$HEADERS_ABSOLUTE_PATH"
214175
215176" $SOURCE_ROOT_DIR " /scripts/print_exported_headers.py --buck2=$( realpath " $BUCK2 " ) --targets \
216177 //extension/module: \
217- //extension/tensor: \
218- | rsync -av --files-from=- " $SOURCE_ROOT_DIR " " $HEADERS_ABSOLUTE_PATH /executorch"
178+ //extension/tensor: |
179+ rsync -av --files-from=- " $SOURCE_ROOT_DIR " " $HEADERS_ABSOLUTE_PATH /executorch"
219180
220181# HACK: XCFrameworks don't appear to support exporting any build
221182# options, but we need the following:
@@ -234,7 +195,7 @@ cp -r $HEADERS_ABSOLUTE_PATH/executorch/runtime/core/portable_type/c10/torch "$H
234195
235196cp " $SOURCE_ROOT_DIR /extension/apple/ExecuTorch/Exported/" * .h " $HEADERS_ABSOLUTE_PATH /executorch"
236197
237- cat > " $HEADERS_ABSOLUTE_PATH /module.modulemap" << 'EOF '
198+ cat > " $HEADERS_ABSOLUTE_PATH /module.modulemap" << 'EOF '
238199module ExecuTorch {
239200 umbrella header "ExecuTorch/ExecuTorch.h"
240201 export *
@@ -258,10 +219,10 @@ append_framework_flag() {
258219 fi
259220
260221 if [[ -n " $mode " && " $mode " != " Release" ]]; then
261- local name spec
262- name=$( echo " $framework " | cut -d: -f1)
263- spec=$( echo " $framework " | cut -d: -f2-)
264- framework=" ${name} _$( echo " $mode " | tr ' [:upper:]' ' [:lower:]' ) :${spec} "
222+ local name spec
223+ name=$( echo " $framework " | cut -d: -f1)
224+ spec=$( echo " $framework " | cut -d: -f2-)
225+ framework=" ${name} _$( echo " $mode " | tr ' [:upper:]' ' [:lower:]' ) :${spec} "
265226 fi
266227 echo " Adding framework: ${framework} "
267228 FRAMEWORK_FLAGS+=(" --framework=$framework " )
0 commit comments