From 92a12a19ae5ac5fdf441c690c48eed0052df326d Mon Sep 17 00:00:00 2001 From: Anas Nashif Date: Fri, 20 May 2016 18:26:59 -0400 Subject: [PATCH] checkpatch: add option for excluding directories when importing code from external sources, we do not want to fail on checkpatch and want to run full sanity checks. Using --exclude we should be able to exclude a list of well defined locations in the tree that carry sources from other projects with other styles. Change-Id: I7d321e85eed6bc37d5c6879ae88e21d20028a433 Signed-off-by: Anas Nashif --- scripts/checkpatch.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ccd4d11374..28dcee13ce 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -42,6 +42,7 @@ my %use_type = (); my @use = (); my %ignore_type = (); my @ignore = (); +my @exclude = (); my $help = 0; my $configuration_file = ".checkpatch.conf"; my $max_line_length = 80; @@ -72,6 +73,7 @@ Options: --subjective, --strict enable more subjective tests --types TYPE(,TYPE2...) show only these comma separated message types --ignore TYPE(,TYPE2...) ignore various comma separated message types + --exclude DIR(,DIR22...) exclude directories --max-line-length=n set the maximum line length, if exceeded, warn --min-conf-desc-length=n set the min description length, if shorter, warn --show-types show the message "types" in the output @@ -144,6 +146,7 @@ GetOptions( 'subjective!' => \$check, 'strict!' => \$check, 'ignore=s' => \@ignore, + 'exclude=s' => \@exclude, 'types=s' => \@use, 'show-types!' => \$show_types, 'max-line-length=i' => \$max_line_length, @@ -2186,6 +2189,15 @@ sub process { } $found_file = 1; } + my $skipme = 0; + foreach (@exclude) { + if ($realfile =~ m@^(?:$_/)@) { + $skipme = 1; + } + } + if ($skipme) { + next; + } #make up the handle for any error we report on this line if ($showfile) {