mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
checkpatch: add scripts/check for batch processing
Co-Authored-By: @Consolatis
This commit is contained in:
parent
a361bae699
commit
4305f54e37
3 changed files with 61 additions and 2 deletions
|
|
@ -102,7 +102,7 @@ The reasons for specifying a style is not that we enjoy creating rules, but
|
||||||
because it makes reading/maintaining the code and spotting problems much easier.
|
because it makes reading/maintaining the code and spotting problems much easier.
|
||||||
|
|
||||||
If you are new to this style and want to get going quickly, either just imitate
|
If you are new to this style and want to get going quickly, either just imitate
|
||||||
the style around you, or read the summary below and use [checkpatch.pl] to run
|
the style around you, or read the summary below and use `./scripts/check` to run
|
||||||
some formatting checks.
|
some formatting checks.
|
||||||
|
|
||||||
## Linux Kernel Style Basics
|
## Linux Kernel Style Basics
|
||||||
|
|
@ -341,7 +341,6 @@ xgettext --keyword=_ --language=C --add-comments -o po/labwc.pot src/menu/menu.c
|
||||||
[common/mem.h]: https://github.com/labwc/labwc/blob/master/include/common/mem.h
|
[common/mem.h]: https://github.com/labwc/labwc/blob/master/include/common/mem.h
|
||||||
[common/list.h]: https://github.com/labwc/labwc/blob/master/include/common/list.h
|
[common/list.h]: https://github.com/labwc/labwc/blob/master/include/common/list.h
|
||||||
[commit messages]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/CONTRIBUTING.md#commit-messages
|
[commit messages]: https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/CONTRIBUTING.md#commit-messages
|
||||||
[checkpatch.pl]: https://github.com/johanmalm/checkpatch.pl
|
|
||||||
[GNU C extensions]: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
|
[GNU C extensions]: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
|
||||||
[`wl_container_of()`]: https://github.com/wayland-project/wayland/blob/985ab55d59db45ea62795c76dff5949343e86b2f/src/wayland-util.h#L409
|
[`wl_container_of()`]: https://github.com/wayland-project/wayland/blob/985ab55d59db45ea62795c76dff5949343e86b2f/src/wayland-util.h#L409
|
||||||
|
|
||||||
|
|
|
||||||
10
scripts/README.md
Normal file
10
scripts/README.md
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
These scripts are intended to be run from the project top-level directory
|
||||||
|
like this: `scripts/foo.sh`
|
||||||
|
|
||||||
|
- `scripts/check`: wrapper to check all files in `src/` and `include/`
|
||||||
|
|
||||||
|
- `scripts/checkpatch.pl`: Quick hack on the Linux kernel [checkpatch.pl]
|
||||||
|
to lint C files written according to the labwc coding style. Run like
|
||||||
|
this: `./checkpatch.pl --no-tree --terse --strict --file <file>`
|
||||||
|
|
||||||
|
[checkpatch.pl]: https://raw.githubusercontent.com/torvalds/linux/4ce9f970457899defdf68e26e0502c7245002eb3/scripts/checkpatch.pl
|
||||||
50
scripts/check
Executable file
50
scripts/check
Executable file
|
|
@ -0,0 +1,50 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
file=
|
||||||
|
|
||||||
|
usage_message="Usage: check [OPTIONS]
|
||||||
|
OPTIONS:
|
||||||
|
--file=<filename> Specify file to check. If none specified, all
|
||||||
|
files in src/ and include/ will be checked.
|
||||||
|
"
|
||||||
|
|
||||||
|
run_checkpatch() {
|
||||||
|
nice scripts/checkpatch.pl --terse --no-tree --strict --file "$1"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
run_checks () {
|
||||||
|
if [ ! -z "$file" ]; then
|
||||||
|
run_checkpatch "${file}"
|
||||||
|
return $?
|
||||||
|
fi
|
||||||
|
|
||||||
|
find src/ include/ \( -name "*.c" -o -name "*.h" \) -type f |
|
||||||
|
{
|
||||||
|
errors=0
|
||||||
|
while IFS= read -r file; do
|
||||||
|
run_checkpatch "$file" || errors=1
|
||||||
|
done
|
||||||
|
return ${errors}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main () {
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
opt=${arg%%=*}
|
||||||
|
var=${arg#*=}
|
||||||
|
case "$opt" in
|
||||||
|
--file)
|
||||||
|
file="$var" ;;
|
||||||
|
-h|--help)
|
||||||
|
printf '%b' "$usage_message"; exit 1 ;;
|
||||||
|
*)
|
||||||
|
printf '%b\n' "warn: unknown option $opt" >&2 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
run_checks
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue