Skip to content

Commit 0b05f47

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 0b05f47

File tree

11 files changed

+30
-17
lines changed

11 files changed

+30
-17
lines changed

.ci/scripts/build_llama_android.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ 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+
clean_executorch_install_folders
16+
mkdir cmake-android-out
1617
ANDROID_NDK=/opt/ndk
1718
BUCK2=buck2
1819
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+
clean_executorch_install_folders
153153
retry cmake \
154154
-DCMAKE_INSTALL_PREFIX=cmake-out \
155155
-DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \

.ci/scripts/utils.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ retry () {
1616
"$@" || (sleep 30 && reset_buck && "$@") || (sleep 60 && reset_buck && "$@")
1717
}
1818

19+
clean_executorch_install_folders() {
20+
./install_requirements.sh --clean
21+
}
22+
1923
install_executorch() {
2024
which pip
2125
# Install executorch, this assumes that Executorch is checked out in the
@@ -74,7 +78,8 @@ build_executorch_runner_buck2() {
7478
build_executorch_runner_cmake() {
7579
CMAKE_OUTPUT_DIR=cmake-out
7680
# Build executorch runtime using cmake
77-
rm -rf "${CMAKE_OUTPUT_DIR}" && mkdir "${CMAKE_OUTPUT_DIR}"
81+
clean_executorch_install_folders
82+
mkdir "${CMAKE_OUTPUT_DIR}"
7883

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

104109
cmake_install_executorch_lib() {
105110
echo "Installing libexecutorch.a and libportable_kernels.a"
106-
rm -rf cmake-out
111+
clean_executorch_install_folders
107112
retry cmake -DBUCK2="$BUCK" \
108113
-DCMAKE_INSTALL_PREFIX=cmake-out \
109114
-DCMAKE_BUILD_TYPE=Release \

docs/source/getting-started-setup.md

Lines changed: 4 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+
> ./install_requirements.sh --clean
117117
> git submodule sync
118118
> git submodule update --init
119119
> ```
@@ -196,7 +196,8 @@ 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+
./install_requirements.sh --clean
200+
(mkdir cmake-out && cd cmake-out && cmake ..)
200201

201202
# Build the executor_runner target
202203
cmake --build cmake-out --target executor_runner -j9
@@ -213,7 +214,7 @@ The ExecuTorch repo uses CMake to build its C++ code. Here, we'll configure it t
213214
>
214215
> ```bash
215216
> # From the root of the executorch repo:
216-
> rm -rf cmake-out pip-out
217+
> ./install_requirements.sh --clean
217218
> git submodule sync
218219
> git submodule update --init
219220
> ```

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ 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+
./install_requirements.sh --clean
49+
(mkdir cmake-out && cd cmake-out && cmake ..)
4950
```
5051

5152
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 +122,8 @@ Following are instruction on how to perform cross compilation for Android and iO
121122
Assuming Android NDK is available, run:
122123
```bash
123124
# Run the following lines from the `executorch/` folder
124-
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
125+
./install_requirements.sh --clean
126+
mkdir cmake-android-out && cd cmake-android-out
125127

126128
# point -DCMAKE_TOOLCHAIN_FILE to the location where ndk is installed
127129
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ 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+
./install_requirements.sh --clean
74+
mkdir cmake-android-out
7375

7476
# Build the core executorch library
7577
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
@@ -112,7 +114,8 @@ export ANDROID_NDK=<path-to-android-ndk>
112114
export ANDROID_ABI=arm64-v8a
113115
export QNN_SDK_ROOT=<path-to-qnn-sdk>
114116

115-
rm -rf cmake-android-out && mkdir cmake-android-out && cd cmake-android-out
117+
./install_requirements.sh --clean
118+
mkdir cmake-android-out && cd cmake-android-out
116119
cmake . -DCMAKE_INSTALL_PREFIX=cmake-android-out \
117120
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
118121
-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+
./install_requirements.sh --clean
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+
clean_executorch_install_folders
2020

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

examples/xnnpack/quantization/test_quantize.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ 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+
clean_executorch_install_folders
51+
52+
(mkdir cmake-out \
5253
&& cd cmake-out \
5354
&& retry cmake \
5455
-DCMAKE_BUILD_TYPE=Release \

install_requirements.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def python_is_compatible():
8585
print("Cleaning build artifacts...")
8686
print("Cleaning pip-out/...")
8787
shutil.rmtree("pip-out/", ignore_errors=True)
88-
dirs = glob.glob("cmake-out*/")
88+
dirs = glob.glob("cmake-out*/") + glob.glob("cmake-android-out/")
8989
for d in dirs:
9090
print(f"Cleaning {d}...")
9191
shutil.rmtree(d, ignore_errors=True)

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+
clean_executorch_install_folders
1717

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

0 commit comments

Comments
 (0)