@@ -14,23 +14,25 @@ PRESETS_RELATIVE_OUT_DIR=("ios" "simulator" "macos")
1414
1515SOURCE_ROOT_DIR=$( git rev-parse --show-toplevel)
1616OUTPUT_DIR=" ${SOURCE_ROOT_DIR} /cmake-out"
17- HEADERS_RELATIVE_PATH=" include"
18- HEADERS_ABSOLUTE_PATH=" ${OUTPUT_DIR} /${HEADERS_RELATIVE_PATH} "
1917
2018BUCK2=$( python3 " $SOURCE_ROOT_DIR /tools/cmake/resolve_buck.py" --cache_dir=" $SOURCE_ROOT_DIR /buck2-bin" )
2119if [[ " $BUCK2 " == " buck2" ]]; then
2220 BUCK2=$( command -v buck2)
2321fi
2422
25- FRAMEWORK_EXECUTORCH=" executorch:\
23+ FRAMEWORK_EXECUTORCH_NAME=" executorch"
24+ FRAMEWORK_EXECUTORCH_MODULE_NAME=" ExecuTorch"
25+ FRAMEWORK_EXECUTORCH_HEADERS_DIR=" ${FRAMEWORK_EXECUTORCH_NAME} _include"
26+ FRAMEWORK_EXECUTORCH_HEADERS_PATH=" ${OUTPUT_DIR} /${FRAMEWORK_EXECUTORCH_HEADERS_DIR} "
27+ FRAMEWORK_EXECUTORCH=" ${FRAMEWORK_EXECUTORCH_NAME} :\
2628libexecutorch.a,\
2729libexecutorch_core.a,\
2830libextension_apple.a,\
2931libextension_data_loader.a,\
3032libextension_flat_tensor.a,\
3133libextension_module.a,\
3234libextension_tensor.a,\
33- :$HEADERS_RELATIVE_PATH :ExecuTorch "
35+ :${FRAMEWORK_EXECUTORCH_HEADERS_DIR} : ${FRAMEWORK_EXECUTORCH_MODULE_NAME} "
3436
3537FRAMEWORK_THREADPOOL=" threadpool:\
3638libcpuinfo.a,\
@@ -169,12 +171,12 @@ done
169171
170172echo " Exporting headers"
171173
172- mkdir -p " $HEADERS_ABSOLUTE_PATH "
174+ mkdir -p " $FRAMEWORK_EXECUTORCH_HEADERS_PATH / $FRAMEWORK_EXECUTORCH_MODULE_NAME "
173175
174176" $SOURCE_ROOT_DIR " /scripts/print_exported_headers.py --buck2=$( realpath " $BUCK2 " ) --targets \
175177 //extension/module: \
176178 //extension/tensor: \
177- | rsync -av --files-from=- " $SOURCE_ROOT_DIR " " $HEADERS_ABSOLUTE_PATH /executorch "
179+ | rsync -av --files-from=- " $SOURCE_ROOT_DIR " " $FRAMEWORK_EXECUTORCH_HEADERS_PATH / $FRAMEWORK_EXECUTORCH_MODULE_NAME "
178180
179181# HACK: XCFrameworks don't appear to support exporting any build
180182# options, but we need the following:
@@ -184,18 +186,18 @@ mkdir -p "$HEADERS_ABSOLUTE_PATH"
184186sed -i ' ' ' 1i\
185187#define C10_USING_CUSTOM_GENERATED_MACROS
186188' \
187- " $HEADERS_ABSOLUTE_PATH /executorch/runtime/core/portable_type/c10/c10/macros/Macros.h" \
188- " $HEADERS_ABSOLUTE_PATH /executorch/runtime/core/portable_type/c10/c10/macros/Export.h" \
189- " $HEADERS_ABSOLUTE_PATH /executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h"
189+ " $FRAMEWORK_EXECUTORCH_HEADERS_PATH /executorch/runtime/core/portable_type/c10/c10/macros/Macros.h" \
190+ " $FRAMEWORK_EXECUTORCH_HEADERS_PATH /executorch/runtime/core/portable_type/c10/c10/macros/Export.h" \
191+ " $FRAMEWORK_EXECUTORCH_HEADERS_PATH /executorch/runtime/core/portable_type/c10/torch/headeronly/macros/Export.h"
190192
191- cp -r $HEADERS_ABSOLUTE_PATH /executorch/runtime/core/portable_type/c10/c10 " $HEADERS_ABSOLUTE_PATH /"
192- cp -r $HEADERS_ABSOLUTE_PATH /executorch/runtime/core/portable_type/c10/torch " $HEADERS_ABSOLUTE_PATH /"
193+ cp -r $FRAMEWORK_EXECUTORCH_HEADERS_PATH /executorch/runtime/core/portable_type/c10/c10 " $FRAMEWORK_EXECUTORCH_HEADERS_PATH /"
194+ cp -r $FRAMEWORK_EXECUTORCH_HEADERS_PATH /executorch/runtime/core/portable_type/c10/torch " $FRAMEWORK_EXECUTORCH_HEADERS_PATH /"
193195
194- cp " $SOURCE_ROOT_DIR /extension/apple/ExecuTorch /Exported/" * .h " $HEADERS_ABSOLUTE_PATH /executorch "
196+ cp " $SOURCE_ROOT_DIR /extension/apple/$FRAMEWORK_EXECUTORCH_MODULE_NAME /Exported/" * .h " $FRAMEWORK_EXECUTORCH_HEADERS_PATH / $FRAMEWORK_EXECUTORCH_MODULE_NAME "
195197
196- cat > " $HEADERS_ABSOLUTE_PATH / module.modulemap" << ' EOF '
197- module ExecuTorch {
198- umbrella header "ExecuTorch/ExecuTorch .h"
198+ cat > " $FRAMEWORK_EXECUTORCH_HEADERS_PATH / $FRAMEWORK_EXECUTORCH_MODULE_NAME / module.modulemap" << EOF
199+ module ${FRAMEWORK_EXECUTORCH_MODULE_NAME} {
200+ umbrella header "${FRAMEWORK_EXECUTORCH_MODULE_NAME} .h"
199201 export *
200202}
201203EOF
@@ -252,7 +254,7 @@ for preset_out_dir in "${PRESETS_RELATIVE_OUT_DIR[@]}"; do
252254 rm -rf " ${OUTPUT_DIR} /${preset_out_dir} "
253255done
254256
255- rm -rf " $HEADERS_ABSOLUTE_PATH "
257+ rm -rf " $FRAMEWORK_EXECUTORCH_HEADERS_PATH "
256258
257259echo " Running tests"
258260
0 commit comments