Skip to content

Update build framework script to skip specifying buck executable. #6004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 11 additions & 7 deletions build/build_apple_frameworks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ SOURCE_ROOT_DIR=""
OUTPUT="cmake-out"
MODE="Release"
TOOLCHAIN=""
BUCK2=$(which buck2)
PYTHON=$(which python3)
FLATC=$(which flatc)
COREML=OFF
Expand Down Expand Up @@ -79,7 +78,6 @@ usage() {
echo " --output=DIR Output directory. Default: 'cmake-out'"
echo " --Debug Use Debug build mode. Default: Uses Release build mode."
echo " --toolchain=FILE Cmake toolchain file. Default: '\$SOURCE_ROOT_DIR/third-party/ios-cmake/ios.toolchain.cmake'"
echo " --buck2=FILE Buck2 executable path. Default: Path of buck2 found in the current \$PATH"
echo " --python=FILE Python executable path. Default: Path of python3 found in the current \$PATH"
echo " --flatc=FILE FlatBuffers Compiler executable path. Default: Path of flatc found in the current \$PATH"
echo " --coreml Include this flag to build the Core ML backend."
Expand All @@ -91,7 +89,7 @@ usage() {
echo " --xnnpack Include this flag to build the XNNPACK backend."
echo
echo "Example:"
echo " $0 /path/to/source/root --output=cmake-out --toolchain=/path/to/cmake/toolchain --buck2=/path/to/buck2 --python=/path/to/python3 --coreml --mps --xnnpack"
echo " $0 /path/to/source/root --output=cmake-out --toolchain=/path/to/cmake/toolchain --python=/path/to/python3 --coreml --mps --xnnpack"
exit 0
}

Expand All @@ -101,7 +99,6 @@ for arg in "$@"; do
--output=*) OUTPUT="${arg#*=}" ;;
--Debug) MODE="Debug" ;;
--toolchain=*) TOOLCHAIN="${arg#*=}" ;;
--buck2=*) BUCK2="${arg#*=}" ;;
--python=*) PYTHON="${arg#*=}" ;;
--flatc=*) FLATC="${arg#*=}" ;;
--coreml) COREML=ON ;;
Expand Down Expand Up @@ -137,7 +134,6 @@ check_command() {

check_command cmake
check_command rsync
check_command "$BUCK2"
check_command "$PYTHON"
check_command "$FLATC"

Expand All @@ -157,7 +153,6 @@ cmake_build() {
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++17" \
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" \
-DBUCK2="$BUCK2" \
-DPYTHON_EXECUTABLE="$PYTHON" \
-DFLATC_EXECUTABLE="$FLATC" \
-DEXECUTORCH_BUILD_COREML=$COREML \
Expand Down Expand Up @@ -189,7 +184,16 @@ echo "Exporting headers"

mkdir -p "$HEADERS_PATH"

"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2="$BUCK2" --targets \
# 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)
if [[ -z "$BUCK2" ]]; then
echo "Could not find buck2 executable in any buck2-bin directory under $OUTPUT"
BUCK2=$(which buck2)
fi

check_command "$BUCK2"

"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
//extension/module: \
//extension/tensor: \
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_PATH/executorch"
Expand Down
9 changes: 1 addition & 8 deletions build/test_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ set -e

OUTPUT="${1:-executorch}"
EXIT_STATUS=0
BUCK2_RELEASE_DATE="2024-05-15"
BUCK2_ARCHIVE="buck2-aarch64-apple-darwin.zst"
BUCK2=".venv/bin/buck2"
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
MODEL_NAME="mv3"
SIMULATOR_NAME="executorch"
Expand Down Expand Up @@ -66,10 +63,6 @@ say "Installing Requirements"

pip install --upgrade cmake pip setuptools wheel zstd

curl -LO "https://github.com/facebook/buck2/releases/download/$BUCK2_RELEASE_DATE/$BUCK2_ARCHIVE"
zstd -cdq "$BUCK2_ARCHIVE" > "$BUCK2" && chmod +x "$BUCK2"
rm "$BUCK2_ARCHIVE"

./install_requirements.sh --pybind coreml mps xnnpack
export PATH="$(realpath third-party/flatbuffers/cmake-out):$PATH"
./build/install_flatc.sh
Expand Down Expand Up @@ -99,7 +92,7 @@ curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \

say "Building Frameworks"

./build/build_apple_frameworks.sh --buck2="$(realpath $BUCK2)" --coreml --custom --mps --optimized --portable --quantized --xnnpack
./build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
mv cmake-out "$APP_PATH/Frameworks"

say "Creating Simulator"
Expand Down
18 changes: 3 additions & 15 deletions docs/source/apple-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,7 @@ source .venv/bin/activate
pip install --upgrade cmake pip zstd
```

5. Install a compatible version of [Buck2](https://buck.build):

```bash
BUCK2_RELEASE_DATE="2024-05-15"
BUCK2_ARCHIVE="buck2-aarch64-apple-darwin.zst"
BUCK2=".venv/bin/buck2"

curl -LO "https://github.com/facebook/buck2/releases/download/$BUCK2_RELEASE_DATE/$BUCK2_ARCHIVE"
zstd -cdq "$BUCK2_ARCHIVE" > "$BUCK2" && chmod +x "$BUCK2"
rm "$BUCK2_ARCHIVE"
```

6. Install the required dependencies, including those needed for the backends like [Core ML](build-run-coreml.md) or [MPS](build-run-mps.md), if you plan to build them as well:
5. Install the required dependencies, including those needed for the backends like [Core ML](build-run-coreml.md) or [MPS](build-run-mps.md), if you plan to build them as well:

```bash
./install_requirements.sh
Expand All @@ -132,7 +120,7 @@ rm "$BUCK2_ARCHIVE"
./backends/apple/mps/install_requirements.sh
```

7. Use the provided script to build .xcframeworks:
6. Use the provided script to build .xcframeworks:

```bash
./build/build_apple_frameworks.sh --help
Expand All @@ -141,7 +129,7 @@ rm "$BUCK2_ARCHIVE"
For example, the following invocation will build the ExecuTorch Runtime and all currently available kernels and backends for the Apple platform:

```bash
./build/build_apple_frameworks.sh --buck2="$(realpath $BUCK2)" --coreml --custom --mps --optimized --portable --quantized --xnnpack
./build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
```

After the build finishes successfully, the resulting frameworks can be found in the `cmake-out` directory.
Expand Down
Loading