[coreboot-gerrit] New patch to review for coreboot: kconfig_lint: merge 'git grep' and 'grep' exclude dir and files

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Tue Jan 26 04:17:51 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/13456

-gerrit

commit ad04facf1bb3212c495bcf65f4f38907c2492e50
Author: Martin Roth <martinroth at google.com>
Date:   Mon Jan 25 16:08:27 2016 -0700

    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 at google.com>
---
 util/lint/kconfig_lint | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index 7fa0d88..4315768 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 at 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}++;
             }



More information about the coreboot-gerrit mailing list