diff options
author | Valentin Rothberg <valentinrothberg@gmail.com> | 2015-04-29 10:58:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-05-24 15:15:29 -0400 |
commit | cf132e4a8e070872e3b170a6cc7429b62e441d99 (patch) | |
tree | 77f952428b9962d5a2d0960ac0abed31cb8526d0 /scripts/checkkconfigsymbols.py | |
parent | f5c48149b961012caf3bd0986fc500325647d5d7 (diff) |
checkkconfigsymbols.py: add option -i to ignore files
Sometimes a user might be interested to filter certain reports (e.g.,
the many defconfigs). Now, this can be achieved by specifying a Python
regex with -i / --ignore.
Signed-off-by: Valentin Rothberg <valentinrothberg@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts/checkkconfigsymbols.py')
-rwxr-xr-x | scripts/checkkconfigsymbols.py | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/scripts/checkkconfigsymbols.py b/scripts/checkkconfigsymbols.py index 74086a583d8d..f35c8ac5d9a0 100755 --- a/scripts/checkkconfigsymbols.py +++ b/scripts/checkkconfigsymbols.py | |||
@@ -58,6 +58,12 @@ def parse_options(): | |||
58 | "input format bases on Git log's " | 58 | "input format bases on Git log's " |
59 | "\'commmit1..commit2\'.") | 59 | "\'commmit1..commit2\'.") |
60 | 60 | ||
61 | parser.add_option('-i', '--ignore', dest='ignore', action='store', | ||
62 | default="", | ||
63 | help="Ignore files matching this pattern. Note that " | ||
64 | "the pattern needs to be a Python regex. To " | ||
65 | "ignore defconfigs, specify -i '.*defconfig'.") | ||
66 | |||
61 | parser.add_option('', '--force', dest='force', action='store_true', | 67 | parser.add_option('', '--force', dest='force', action='store_true', |
62 | default=False, | 68 | default=False, |
63 | help="Reset current Git tree even when it's dirty.") | 69 | help="Reset current Git tree even when it's dirty.") |
@@ -80,6 +86,12 @@ def parse_options(): | |||
80 | "'--force' if you\nwant to ignore this warning and " | 86 | "'--force' if you\nwant to ignore this warning and " |
81 | "continue.") | 87 | "continue.") |
82 | 88 | ||
89 | if opts.ignore: | ||
90 | try: | ||
91 | re.match(opts.ignore, "this/is/just/a/test.c") | ||
92 | except: | ||
93 | sys.exit("Please specify a valid Python regex.") | ||
94 | |||
83 | return opts | 95 | return opts |
84 | 96 | ||
85 | 97 | ||
@@ -105,11 +117,11 @@ def main(): | |||
105 | 117 | ||
106 | # get undefined items before the commit | 118 | # get undefined items before the commit |
107 | execute("git reset --hard %s" % commit_a) | 119 | execute("git reset --hard %s" % commit_a) |
108 | undefined_a = check_symbols() | 120 | undefined_a = check_symbols(opts.ignore) |
109 | 121 | ||
110 | # get undefined items for the commit | 122 | # get undefined items for the commit |
111 | execute("git reset --hard %s" % commit_b) | 123 | execute("git reset --hard %s" % commit_b) |
112 | undefined_b = check_symbols() | 124 | undefined_b = check_symbols(opts.ignore) |
113 | 125 | ||
114 | # report cases that are present for the commit but not before | 126 | # report cases that are present for the commit but not before |
115 | for feature in sorted(undefined_b): | 127 | for feature in sorted(undefined_b): |
@@ -129,7 +141,7 @@ def main(): | |||
129 | 141 | ||
130 | # default to check the entire tree | 142 | # default to check the entire tree |
131 | else: | 143 | else: |
132 | undefined = check_symbols() | 144 | undefined = check_symbols(opts.ignore) |
133 | for feature in sorted(undefined): | 145 | for feature in sorted(undefined): |
134 | files = sorted(undefined.get(feature)) | 146 | files = sorted(undefined.get(feature)) |
135 | print "%s\t%s" % (feature, ", ".join(files)) | 147 | print "%s\t%s" % (feature, ", ".join(files)) |
@@ -160,9 +172,10 @@ def get_head(): | |||
160 | return stdout.strip('\n') | 172 | return stdout.strip('\n') |
161 | 173 | ||
162 | 174 | ||
163 | def check_symbols(): | 175 | def check_symbols(ignore): |
164 | """Find undefined Kconfig symbols and return a dict with the symbol as key | 176 | """Find undefined Kconfig symbols and return a dict with the symbol as key |
165 | and a list of referencing files as value.""" | 177 | and a list of referencing files as value. Files matching %ignore are not |
178 | checked for undefined symbols.""" | ||
166 | source_files = [] | 179 | source_files = [] |
167 | kconfig_files = [] | 180 | kconfig_files = [] |
168 | defined_features = set() | 181 | defined_features = set() |
@@ -185,10 +198,17 @@ def check_symbols(): | |||
185 | source_files.append(gitfile) | 198 | source_files.append(gitfile) |
186 | 199 | ||
187 | for sfile in source_files: | 200 | for sfile in source_files: |
201 | if ignore and re.match(ignore, sfile): | ||
202 | # do not check files matching %ignore | ||
203 | continue | ||
188 | parse_source_file(sfile, referenced_features) | 204 | parse_source_file(sfile, referenced_features) |
189 | 205 | ||
190 | for kfile in kconfig_files: | 206 | for kfile in kconfig_files: |
191 | parse_kconfig_file(kfile, defined_features, referenced_features) | 207 | if ignore and re.match(ignore, kfile): |
208 | # do not collect references for files matching %ignore | ||
209 | parse_kconfig_file(kfile, defined_features, dict()) | ||
210 | else: | ||
211 | parse_kconfig_file(kfile, defined_features, referenced_features) | ||
192 | 212 | ||
193 | undefined = {} # {feature: [files]} | 213 | undefined = {} # {feature: [files]} |
194 | for feature in sorted(referenced_features): | 214 | for feature in sorted(referenced_features): |