diff --git a/build/build_apple_frameworks.sh b/build/build_apple_frameworks.sh index 5746adb5a1..4b50996d6b 100755 --- a/build/build_apple_frameworks.sh +++ b/build/build_apple_frameworks.sh @@ -188,7 +188,7 @@ echo "Exporting headers" mkdir -p "$HEADERS_PATH" # Set BUCK2 to the path of the buck2 executable in $OUTPUT/*/buck2-bin/buck2-* -BUCK2=$(find . -type f -path '*/buck2-bin/buck2-*' | head -n 1) +BUCK2=$(find $SOURCE_ROOT_DIR -type f -path '*/buck2-bin/buck2-*' | head -n 1) if [[ -z "$BUCK2" ]]; then echo "Could not find buck2 executable in any buck2-bin directory under $OUTPUT" BUCK2=$(which buck2) @@ -201,6 +201,20 @@ check_command "$BUCK2" //extension/tensor: \ | rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_PATH/executorch" +# HACK: XCFrameworks don't appear to support exporting any build +# options, but we need the following: +# - runtime/core/portable/type/c10 reachable with `#include ` +# - exported -DC10_USING_CUSTOM_GENERATED_MACROS compiler flag +# So, just patch our generated framework to do that. +sed -i '' '1i\ +#define C10_USING_CUSTOM_GENERATED_MACROS +' $SOURCE_ROOT_DIR/runtime/core/portable_type/c10/macros/Macros.h +sed -i '' '1i\ +#define C10_USING_CUSTOM_GENERATED_MACROS +' $SOURCE_ROOT_DIR/runtime/core/portable_type/c10/macros/Export.h +cp -r $SOURCE_ROOT_DIR/runtime/core/portable_type/c10 "$HEADERS_PATH/" + + cp "$SOURCE_ROOT_DIR/extension/apple/ExecuTorch/Exported/"*.h "$HEADERS_PATH/executorch" cp "$SOURCE_ROOT_DIR/extension/apple/ExecuTorch/Exported/"*.modulemap "$HEADERS_PATH"