Skip to content

Commit 92a12a1

Browse files
nashifAnas Nashif
authored andcommitted
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 <[email protected]>
1 parent 8c3189c commit 92a12a1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

scripts/checkpatch.pl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
my @use = ();
4343
my %ignore_type = ();
4444
my @ignore = ();
45+
my @exclude = ();
4546
my $help = 0;
4647
my $configuration_file = ".checkpatch.conf";
4748
my $max_line_length = 80;
@@ -72,6 +73,7 @@ sub help {
7273
--subjective, --strict enable more subjective tests
7374
--types TYPE(,TYPE2...) show only these comma separated message types
7475
--ignore TYPE(,TYPE2...) ignore various comma separated message types
76+
--exclude DIR(,DIR22...) exclude directories
7577
--max-line-length=n set the maximum line length, if exceeded, warn
7678
--min-conf-desc-length=n set the min description length, if shorter, warn
7779
--show-types show the message "types" in the output
@@ -144,6 +146,7 @@ sub help {
144146
'subjective!' => \$check,
145147
'strict!' => \$check,
146148
'ignore=s' => \@ignore,
149+
'exclude=s' => \@exclude,
147150
'types=s' => \@use,
148151
'show-types!' => \$show_types,
149152
'max-line-length=i' => \$max_line_length,
@@ -2186,6 +2189,15 @@ sub process {
21862189
}
21872190
$found_file = 1;
21882191
}
2192+
my $skipme = 0;
2193+
foreach (@exclude) {
2194+
if ($realfile =~ m@^(?:$_/)@) {
2195+
$skipme = 1;
2196+
}
2197+
}
2198+
if ($skipme) {
2199+
next;
2200+
}
21892201

21902202
#make up the handle for any error we report on this line
21912203
if ($showfile) {

0 commit comments

Comments
 (0)