Skip to content

[build Folder Migration] Move core build files into scripts #9434

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 10 commits into from
Mar 24, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
# Build LLM Demo for Android
export BUILD_AAR_DIR=aar-out
mkdir -p $BUILD_AAR_DIR
bash build/build_android_library.sh ${ARTIFACTS_DIR_NAME}
bash scripts/build_android_library.sh ${ARTIFACTS_DIR_NAME}
bash .ci/scripts/build_android_instrumentation.sh ${ARTIFACTS_DIR_NAME}

mkdir -p examples/demo-apps/android/LlamaDemo/app/libs
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
with:
api-level: ${{ env.API_LEVEL }}
arch: x86_64
script: ./build/run_android_emulator.sh
script: ./scripts/run_android_emulator.sh
# NB: This is to boot the emulator faster following the instructions on
# https://github.com/ReactiveCircus/android-emulator-runner. The max number
# of cores we can set is 6, any higher number will be reduced to 6.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ jobs:
PYTHON_EXECUTABLE=python bash .ci/scripts/build-qnn-sdk.sh

mkdir -p aar-out
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 bash build/build_android_library.sh
PYTHON_EXECUTABLE=python ANDROID_ABIS="arm64-v8a" BUILD_AAR_DIR=aar-out EXECUTORCH_BUILD_QNN=ON QNN_SDK_ROOT=/tmp/qnn/2.28.0.241029 bash scripts/build_android_library.sh
mkdir -p extension/benchmark/android/benchmark/app/libs
cp aar-out/executorch.aar extension/benchmark/android/benchmark/app/libs
pushd extension/benchmark/android/benchmark
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/android-release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
# Build AAR Package
mkdir aar-out
export BUILD_AAR_DIR=aar-out
bash build/build_android_library.sh
bash scripts/build_android_library.sh
mkdir -p "${ARTIFACTS_DIR_NAME}"
cp aar-out/executorch.aar "${ARTIFACTS_DIR_NAME}/executorch.aar"

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/apple-perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ jobs:

echo "::group::Build ExecuTorch iOS frameworks"
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
echo "::endgroup::"

# NB: Although exported models can be copied to this directory and bundled together with the
Expand All @@ -396,7 +396,7 @@ jobs:
# create the directory here to pass the build
mkdir -p extension/benchmark/apple/Benchmark/Models
${CONDA_RUN} --no-capture-output \
build/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}
scripts/build_apple_llm_demo.sh ${ARTIFACTS_DIR_NAME}

