Skip to content

Commit

Permalink
Add script to run clang-tidy on all builds
Browse files Browse the repository at this point in the history
tools/clang-tidy_runner.sh will run clang-tidy on all builds in parallel.

Other scripts got an updated method of determining the cholla directory
that works if invoked from outside the directory.
  • Loading branch information
bcaddy committed Sep 18, 2023
1 parent 9209462 commit ea0f443
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion tools/cholla-nv-compute-sanitizer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ if [ -z "$tool" ]; then
fi

# Get Paths
cholla_root=$(git rev-parse --show-toplevel)
cholla_root="$(dirname "$(dirname "$(readlink -fm "$0")")")"
cholla_exe=$(find "${cholla_root}" -name cholla.*)
cholla_parameter_file="${cholla_root}/examples/3D/sod.txt"
COMPUTE_SANITIZER=$(which compute-sanitizer)
Expand Down
3 changes: 2 additions & 1 deletion tools/clang-format_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
# - GNU Find, the default macos version won't work

# Get the location of Cholla
cholla_root=$(git rev-parse --show-toplevel)
cholla_root="$(dirname "$(dirname "$(readlink -fm "$0")")")"
cd $cholla_root

# Get a list of all the files to format
readarray -t files <<<$(find ${cholla_root} -regex '.*\.\(h\|hpp\|c\|cpp\|cu\|cuh\)$' -print)
Expand Down
23 changes: 23 additions & 0 deletions tools/clang-tidy_runner.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

# Description:
# Run clang-tidy on all build types in parallel. Note that this spawns 2x the
# number of build types threads since each type has a thread for the CPU code
# and a thread for the GPU code

# If ctrl-c is sent trap it and kill all clang-tidy processes
trap "kill -- -$$" EXIT

# cd into the Cholla directory. Default to ${HOME}/Code/cholla
cholla_root="$(dirname "$(dirname "$(readlink -fm "$0")")")"
cd $cholla_root

# Run all clang-tidy build types in parallel
builds=( hydro gravity disk particles cosmology mhd dust)
for build in "${builds[@]}"
do
make tidy TYPE=$build &
done

# Wait for clang-tidy to finish
wait

0 comments on commit ea0f443

Please sign in to comment.