Skip to content

Commit 6932f7c

Browse files
shoumikhinpytorchbot
authored andcommitted
Update build framework script to skip specifying buck executable. (#5985)
Summary: Pull Request resolved: #5985 . Reviewed By: dbort Differential Revision: D64053120 fbshipit-source-id: fc4149ee13130f913f96768a1370ea40ce8ed8b7 (cherry picked from commit f663ba6)
1 parent 245aa4e commit 6932f7c

File tree

3 files changed

+15
-30
lines changed

3 files changed

+15
-30
lines changed

build/build_apple_frameworks.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ SOURCE_ROOT_DIR=""
1111
OUTPUT="cmake-out"
1212
MODE="Release"
1313
TOOLCHAIN=""
14-
BUCK2=$(which buck2)
1514
PYTHON=$(which python3)
1615
FLATC=$(which flatc)
1716
COREML=OFF
@@ -79,7 +78,6 @@ usage() {
7978
echo " --output=DIR Output directory. Default: 'cmake-out'"
8079
echo " --Debug Use Debug build mode. Default: Uses Release build mode."
8180
echo " --toolchain=FILE Cmake toolchain file. Default: '\$SOURCE_ROOT_DIR/third-party/ios-cmake/ios.toolchain.cmake'"
82-
echo " --buck2=FILE Buck2 executable path. Default: Path of buck2 found in the current \$PATH"
8381
echo " --python=FILE Python executable path. Default: Path of python3 found in the current \$PATH"
8482
echo " --flatc=FILE FlatBuffers Compiler executable path. Default: Path of flatc found in the current \$PATH"
8583
echo " --coreml Include this flag to build the Core ML backend."
@@ -91,7 +89,7 @@ usage() {
9189
echo " --xnnpack Include this flag to build the XNNPACK backend."
9290
echo
9391
echo "Example:"
94-
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"
92+
echo " $0 /path/to/source/root --output=cmake-out --toolchain=/path/to/cmake/toolchain --python=/path/to/python3 --coreml --mps --xnnpack"
9593
exit 0
9694
}
9795

@@ -101,7 +99,6 @@ for arg in "$@"; do
10199
--output=*) OUTPUT="${arg#*=}" ;;
102100
--Debug) MODE="Debug" ;;
103101
--toolchain=*) TOOLCHAIN="${arg#*=}" ;;
104-
--buck2=*) BUCK2="${arg#*=}" ;;
105102
--python=*) PYTHON="${arg#*=}" ;;
106103
--flatc=*) FLATC="${arg#*=}" ;;
107104
--coreml) COREML=ON ;;
@@ -137,7 +134,6 @@ check_command() {
137134

138135
check_command cmake
139136
check_command rsync
140-
check_command "$BUCK2"
141137
check_command "$PYTHON"
142138
check_command "$FLATC"
143139

@@ -157,7 +153,6 @@ cmake_build() {
157153
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \
158154
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD="c++17" \
159155
-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY="libc++" \
160-
-DBUCK2="$BUCK2" \
161156
-DPYTHON_EXECUTABLE="$PYTHON" \
162157
-DFLATC_EXECUTABLE="$FLATC" \
163158
-DEXECUTORCH_BUILD_COREML=$COREML \
@@ -189,7 +184,16 @@ echo "Exporting headers"
189184

190185
mkdir -p "$HEADERS_PATH"
191186

192-
"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2="$BUCK2" --targets \
187+
# Set BUCK2 to the path of the buck2 executable in $OUTPUT/*/buck2-bin/buck2-*
188+
BUCK2=$(find . -type f -path '*/buck2-bin/buck2-*' | head -n 1)
189+
if [[ -z "$BUCK2" ]]; then
190+
echo "Could not find buck2 executable in any buck2-bin directory under $OUTPUT"
191+
BUCK2=$(which buck2)
192+
fi
193+
194+
check_command "$BUCK2"
195+
196+
"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
193197
//extension/module: \
194198
//extension/tensor: \
195199
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_PATH/executorch"

build/test_ios.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ set -e
1515

1616
OUTPUT="${1:-executorch}"
1717
EXIT_STATUS=0
18-
BUCK2_RELEASE_DATE="2024-05-15"
19-
BUCK2_ARCHIVE="buck2-aarch64-apple-darwin.zst"
20-
BUCK2=".venv/bin/buck2"
2118
APP_PATH="examples/demo-apps/apple_ios/ExecuTorchDemo/ExecuTorchDemo"
2219
MODEL_NAME="mv3"
2320
SIMULATOR_NAME="executorch"
@@ -66,10 +63,6 @@ say "Installing Requirements"
6663

6764
pip install --upgrade cmake pip setuptools wheel zstd
6865

69-
curl -LO "https://github.com/facebook/buck2/releases/download/$BUCK2_RELEASE_DATE/$BUCK2_ARCHIVE"
70-
zstd -cdq "$BUCK2_ARCHIVE" > "$BUCK2" && chmod +x "$BUCK2"
71-
rm "$BUCK2_ARCHIVE"
72-
7366
./install_requirements.sh --pybind coreml mps xnnpack
7467
export PATH="$(realpath third-party/flatbuffers/cmake-out):$PATH"
7568
./build/install_flatc.sh
@@ -99,7 +92,7 @@ curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \
9992

10093
say "Building Frameworks"
10194

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

10598
say "Creating Simulator"

docs/source/apple-runtime.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,7 @@ source .venv/bin/activate
108108
pip install --upgrade cmake pip zstd
109109
```
110110

111-
5. Install a compatible version of [Buck2](https://buck.build):
112-
113-
```bash
114-
BUCK2_RELEASE_DATE="2024-05-15"
115-
BUCK2_ARCHIVE="buck2-aarch64-apple-darwin.zst"
116-
BUCK2=".venv/bin/buck2"
117-
118-
curl -LO "https://github.com/facebook/buck2/releases/download/$BUCK2_RELEASE_DATE/$BUCK2_ARCHIVE"
119-
zstd -cdq "$BUCK2_ARCHIVE" > "$BUCK2" && chmod +x "$BUCK2"
120-
rm "$BUCK2_ARCHIVE"
121-
```
122-
123-
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:
111+
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:
124112

125113
```bash
126114
./install_requirements.sh
@@ -132,7 +120,7 @@ rm "$BUCK2_ARCHIVE"
132120
./backends/apple/mps/install_requirements.sh
133121
```
134122

135-
7. Use the provided script to build .xcframeworks:
123+
6. Use the provided script to build .xcframeworks:
136124

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

143131
```bash
144-
./build/build_apple_frameworks.sh --buck2="$(realpath $BUCK2)" --coreml --custom --mps --optimized --portable --quantized --xnnpack
132+
./build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
145133
```
146134

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

0 commit comments

Comments
 (0)