upload-benchmark-app:
needs: build-benchmark-app
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/apple.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ on:
- .github/workflows/apple.yml
- install_executorch.sh
- backends/apple/**
- build/build_apple_frameworks.sh
- build/build_apple_llm_demo.sh
- build/create_frameworks.sh
- scripts/build_apple_frameworks.sh
- scripts/build_apple_llm_demo.sh
- scripts/create_frameworks.sh
- .ci/scripts/test_ios_ci.sh
- examples/demo-apps/apple_ios/**
- extension/apple/**
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:

# Build iOS Frameworks
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack

# Bundle iOS Frameworks
for FRAMEWORK in "${FRAMEWORKS[@]}"; do (
Expand Down Expand Up @@ -313,11 +313,11 @@ jobs:

echo "::group::Build ExecuTorch iOS frameworks"
PYTHON_EXECUTABLE=python ${CONDA_RUN} --no-capture-output \
build/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
scripts/build_apple_frameworks.sh --Release --Debug --coreml --custom --mps --optimized --portable --quantized --xnnpack
echo "::endgroup::"

echo "::group::Build ExecuTorch benchmark app"
mkdir -p extension/benchmark/apple/Benchmark/Models
${CONDA_RUN} --no-capture-output \
build/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
scripts/build_apple_llm_demo.sh "${ARTIFACTS_DIR_NAME}"
echo "::endgroup::"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ __pycache__/
arm_test/
buck-out/
buck2-bin/
build/
cmake-android-out/
cmake-ios-out/
cmake-out*
Expand Down
2 changes: 1 addition & 1 deletion backends/apple/coreml/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ xcode-select --install

```bash
cd executorch
./build/build_apple_frameworks.sh --coreml
./scripts/build_apple_frameworks.sh --coreml
```
5. Open the project in Xcode, and drag `executorch.xcframework` and `coreml_backend.xcframework` frameworks generated from Step 2 to Frameworks.

Expand Down
2 changes: 1 addition & 1 deletion backends/apple/mps/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ python3 -m sdk.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path
***Step 1***. Create the ExecuTorch core and MPS delegate frameworks to link on iOS
```bash
cd executorch
./build/build_apple_frameworks.sh --mps
./scripts/build_apple_frameworks.sh --mps
```

`mps_delegate.xcframework` will be in `cmake-out` folder, along with `executorch.xcframework` and `portable_delegate.xcframework`:
Expand Down
6 changes: 0 additions & 6 deletions build/__init__.py

This file was deleted.

2 changes: 1 addition & 1 deletion docs/source/backends-mps.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ python3 -m sdk.inspector.inspector_cli --etdump_path etdump.etdp --etrecord_path
***Step 1***. Create the ExecuTorch core and MPS delegate frameworks to link on iOS
```bash
cd executorch
./build/build_apple_frameworks.sh --mps
./scripts/build_apple_frameworks.sh --mps
```

`mps_delegate.xcframework` will be in `cmake-out` folder, along with `executorch.xcframework` and `portable_delegate.xcframework`:
Expand Down
6 changes: 3 additions & 3 deletions docs/source/using-executorch-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Now you can compile your app with the ExecuTorch Android library.

## Building from Source

`build/build_android_library.sh` is a helper script to build the Java library (into .jar), native library (into .so), and the packaged AAR file. It can also build
`scripts/build_android_library.sh` is a helper script to build the Java library (into .jar), native library (into .so), and the packaged AAR file. It can also build
demo apps to showcase the AAR is integrated into a user app correctly.

You need Android [SDK](https://developer.android.com/studio) and [NDK](https://developer.android.com/ndk/downloads) to use it.
Expand All @@ -100,7 +100,7 @@ You need to set `ANDROID_HOME` to Android SDK home and `ANDROID_NDK` to the corr
```
export ANDROID_HOME=/path/to/sdk
export ANDROID_NDK=/path/to/ndk
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```

### Optional environment variables
Expand All @@ -113,7 +113,7 @@ Set environment variable `ANDROID_ABIS` to either `arm64-v8a` or `x86_64` if you
export ANDROID_ABIS=arm64-v8a
# or
# export ANDROID_ABIS=x86_64
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```

#### EXECUTORCH_CMAKE_BUILD_TYPE
Expand Down
2 changes: 1 addition & 1 deletion docs/source/using-executorch-building-from-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ xcode-select --install
2. Build the frameworks:

```bash
./build/build_apple_frameworks.sh
./scripts/build_apple_frameworks.sh
```

Run the above command with `--help` flag to learn more on how to build additional backends
Expand Down
4 changes: 2 additions & 2 deletions docs/source/using-executorch-ios.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ sudo /Applications/CMake.app/Contents/bin/cmake-gui --install
6. Use the provided script to build .xcframeworks:

```bash
./build/build_apple_frameworks.sh --help
./scripts/build_apple_frameworks.sh --help
```

For example, the following command will build the ExecuTorch Runtime along with all available kernels and backends for the Apple platform in both Release and Debug modes:

```bash
./build/build_apple_frameworks.sh --Release --Debug --coreml --mps --xnnpack --custom --optimized --portable --quantized
./scripts/build_apple_frameworks.sh --Release --Debug --coreml --mps --xnnpack --custom --optimized --portable --quantized
```

After the build finishes successfully, the resulting frameworks can be found in the `cmake-out` directory.
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-apps/android/ExecuTorchDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ popd

# Build the AAR. It will include XNNPACK backend by default.
export BUILD_AAR_DIR=$(realpath examples/demo-apps/android/ExecuTorchDemo/app/libs)
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```

#### Qualcomm Hexagon NPU
Expand All @@ -107,7 +107,7 @@ popd

# Build the AAR. It will include XNNPACK backend by default.
export BUILD_AAR_DIR=$(realpath examples/demo-apps/android/ExecuTorchDemo/app/libs)
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```

This is very similar to XNNPACK setup, but users now needs to define `QNN_SDK_ROOT` so that
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ The Mediatek runner (`examples/mediatek/executor_runner/mtk_llama_runner.cpp`) c

Next we need to build and compile the MediaTek backend and MediaTek Llama runner. By setting `NEURON_BUFFER_ALLOCATOR_LIB`, the script will build the MediaTek backend.
```
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```

**Output**: This will generate an .aar file that is already imported into the expected directory for the Android app. It will live in `examples/demo-apps/android/Llamademo/app/libs`.
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-apps/android/LlamaDemo/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export BUILD_AAR_DIR

BASEDIR=$(dirname "$0")
mkdir -p "$BASEDIR"/app/libs
bash "$BASEDIR"/../../../../build/build_android_library.sh
bash "$BASEDIR"/../../../../scripts/build_android_library.sh

cp "$BUILD_AAR_DIR/executorch.aar" "$BASEDIR"/app/libs/executorch.aar
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ curl -LO "https://github.com/facebook/buck2/releases/download/$BUCK2_RELEASE_DAT
zstd -cdq "$BUCK2_ARCHIVE" > "$BUCK2" && chmod +x "$BUCK2"
rm "$BUCK2_ARCHIVE"

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

After the build finishes successfully, the resulting frameworks can be found in the `cmake-out` directory. Copy them to your project and link them against your targets.
Expand Down
2 changes: 1 addition & 1 deletion extension/benchmark/android/benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Minibench is usedful for giving reference performance data when developers integ
You will need executorch AAR for Java and JNI dependencies.
```
export ANDROID_NDK=<path_to_android_ndk>
sh build/build_android_library.sh
sh scripts/build_android_library.sh
```
and copy the AAR to `app/libs`.
```
Expand Down
Empty file added scripts/__init__.py
Empty file.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ echo "Exporting headers"

mkdir -p "$HEADERS_PATH"

"$SOURCE_ROOT_DIR"/build/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
"$SOURCE_ROOT_DIR"/scripts/print_exported_headers.py --buck2=$(realpath "$BUCK2") --targets \
//extension/module: \
//extension/tensor: \
| rsync -av --files-from=- "$SOURCE_ROOT_DIR" "$HEADERS_PATH/executorch"
Expand Down Expand Up @@ -272,7 +272,7 @@ for mode in "${MODES[@]}"; do
append_framework_flag "$PORTABLE" "$FRAMEWORK_KERNELS_PORTABLE" "$mode"
append_framework_flag "$QUANTIZED" "$FRAMEWORK_KERNELS_QUANTIZED" "$mode"

"$SOURCE_ROOT_DIR"/build/create_frameworks.sh "${FRAMEWORK_FLAGS[@]}"
"$SOURCE_ROOT_DIR"/scripts/create_frameworks.sh "${FRAMEWORK_FLAGS[@]}"
done

echo "Cleaning up"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion build/test_ios.sh → scripts/test_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ curl https://raw.githubusercontent.com/pytorch/hub/master/imagenet_classes.txt \

say "Building Frameworks"

./build/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
./scripts/build_apple_frameworks.sh --coreml --custom --mps --optimized --portable --quantized --xnnpack
mv cmake-out "$APP_PATH/Frameworks"

say "Creating Simulator"
Expand Down
Loading