Skip to content

Commit 9368831

Browse files
committed
Switch from print_exported_headers to CMake's installed headers in scripts/build_apple_frameworks.sh
This removes the need to use Buck in this script. The previous PR (#13485) adds enforcement that we don't install non-public headers from CMake. I built the frameworks before and after. Here is a diff of all headers present in the frameworks: https://gist.github.com/swolchok/70647b551da7827a9cbdb083fad1e209 Generally, we now include more headers than before. The only header we used to include that we no longer include is schema/extended_header.h. It looks like we are not including the rest of the headers for the PTE schema anyway, so I propose that we fix installation of the schema headers separately. ghstack-source-id: 626397b ghstack-comment-id: 3207551649 Pull-Request: #13559
1 parent e72486b commit 9368831

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

scripts/build_apple_frameworks.sh

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ PRESETS_RELATIVE_OUT_DIR=("ios" "simulator" "macos")
1515
SOURCE_ROOT_DIR=$(git rev-parse --show-toplevel)
1616
OUTPUT_DIR="${SOURCE_ROOT_DIR}/cmake-out"
1717

18-
BUCK2=$(python3 "$SOURCE_ROOT_DIR/tools/cmake/resolve_buck.py" --cache_dir="$SOURCE_ROOT_DIR/buck2-bin")
19-
if [[ "$BUCK2" == "buck2" ]]; then
20-
BUCK2=$(command -v buck2)
21-
fi
22-
2318
FRAMEWORK_EXECUTORCH_NAME="executorch"
2419
FRAMEWORK_EXECUTORCH_MODULE_NAME="ExecuTorch"
2520
FRAMEWORK_EXECUTORCH_HEADERS_DIR="${FRAMEWORK_EXECUTORCH_NAME}_include"
@@ -208,10 +203,14 @@ fi
208203
echo "Building libraries"
209204

210205
rm -rf "${OUTPUT_DIR}"
206+
mkdir -p "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
211207
for preset_index in "${!PRESETS[@]}"; do
212208
preset="${PRESETS[$preset_index]}"
213209
preset_output_dir="${OUTPUT_DIR}/${PRESETS_RELATIVE_OUT_DIR[$preset_index]}"
214-
210+
do_install=""
211+
if [[ "${preset}" == "macos" ]]; then
212+
do_install="--target install"
213+
fi
215214
for mode in "${MODES[@]}"; do
216215
echo "Building preset ${preset} (${mode}) in ${preset_output_dir}..."
217216

@@ -221,25 +220,24 @@ for preset_index in "${!PRESETS[@]}"; do
221220
--fresh \
222221
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${preset_output_dir}" \
223222
-DCMAKE_BUILD_TYPE="${mode}" \
223+
-DCMAKE_INSTALL_PREFIX="${preset_output_dir}" \
224224
${CMAKE_OPTIONS_OVERRIDE[@]:-} \
225225
--preset "${preset}"
226226

227227
cmake --build "${preset_output_dir}" \
228-
--config "${mode}"
228+
--config "${mode}" ${do_install}
229229
done
230+
if [[ "${preset}" == "macos" ]]; then
231+
find "${preset_output_dir}/include/executorch" -name '*.h' \
232+
| sort | sed -e "s|${preset_output_dir}/include/executorch/||" \
233+
| rsync -av --files-from=- "${preset_output_dir}/include/executorch" "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
234+
fi
230235
done
231236

232237
echo "Exporting headers"
233238

234239
# FRAMEWORK_EXECUTORCH
235240

236-
mkdir -p "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
237-
238-
"$SOURCE_ROOT_DIR"/scripts/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
239-
//extension/module: \
240-
//extension/tensor: \
241-
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
242-
243241
# HACK: XCFrameworks don't appear to support exporting any build
244242
# options, but we need the following:
245243
# - runtime/core/portable/type/c10 reachable with `#include <c10/...>`

0 commit comments

Comments
 (0)