diff options
author | Oliver Smith <osmith@sysmocom.de> | 2021-10-26 15:58:03 +0200 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2021-11-02 13:40:22 +0000 |
commit | 623b0b60f95c2cf18cd809c3f0aa499b817d63e3 (patch) | |
tree | f145c83d88a8c0ccee1b508356363a769a971cfe | |
parent | f6974d89c85112b4f6fa31dc6b2883c87fa6b6c9 (diff) |
lint: checkpatch_osmo.sh: exclude asn1c generated
Does not make a noticable speed difference on a typical patch with few
changed files, but makes linting on big patches with ~1000 files and
lots of asn1c generated files in the repository significantly slower.
The next patch will optimize that case.
Change-Id: I7437d888b433fec8a444e4d7c285fff47d16c0c7
-rwxr-xr-x | lint/checkpatch/checkpatch_osmo.sh | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lint/checkpatch/checkpatch_osmo.sh b/lint/checkpatch/checkpatch_osmo.sh index 91e9abe..f9cc74f 100755 --- a/lint/checkpatch/checkpatch_osmo.sh +++ b/lint/checkpatch/checkpatch_osmo.sh @@ -1,6 +1,7 @@ #!/bin/sh -e SCRIPT_DIR="$(dirname "$(realpath "$0")")" -PROJECT="$(basename "$(git rev-parse --show-toplevel)")" +PROJECT_DIR="$(git rev-parse --show-toplevel)" +PROJECT="$(basename "$PROJECT_DIR")" exclude_paths_common() { # Stdout and stderr of regression tests @@ -9,6 +10,21 @@ exclude_paths_common() { echo '--exclude ^debian/changelog$' } +exclude_paths_common_asn1c() { + local pattern="^ \* Generated by asn1c-" + local files="$(find -name '*.c' -o -name '*.h' | cut -d / -f 2-)" + local i + + if [ -z "$files" ]; then + return + fi + + for i in $(grep -l "$pattern" $files); do + # Example: --exclude ^include/osmocom/sabp/SABP_Data-Coding-Scheme.h$ + echo '--exclude ^'$i'$' + done +} + exclude_paths_project() { case "$PROJECT" in libosmocore) @@ -56,8 +72,11 @@ exclude_paths_project() { # * UNNECESSARY_INT: not followed (see https://gerrit.osmocom.org/c/libosmocore/+/25345) # * UNSPECIFIED_INT: not followed (doesn't seem useful for us) +cd "$PROJECT_DIR" + $SCRIPT_DIR/checkpatch.pl \ $(exclude_paths_common) \ + $(exclude_paths_common_asn1c) \ $(exclude_paths_project) \ --ignore ASSIGN_IN_IF \ --ignore AVOID_EXTERNS \ |