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 <dir> 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 <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2016-05-20 18:26:59 -04:00 committed by Anas Nashif
parent 8c3189c646
commit 92a12a19ae

View file

@ -42,6 +42,7 @@ my %use_type = ();
my @use = (); my @use = ();
my %ignore_type = (); my %ignore_type = ();
my @ignore = (); my @ignore = ();
my @exclude = ();
my $help = 0; my $help = 0;
my $configuration_file = ".checkpatch.conf"; my $configuration_file = ".checkpatch.conf";
my $max_line_length = 80; my $max_line_length = 80;
@ -72,6 +73,7 @@ Options:
--subjective, --strict enable more subjective tests --subjective, --strict enable more subjective tests
--types TYPE(,TYPE2...) show only these comma separated message types --types TYPE(,TYPE2...) show only these comma separated message types
--ignore TYPE(,TYPE2...) ignore various 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 --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 --min-conf-desc-length=n set the min description length, if shorter, warn
--show-types show the message "types" in the output --show-types show the message "types" in the output
@ -144,6 +146,7 @@ GetOptions(
'subjective!' => \$check, 'subjective!' => \$check,
'strict!' => \$check, 'strict!' => \$check,
'ignore=s' => \@ignore, 'ignore=s' => \@ignore,
'exclude=s' => \@exclude,
'types=s' => \@use, 'types=s' => \@use,
'show-types!' => \$show_types, 'show-types!' => \$show_types,
'max-line-length=i' => \$max_line_length, 'max-line-length=i' => \$max_line_length,
@ -2186,6 +2189,15 @@ sub process {
} }
$found_file = 1; $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 #make up the handle for any error we report on this line
if ($showfile) { if ($showfile) {