mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
This adds two tools to the ./tools/ subdirectory:
== clang-formatter.sh ==
This is simply a small shell script that can be executed from the top of
the UHD repository, and it will format all files according the the
.clang-format file. It can be executed as such:
$ CLANG_FORMAT=clang-format-14 ./tools/clang-formatter.sh apply
Specifying a clang-format executable is optional, but note that
clang-format 14.0 should be used.
== run-clang-format.py ==
This is a Python script that is a modified version from
https://github.com/gnuradio/clang-format-lint-action/blob/ \
0b0cb14cf220a070d2a8b2610bd74ad1546252a1/run-clang-format.py
It was modified to add --patch-file option.
Alongside this file is a .clang-format-ignore file, which is sourced
from this script. The command can be run as such:
$ ./tools/run-clang-format.py \
--clang-format-executable clang-format-14 \
--extensions c,cpp,h,hpp,hpp.in,ipp \
-r \
--patch-file format.patch \
/path/to/uhd-repo
It will provide both a nice output summary as well as a patch file that
can be consumed with `patch -p0 < format.patch`.
49 lines
1.1 KiB
Bash
Executable File
49 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
cformat=${CLANG_FORMAT:-}
|
|
if [ -z "$cformat" ]; then
|
|
cformat=$(which clang-format)
|
|
fi
|
|
|
|
_cmd=$1
|
|
if [ -z "$_cmd" ]; then
|
|
_cmd="apply"
|
|
fi
|
|
|
|
cformat_args=""
|
|
case $_cmd in
|
|
apply)
|
|
cformat_args="-i"
|
|
;;
|
|
check)
|
|
cformat_args="-Werror --dry-run"
|
|
;;
|
|
check_apply)
|
|
cformat_args="-Werror -i"
|
|
;;
|
|
*)
|
|
echo "Usage: $0 [check|apply|check_apply]"
|
|
esac
|
|
|
|
find . \
|
|
-path './host/lib/deps' -prune -o \
|
|
-path './host/cmake' -prune -o \
|
|
-path './fpga' -prune -o \
|
|
-path './firmware' -prune -o \
|
|
-path './mpm/lib/mykonos' -prune -o \
|
|
-path './mpm/lib/rfdc' -prune -o \
|
|
-path './mpm/include/mpm/rfdc' -prune -o \
|
|
-path './mpm/tools' -prune -o \
|
|
-path './tools' -prune -o \
|
|
-name "getopt.*" -prune -o \
|
|
-name "cdecode.*" -prune -o \
|
|
-name "*_generated.h" -prune -o \
|
|
-name "*template_lvbitx.*" -prune -o \
|
|
-name "*.cpp" -print -o \
|
|
-name "*.hpp" -print -o \
|
|
-name "*.cpp.in" -print -o \
|
|
-name "*.hpp.in" -print -o \
|
|
-name "*.ipp" -print -o \
|
|
-name "*.c" -print -o \
|
|
-name "*.h" -print | xargs -n 10 -P 2 $cformat $cformat_args
|