Skip to content

Commit

Permalink
[Comgr] Update tidy script to use local paths from llvm-project
Browse files Browse the repository at this point in the history
Change-Id: I4c6c7c8376aaba16db29cd0713e1b9cdf0d2a4a5
  • Loading branch information
lamb-j committed Nov 7, 2023
1 parent 1bb0075 commit a5582ee
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions amd/comgr/utils/tidy-and-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@

set -euo pipefail

hash git find clang-format clang-tidy clang-apply-replacements

if ! hash run-clang-tidy.py 2>/dev/null; then
# For some reason this doesn't get installed into the PATH on e.g. Ubuntu, so
# let's see if it is in a known location rather than just fail.
if [ -x /usr/local/share/clang/run-clang-tidy.py ]; then
hash -p /usr/local/share/clang/run-clang-tidy.py run-clang-tidy.py
else
printf "error: could not find run-clang-tidy.py in PATH\n" >&2
exit 1
fi
if ! test -f ../../../build/bin/clang-format; then
printf "error: could not find clang-format in llvm-project/build/bin directory\n" >&2
exit 1
fi

cd "$(git rev-parse --show-toplevel)/lib/comgr"
cd "$(git rev-parse --show-toplevel)/amd/comgr"

if [ ! -e compile_commands.json ]; then
printf "error: compile_commands.json database missing\n" >&2
printf " hint: enable with -DCMAKE_EXPORT_COMPILE_COMMANDS=On and then symlink into the lib/comgr directory:\n" >&2
printf " lib/comgr/release$ cmake ... -DCMAKE_EXPORT_COMPILE_COMMANDS=On ... && make && cd ..\n" >&2
printf " lib/comgr$ ln -s release/compile_commands.json .\n" >&2
printf " hint: enable with -DCMAKE_EXPORT_COMPILE_COMMANDS=On and then symlink into the amd/comgr directory:\n" >&2
printf " amd/comgr/build$ cmake ... -DCMAKE_EXPORT_COMPILE_COMMANDS=On ... && make && cd ..\n" >&2
printf " amd/comgr$ ln -s build/compile_commands.json .\n" >&2
exit 1
fi

run-clang-tidy.py -fix
../../clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -fix

# FIXME: Drive this off of compile_commands.json
find src/ test/ -type f -regex '.*\.\(c\|cpp\|h\|hpp\|cl\)$' -print0 \
| xargs -0 clang-format -i
| xargs -0 ../../build/bin/clang-format -i

0 comments on commit a5582ee

Please sign in to comment.