Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions scripts/build_apple_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ PRESETS_RELATIVE_OUT_DIR=("ios" "simulator" "macos")
SOURCE_ROOT_DIR=$(git rev-parse --show-toplevel)
OUTPUT_DIR="${SOURCE_ROOT_DIR}/cmake-out"

BUCK2=$(python3 "$SOURCE_ROOT_DIR/tools/cmake/resolve_buck.py" --cache_dir="$SOURCE_ROOT_DIR/buck2-bin")
if [[ "$BUCK2" == "buck2" ]]; then
BUCK2=$(command -v buck2)
fi

FRAMEWORK_EXECUTORCH_NAME="executorch"
FRAMEWORK_EXECUTORCH_MODULE_NAME="ExecuTorch"
FRAMEWORK_EXECUTORCH_HEADERS_DIR="${FRAMEWORK_EXECUTORCH_NAME}_include"
Expand Down Expand Up @@ -208,10 +203,14 @@ fi
echo "Building libraries"

rm -rf "${OUTPUT_DIR}"
mkdir -p "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
for preset_index in "${!PRESETS[@]}"; do
preset="${PRESETS[$preset_index]}"
preset_output_dir="${OUTPUT_DIR}/${PRESETS_RELATIVE_OUT_DIR[$preset_index]}"

do_install=""
if [[ "${preset}" == "macos" ]]; then
do_install="--target install"
fi
for mode in "${MODES[@]}"; do
echo "Building preset ${preset} (${mode}) in ${preset_output_dir}..."

Expand All @@ -221,25 +220,24 @@ for preset_index in "${!PRESETS[@]}"; do
--fresh \
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY="${preset_output_dir}" \
-DCMAKE_BUILD_TYPE="${mode}" \
-DCMAKE_INSTALL_PREFIX="${preset_output_dir}" \
${CMAKE_OPTIONS_OVERRIDE[@]:-} \
--preset "${preset}"

cmake --build "${preset_output_dir}" \
--config "${mode}"
--config "${mode}" ${do_install}
done
if [[ "${preset}" == "macos" ]]; then
find "${preset_output_dir}/include/executorch" -name '*.h' \
| sort | sed -e "s|${preset_output_dir}/include/executorch/||" \
| rsync -av --files-from=- "${preset_output_dir}/include/executorch" "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"
fi
done

echo "Exporting headers"

# FRAMEWORK_EXECUTORCH

mkdir -p "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"

"$SOURCE_ROOT_DIR"/scripts/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
//extension/module: \
//extension/tensor: \
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$FRAMEWORK_EXECUTORCH_HEADERS_PATH/$FRAMEWORK_EXECUTORCH_MODULE_NAME"

# HACK: XCFrameworks don't appear to support exporting any build
# options, but we need the following:
# - runtime/core/portable/type/c10 reachable with `#include <c10/...>`
Expand Down
Loading