Skip to content

Commit

Permalink
sh clean.sh script that does cleaning
Browse files Browse the repository at this point in the history
Let's encapsulate important steps inside this single script for cleaning up.

As next steps, I'd like to restart buck as part of this script.

#7083
  • Loading branch information
mergennachin committed Dec 2, 2024
1 parent 2d499b3 commit 6f9a7d5
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .ci/scripts/build_llama_android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"

install_executorch_and_backend_lib() {
echo "Installing executorch and xnnpack backend"
rm -rf cmake-android-out && mkdir cmake-android-out
sh clean.sh
ANDROID_NDK=/opt/ndk
BUCK2=buck2
ANDROID_ABI=arm64-v8a
Expand Down
2 changes: 1 addition & 1 deletion .ci/scripts/test_llama.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ which "${PYTHON_EXECUTABLE}"

cmake_install_executorch_libraries() {
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
rm -rf cmake-out
sh clean.sh
retry cmake \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \
Expand Down
4 changes: 2 additions & 2 deletions .ci/scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ build_executorch_runner_buck2() {
build_executorch_runner_cmake() {
CMAKE_OUTPUT_DIR=cmake-out
# Build executorch runtime using cmake
rm -rf "${CMAKE_OUTPUT_DIR}" && mkdir "${CMAKE_OUTPUT_DIR}"
sh clean.sh

pushd "${CMAKE_OUTPUT_DIR}" || return
# This command uses buck2 to gather source files and buck2 could crash flakily
Expand Down Expand Up @@ -103,7 +103,7 @@ build_executorch_runner() {

cmake_install_executorch_lib() {
echo "Installing libexecutorch.a and libportable_kernels.a"
rm -rf cmake-out
sh clean.sh
retry cmake -DBUCK2="$BUCK" \
-DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
11 changes: 11 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree

set -eu
rm -rf cmake-out pip-out cmake-android-out
mkdir cmake-out
mkdir cmake-android-out
6 changes: 3 additions & 3 deletions docs/source/getting-started-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ to ExecuTorch.
>
> ```bash
> # From the root of the executorch repo:
> rm -rf cmake-out pip-out
> sh clean.sh
> git submodule sync
> git submodule update --init
> ```
Expand Down Expand Up @@ -196,7 +196,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
```bash
# Clean and configure the CMake build system. Compiled programs will
# appear in the executorch/cmake-out directory we create here.
(rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake ..)
(sh clean.sh && cd cmake-out && cmake ..)

# Build the executor_runner target
cmake --build cmake-out --target executor_runner -j9
Expand All @@ -213,7 +213,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
>
> ```bash
> # From the root of the executorch repo:
> rm -rf cmake-out pip-out
> sh clean.sh
> git submodule sync
> git submodule update --init
> ```
Expand Down
4 changes: 2 additions & 2 deletions docs/source/runtime-build-and-cross-compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ cd executorch

# Clean and configure the CMake build system. It's good practice to do this
# whenever cloning or pulling the upstream repo.
(rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake ..)
(sh clean.sh && cd cmake-out && cmake ..)
```

Once this is done, you don't need to do it again until you pull from the upstream repo again, or if you modify any CMake-related files.
Expand Down Expand Up @@ -121,7 +121,7 @@ Following are instruction on how to perform cross compilation for Android and iO
Assuming Android NDK is available, run:
```bash
# Run the following lines from the `executorch/` folder
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
sh clean.sh && cd cmake-android-out

# point -DCMAKE_TOOLCHAIN_FILE to the location where ndk is installed
cmake -DCMAKE_TOOLCHAIN_FILE=/Users/{user_name}/Library/Android/sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a ..
Expand Down
5 changes: 3 additions & 2 deletions examples/demo-apps/android/ExecuTorchDemo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ We build the required ExecuTorch runtime library to run the model.
export ANDROID_NDK=<path-to-android-ndk>
export ANDROID_ABI=arm64-v8a

rm -rf cmake-android-out && mkdir cmake-android-out
# Run the following lines from the `executorch/` folder
sh clean.sh

# Build the core executorch library
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
Expand Down Expand Up @@ -112,7 +113,7 @@ export ANDROID_NDK=<path-to-android-ndk>
export ANDROID_ABI=arm64-v8a
export QNN_SDK_ROOT=<path-to-qnn-sdk>

rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
sh clean.sh && cd cmake-android-out
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
-DANDROID_ABI="${ANDROID_ABI}" \
Expand Down
2 changes: 1 addition & 1 deletion examples/devtools/build_example_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ done
main() {
cd "${EXECUTORCH_ROOT}"

rm -rf cmake-out
sh clean.sh

if [[ "${BUILD_COREML}" == "ON" ]]; then
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
Expand Down
2 changes: 1 addition & 1 deletion examples/devtools/test_example_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh"

cmake_install_executorch_devtools_lib() {
echo "Installing libexecutorch.a, libportable_kernels.a, libetdump.a, libbundled_program.a"
rm -rf cmake-out
sh clean.sh

retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
3 changes: 1 addition & 2 deletions examples/xnnpack/quantization/test_quantize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ test_cmake_quantization() {
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"

(rm -rf cmake-out \
&& mkdir cmake-out \
(sh clean.sh \
&& cd cmake-out \
&& retry cmake \
-DCMAKE_BUILD_TYPE=Release \
Expand Down
2 changes: 1 addition & 1 deletion test/build_size_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"

cmake_install_executorch_lib() {
echo "Installing libexecutorch.a"
rm -rf cmake-out
sh clean.sh

retry cmake -DBUCK2="$BUCK2" \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
Expand Down

0 comments on commit 6f9a7d5

Please sign in to comment.