summaryrefslogtreecommitdiff
path: root/util/lint
diff options
context:
space:
mode:
authorMartin Roth <martinroth@google.com>2016-01-25 16:08:27 -0700
committerMartin Roth <martinroth@google.com>2016-01-30 17:26:03 +0100
commit63ea4930e4ea127a317268de58371848944880a2 (patch)
treefa8e3d6e526a3dd74bc5156c0c07de47c8252059 /util/lint
parent721ee01bb0668d2ea207048a11c339313ed248f5 (diff)
kconfig_lint: merge 'git grep' and 'grep' exclude dir and files
The code had originally been using standard grep to look through the coreboot tree for Kconfig symbols. When this was switched to git grep, the --exclude-dir options didn't work, and nothing was added to exclude the directories that shouldn't be searched for symbols. This resulted in invalid warnings as it searched directories that had Kconfig symbols for other projects. This merges the exclusion list for both the regular and git versions of grep for consistent behavior. Change-Id: I69a1e0b30fecca152e02a511c82248b6091b3d8b Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: https://review.coreboot.org/13456 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/lint')
-rwxr-xr-xutil/lint/kconfig_lint22
1 files changed, 7 insertions, 15 deletions
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index 7fa0d8858b..4315768709 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -4,7 +4,7 @@
# This file is part of the coreboot project.
#
# Copyright (C) 2015 Martin L Roth <gaumless@gmail.com>
-# Copyright (C) 2015 Google, Inc.
+# Copyright (C) 2015-2016 Google, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -38,11 +38,10 @@ my $top_dir = "."; # Directory where Kconfig is run
my $root_dir = "src"; # Directory of the top level Kconfig file
my $errors_found = 0; # count of errors
my $warnings_found = 0;
-my $exclude_dirs =
- '--exclude-dir="build" --exclude-dir="coreboot-builds" '
- . '--exclude-dir="payloads" --exclude-dir="configs" '
- . '--exclude-dir="util"'; # directories to exclude when searching for used symbols - NOT USED FOR GIT GREP (TODO)
-my @exclude_files = ( '\.txt$', '\.tex$', 'config', '\.tags' ); #files to exclude when looking for symbols
+my $exclude_dirs_and_files =
+ '^build/\|^coreboot-builds/\|^payloads/libpayload\|^payloads/coreinfo\|^configs/\|^util/\|^\.git/'
+ . '\|' . # directories to exclude when searching for used symbols
+ '\.txt$\|\.tex$\|\.tags'; #files to exclude when looking for symbols
my $config_file = ""; # name of config file to load symbol values from.
my @wholeconfig; # document the entire kconfig structure
my %loaded_files; # list of each Kconfig file loaded
@@ -345,10 +344,10 @@ sub collect_used_symbols {
# find all references to CONFIG_ statements in the tree
if ($dont_use_git_grep) {
- @collected_symbols = `grep -Irn $exclude_dirs -- "CONFIG_"`;
+ @collected_symbols = `grep -Irn -- "CONFIG_" | grep -v '$exclude_dirs_and_files'`;
}
else {
- @collected_symbols = `git grep -In -- "CONFIG_"`;
+ @collected_symbols = `git grep -In -- "CONFIG_" | grep -v '$exclude_dirs_and_files'`;
}
my @used_symbols = @collected_symbols;
@@ -362,13 +361,6 @@ sub collect_used_symbols {
$filename = $1;
}
- my $skip = 0;
- foreach my $exfile (@exclude_files) {
- $skip = ( $filename =~ /$exfile/ );
- last if $skip;
- }
- last if $skip;
-
if ( exists $used_symbols{$symbol}{count} ) {
$used_symbols{$symbol}{count}++;
}