Repository navigation
Expand file tree
/
Copy pathclean.sh
More file actions
executable file
·66 lines (53 loc) · 2.66 KB
/
Copy pathclean.sh
File metadata and controls
executable file
·66 lines (53 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
#
# Copyright 2025 ByteDance Ltd. and/or its affiliates. All rights reserved.
# Licensed under the Apache License, Version 2.0 (the "License").
#
# Removes everything generated/downloaded by build.sh and by ad-hoc
# CMake/compiler runs, leaving only source files under version control. This
# includes optional JSONTestSuite and benchmark dependency checkouts.
#
set -euo pipefail
# Anchor every destructive path to this checkout, regardless of where the
# caller invokes the script. No caller-supplied cleanup path is accepted.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"
# ---- Repository-owned generated trees ----------------------------------
echo ">> Removing build.sh output (out/)"
rm -rf "${SCRIPT_DIR}/out"
echo ">> Removing downloaded test corpora (.test-corpora/)"
rm -rf "${SCRIPT_DIR}/.test-corpora"
echo ">> Removing downloaded benchmark dependencies (.benchmark-deps/)"
rm -rf "${SCRIPT_DIR}/.benchmark-deps"
echo ">> Removing local fuzz runtime state (.fuzz-corpus/ and .fuzz-artifacts/)"
rm -rf "${SCRIPT_DIR}/.fuzz-corpus" "${SCRIPT_DIR}/.fuzz-artifacts"
echo ">> Removing Python bytecode caches"
find "${SCRIPT_DIR}" -type d -name '__pycache__' -not -path '*/.git/*' \
-prune -exec rm -rf {} + 2>/dev/null || true
find "${SCRIPT_DIR}" -type f \( -name '*.pyc' -o -name '*.pyo' \) \
-not -path '*/.git/*' -delete 2>/dev/null || true
echo ">> Removing stray CMake build trees"
rm -rf "${SCRIPT_DIR}/build" "${SCRIPT_DIR}/cmake-build-"* 2>/dev/null || true
echo ">> Removing Conan test-package build output"
rm -rf "${SCRIPT_DIR}/test_package/build"
rm -f "${SCRIPT_DIR}/test_package/CMakeUserPresets.json"
# ---- Stray generated files ---------------------------------------------
# These scans stay below the resolved repository root and explicitly prune
# .git so cleanup cannot damage Git's object database or metadata.
echo ">> Removing in-source CMake artifacts (from accidental in-tree configures)"
find "${SCRIPT_DIR}" \
\( -name 'CMakeCache.txt' \
-o -name 'CMakeFiles' -type d \
-o -name 'cmake_install.cmake' \
-o -name 'CTestTestfile.cmake' \
-o -name 'compile_commands.json' \
-o -name 'Makefile' \) \
-not -path '*/.git/*' -prune -exec rm -rf {} + 2>/dev/null || true
echo ">> Removing compiled objects, libraries, and OS cruft"
find "${SCRIPT_DIR}" \
\( -name '*.o' -o -name '*.obj' -o -name '*.a' -o -name '*.lib' \
-o -name '*.so' -o -name '*.dylib' -o -name '*.dll' \
-o -name '*.exe' -o -name '*.out' -o -name '*.gch' -o -name '*.pch' \
-o -name '.DS_Store' \) \
-not -path '*/.git/*' -type f -delete 2>/dev/null || true
echo ">> Clean."