@@ -9,6 +9,8 @@ set -euxo pipefail
9
9
10
10
MODES=(" Release" " Debug" )
11
11
PRESETS=(" 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" )
12
14
13
15
SOURCE_ROOT_DIR=$( git rev-parse --show-toplevel)
14
16
OUTPUT_DIR=" ${SOURCE_ROOT_DIR} /cmake-out"
@@ -142,20 +144,22 @@ done
142
144
echo " Building libraries"
143
145
144
146
rm -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
+
146
151
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} ..."
149
153
150
154
# Do NOT add options here. Update the respective presets instead.
151
155
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 } " \
154
158
-DCMAKE_BUILD_TYPE=" ${mode} " \
155
159
${CMAKE_OPTIONS_OVERRIDE[@]:- } \
156
160
--preset " ${preset} "
157
161
158
- cmake --build " ${output_dir } " \
162
+ cmake --build " ${preset_output_dir } " \
159
163
--config " ${mode} " \
160
164
-j$( sysctl -n hw.ncpu)
161
165
done
@@ -220,9 +224,9 @@ append_framework_flag() {
220
224
221
225
for mode in " ${MODES[@]} " ; do
222
226
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} " )
226
230
done
227
231
228
232
append_framework_flag " " " $FRAMEWORK_EXECUTORCH " " $mode "
240
244
241
245
echo " Cleaning up"
242
246
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} "
245
249
done
246
250
247
251
rm -rf " $HEADERS_ABSOLUTE_PATH "
0 commit comments