Skip to content

Commit 0d398a3

Browse files
committed
sh clean.sh script that does cleaning
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
1 parent de74961 commit 0d398a3

File tree

11 files changed

+27
-16
lines changed

11 files changed

+27
-16
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils.sh"
1212

1313
install_executorch_and_backend_lib() {
1414
echo "Installing executorch and xnnpack backend"
15-
rm -rf cmake-android-out && mkdir cmake-android-out
15+
sh clean.sh
1616
ANDROID_NDK=/opt/ndk
1717
BUCK2=buck2
1818
ANDROID_ABI=arm64-v8a

.ci/scripts/test_llama.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ which "${PYTHON_EXECUTABLE}"
149149

150150
cmake_install_executorch_libraries() {
151151
echo "Installing libexecutorch.a, libextension_module.so, libportable_ops_lib.a"
152-
rm -rf cmake-out
152+
sh clean.sh
153153
retry cmake \
154154
-DCMAKE_INSTALL_PREFIX=cmake-out \
155155
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \

.ci/scripts/utils.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ build_executorch_runner_buck2() {
7474
build_executorch_runner_cmake() {
7575
CMAKE_OUTPUT_DIR=cmake-out
7676
# Build executorch runtime using cmake
77-
rm -rf "${CMAKE_OUTPUT_DIR}" && mkdir "${CMAKE_OUTPUT_DIR}"
77+
sh clean.sh
7878

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

104104
cmake_install_executorch_lib() {
105105
echo "Installing libexecutorch.a and libportable_kernels.a"
106-
rm -rf cmake-out
106+
sh clean.sh
107107
retry cmake -DBUCK2="$BUCK" \
108108
-DCMAKE_INSTALL_PREFIX=cmake-out \
109109
-DCMAKE_BUILD_TYPE=Release \

clean.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
# Copyright (c) Meta Platforms, Inc. and affiliates.
3+
# All rights reserved.
4+
#
5+
# This source code is licensed under the BSD-style license found in the
6+
# LICENSE file in the root directory of this source tree
7+
8+
set -eu
9+
rm -rf cmake-out pip-out cmake-android-out
10+
mkdir cmake-out
11+
mkdir cmake-android-out

docs/source/getting-started-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ to ExecuTorch.
113113
>
114114
> ```bash
115115
> # From the root of the executorch repo:
116-
> rm -rf cmake-out pip-out
116+
> sh clean.sh
117117
> git submodule sync
118118
> git submodule update --init
119119
> ```
@@ -196,7 +196,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
196196
```bash
197197
# Clean and configure the CMake build system. Compiled programs will
198198
# appear in the executorch/cmake-out directory we create here.
199-
(rm -rf cmake-out && mkdir cmake-out && cd cmake-out && cmake ..)
199+
(sh clean.sh && cd cmake-out && cmake ..)
200200

201201
# Build the executor_runner target
202202
cmake --build cmake-out --target executor_runner -j9
@@ -213,7 +213,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
213213
>
214214
> ```bash
215215
> # From the root of the executorch repo:
216-
> rm -rf cmake-out pip-out
216+
> sh clean.sh
217217
> git submodule sync
218218
> git submodule update --init
219219
> ```

docs/source/runtime-build-and-cross-compilation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ cd executorch
4545

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

5151
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.
@@ -121,7 +121,7 @@ Following are instruction on how to perform cross compilation for Android and iO
121121
Assuming Android NDK is available, run:
122122
```bash
123123
# Run the following lines from the `executorch/` folder
124-
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
124+
sh clean.sh && cd cmake-android-out
125125

126126
# point -DCMAKE_TOOLCHAIN_FILE to the location where ndk is installed
127127
cmake -DCMAKE_TOOLCHAIN_FILE=/Users/{user_name}/Library/Android/sdk/ndk/25.2.9519653/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a ..

examples/demo-apps/android/ExecuTorchDemo/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ We build the required ExecuTorch runtime library to run the model.
6969
export ANDROID_NDK=<path-to-android-ndk>
7070
export ANDROID_ABI=arm64-v8a
7171

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

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

115-
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
116+
sh clean.sh && cd cmake-android-out
116117
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
117118
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
118119
-DANDROID_ABI="${ANDROID_ABI}" \

examples/devtools/build_example_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ done
3737
main() {
3838
cd "${EXECUTORCH_ROOT}"
3939

40-
rm -rf cmake-out
40+
sh clean.sh
4141

4242
if [[ "${BUILD_COREML}" == "ON" ]]; then
4343
cmake -DCMAKE_INSTALL_PREFIX=cmake-out \

examples/devtools/test_example_runner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../../.ci/scripts/utils.sh"
1616

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

2121
retry cmake -DCMAKE_INSTALL_PREFIX=cmake-out \
2222
-DCMAKE_BUILD_TYPE=Release \

examples/xnnpack/quantization/test_quantize.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ test_cmake_quantization() {
4747
SITE_PACKAGES="$(${PYTHON_EXECUTABLE} -c 'from distutils.sysconfig import get_python_lib; print(get_python_lib())')"
4848
CMAKE_PREFIX_PATH="${SITE_PACKAGES}/torch"
4949

50-
(rm -rf cmake-out \
51-
&& mkdir cmake-out \
50+
(sh clean.sh \
5251
&& cd cmake-out \
5352
&& retry cmake \
5453
-DCMAKE_BUILD_TYPE=Release \

test/build_size_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/../.ci/scripts/utils.sh"
1313

1414
cmake_install_executorch_lib() {
1515
echo "Installing libexecutorch.a"
16-
rm -rf cmake-out
16+
sh clean.sh
1717

1818
retry cmake -DBUCK2="$BUCK2" \
1919
-DCMAKE_CXX_STANDARD_REQUIRED=ON \

0 commit comments

Comments
 (0)