@@ -9,6 +9,8 @@ set -euxo pipefail
99
1010MODES=(" Release" " Debug" )
1111PRESETS=(" ios" " ios-simulator" " macos" )
12+ # To support backwards compatibility, we want to retain the same output directory.
13+ PRESETS_RELATIVE_OUT_DIR=(" ios" " simulator" " macos" )
1214
1315SOURCE_ROOT_DIR=$( git rev-parse --show-toplevel)
1416OUTPUT_DIR=" ${SOURCE_ROOT_DIR} /cmake-out"
@@ -142,20 +144,22 @@ done
142144echo " Building libraries"
143145
144146rm -rf " ${OUTPUT_DIR} "
145- for preset in " ${PRESETS[@]} " ; do
147+ for preset_index in " ${! PRESETS[@]} " ; do
148+ preset=" ${PRESETS[$preset_index]} "
149+ preset_output_dir=" ${OUTPUT_DIR} /${PRESETS_RELATIVE_OUT_DIR[$preset_index]} "
150+
146151 for mode in " ${MODES[@]} " ; do
147- output_dir=" ${OUTPUT_DIR} /${preset} "
148- echo " Building preset ${preset} (${mode} ) in ${output_dir} ..."
152+ echo " Building preset ${preset} (${mode} ) in ${preset_output_dir} ..."
149153
150154 # Do NOT add options here. Update the respective presets instead.
151155 cmake -S " ${SOURCE_ROOT_DIR} " \
152- -B " ${output_dir } " \
153- -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" ${output_dir } " \
156+ -B " ${preset_output_dir } " \
157+ -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=" ${preset_output_dir } " \
154158 -DCMAKE_BUILD_TYPE=" ${mode} " \
155159 ${CMAKE_OPTIONS_OVERRIDE[@]:- } \
156160 --preset " ${preset} "
157161
158- cmake --build " ${output_dir } " \
162+ cmake --build " ${preset_output_dir } " \
159163 --config " ${mode} " \
160164 -j$( sysctl -n hw.ncpu)
161165 done
@@ -220,9 +224,9 @@ append_framework_flag() {
220224
221225for mode in " ${MODES[@]} " ; do
222226 FRAMEWORK_FLAGS=()
223- for preset in " ${PRESETS [@]} " ; do
224- echo " Framework directory: ${preset } /${mode} "
225- FRAMEWORK_FLAGS+=(" --directory=${preset } /${mode} " )
227+ for preset_out_dir in " ${PRESETS_RELATIVE_OUT_DIR [@]} " ; do
228+ echo " Framework directory: ${preset_out_dir } /${mode} "
229+ FRAMEWORK_FLAGS+=(" --directory=${preset_out_dir } /${mode} " )
226230 done
227231
228232 append_framework_flag " " " $FRAMEWORK_EXECUTORCH " " $mode "
240244
241245echo " Cleaning up"
242246
243- for preset in " ${PRESETS [@]} " ; do
244- rm -rf " ${OUTPUT_DIR} /${preset} / $preset "
247+ for preset_out_dir in " ${PRESETS_RELATIVE_OUT_DIR [@]} " ; do
248+ rm -rf " ${OUTPUT_DIR} /${preset_out_dir} "
245249done
246250
247251rm -rf " $HEADERS_ABSOLUTE_PATH "
0 commit comments