diff options
| author | KiritoDv <kiritodev01@gmail.com> | 2026-03-23 21:23:59 -0600 |
|---|---|---|
| committer | KiritoDv <kiritodev01@gmail.com> | 2026-03-23 21:23:59 -0600 |
| commit | 75f64161cb4addcbc6e29732df8d9b519a62c43f (patch) | |
| tree | 92e2b17bd8c41af42bdf24a6eb4b7b08b90254f6 /run-clang-format.sh | |
| parent | 654b451ddc6cf25db201b2c858948f430784cc5f (diff) | |
Implemented clang-format
Diffstat (limited to 'run-clang-format.sh')
| -rwxr-xr-x | run-clang-format.sh | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/run-clang-format.sh b/run-clang-format.sh new file mode 100755 index 0000000..764ed77 --- /dev/null +++ b/run-clang-format.sh @@ -0,0 +1,36 @@ +# this line does quite a bit, so let's break it down +# +# find soh +# use "find" to look in the "soh" directory +# this ensures we don't try to format stuff in the submodules +# +# -type f +# only look for files +# +# -name "*.c" -o -name "*.cpp" +# find all .c and .cpp files +# +# ( -name "*.h" -o -name "*.hpp" ) ! -path "soh/src/**.h" ! -path "soh/include/**.h" +# find all .h and .hpp files that aren't in soh/src or soh/include +# this is because zret decomp only runs clang-format on c files +# https://github.com/zeldaret/mm/blob/b7e5468ca16315a7e322055eff3d97fe980bbc25/format.py#L182 +# +# ! -path "soh/assets/*" +# asset headers are autogenerated, don't fight them +# +# -print0 +# separate paths with NUL bytes, avoiding issues with spaces in paths +# +# | xargs -0 clang-format-14 -i -verbose +# use xargs to take each path we've found +# and pass it as an argument to clang-format +# verbose to print files being formatted and X out of Y status + +# Autodetect the command +if command -v clang-format-14 &> /dev/null; then + CLANG_FORMAT="clang-format-14" +else + CLANG_FORMAT="clang-format" +fi + +find src -type f \( -name "*.c" -o -name "*.cpp" -o \( \( -name "*.h" -o -name "*.hpp" \) ! -path "src/*" ! -path "include/*" \) \) ! -path "assets/*" -print0 | xargs -0 $CLANG_FORMAT -i --verbose |
