Philipp Schrader | e3a69d9 | 2023-07-05 20:54:16 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | # --- begin runfiles.bash initialization v2 --- |
| 4 | # Copy-pasted from the Bazel Bash runfiles library v2. |
| 5 | set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash |
| 6 | source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \ |
| 7 | source "$(grep -sm1 "^$f " "${RUNFILES_MANIFEST_FILE:-/dev/null}" | cut -f2- -d' ')" 2>/dev/null || \ |
| 8 | source "$0.runfiles/$f" 2>/dev/null || \ |
| 9 | source "$(grep -sm1 "^$f " "$0.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 10 | source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/null || \ |
| 11 | { echo>&2 "ERROR: cannot find $f"; exit 1; }; f=; set -e |
| 12 | # --- end runfiles.bash initialization v2 --- |
| 13 | |
| 14 | readonly CLANG_FORMAT="$(rlocation llvm_k8/bin/clang-format)" |
| 15 | |
| 16 | # Run everything from the root of the tree. |
| 17 | cd "${BUILD_WORKSPACE_DIRECTORY}" |
| 18 | |
| 19 | # Find all the C/C++ files in the repo. |
| 20 | # Exclude third-party code. Both in //third_party and the third-party code |
| 21 | # checked in to the main repo directly. |
| 22 | cc_files=($(git ls-tree --name-only --full-tree -r @ \ |
| 23 | | grep -v -e '^third_party/' \ |
| 24 | -e '^motors/core/kinetis.h$' \ |
| 25 | -e '^y2023/vision/rkisp1-config.h$' \ |
| 26 | | (grep -e '\.c$' -e '\.cc$' -e '\.h' || :))) |
| 27 | |
| 28 | # If we have any C/C++ files, format them. |
| 29 | if ((${#cc_files[@]} > 0)); then |
| 30 | exec "${CLANG_FORMAT}" -i "${cc_files[@]}" |
| 31 | fi |