blob: d88caa9c60c67fdee595f0a5662eff7cda479072 [file] [log] [blame]
Martin Rothbcaaad12015-10-18 11:16:25 -06001#!/usr/bin/perl
2
3#
4# This file is part of the coreboot project.
5#
6# Copyright (C) 2015 Martin L Roth <gaumless@gmail.com>
7# Copyright (C) 2015 Google, Inc.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; version 2 of the License.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
Martin Rothbcaaad12015-10-18 11:16:25 -060018
19package kconfig_lint;
20
21use strict;
22use warnings;
23use English qw( -no_match_vars );
24use File::Find;
25use Getopt::Long;
26use Getopt::Std;
27
Martin Rothd8080172015-11-26 19:12:44 -070028my $suppress_error_output = 0; # flag to prevent error text
29my $suppress_warning_output = 0; # flag to prevent warning text
30my $show_note_output = 0; # flag to show minor notes text
31my $print_full_output = 0; # flag to print wholeconfig output
32my $output_file = "-"; # filename of output - set stdout by default
33my $dont_use_git_grep = 0;
Martin Rothbcaaad12015-10-18 11:16:25 -060034
35#globals
Martin Rothd8080172015-11-26 19:12:44 -070036my $top_dir = "."; # Directory where Kconfig is run
37my $root_dir = "src"; # Directory of the top level Kconfig file
38my $errors_found = 0; # count of errors
39my $warnings_found = 0;
40my $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)
41my @exclude_files = ('\.txt$', '\.tex$', 'config', '\.tags'); #files to exclude when looking for symbols
42my $config_file = ""; # name of config file to load symbol values from.
Martin Rothbcaaad12015-10-18 11:16:25 -060043my @wholeconfig; # document the entire kconfig structure
44my %loaded_files; # list of each Kconfig file loaded
45my %symbols; # main structure of all symbols declared
46my %referenced_symbols; # list of symbols referenced by expressions or select statements
47my %used_symbols; # structure of symbols used in the tree, and where they're found
48my @collected_symbols; #
49
50Main();
51
52#-------------------------------------------------------------------------------
53# Main
54#
55# Start by loading and parsing the top level Kconfig, this pulls in the other
56# files. Parsing the tree creates several arrays and hashes that can be used
57# to check for errors
58#-------------------------------------------------------------------------------
59sub Main {
60
61 check_arguments();
62 open( STDOUT, "> $output_file" ) or die "Can't open $output_file for output: $!\n";
63
64 if (defined $top_dir) {
65 chdir $top_dir or die "Error: can't cd to $top_dir\n";
66 }
67
68 die "Error: $top_dir/$root_dir does not exist.\n" unless (-d $root_dir);
69
70 #load the Kconfig tree, checking what we can and building up all the hash tables
71 build_and_parse_kconfig_tree("$root_dir/Kconfig");
72
73 #run checks based on the data that was found
74 find( \&check_if_file_referenced, $root_dir );
75
76 load_config($config_file) if ($config_file);
77
78 check_defaults();
79 check_referenced_symbols();
80
81 collect_used_symbols();
82 check_used_symbols();
83 check_for_ifdef();
84 check_for_def();
85 check_is_enabled();
86
87 print_wholeconfig();
88
Martin Rothd8080172015-11-26 19:12:44 -070089 if ($errors_found) {
90 print "# $errors_found errors";
91 if ($warnings_found) {
92 print ", $warnings_found warnings";
93 }
94 print "\n";
95 }
96
97 exit($errors_found + $warnings_found);
98}
99
100#-------------------------------------------------------------------------------
101# Print and count errors
102#-------------------------------------------------------------------------------
103sub show_error {
104 my ($error_msg) = @_;
105 unless ($suppress_error_output) {
106 print "#!!!!! Error: $error_msg\n";
107 $errors_found++;
108 }
109}
110
111#-------------------------------------------------------------------------------
112# Print and count warnings
113#-------------------------------------------------------------------------------
114sub show_warning {
115 my ($warning_msg) = @_;
116 unless ($suppress_warning_output) {
117 print "#!!!!! Warning: $warning_msg\n";
118 $warnings_found++;
119 }
Martin Rothbcaaad12015-10-18 11:16:25 -0600120}
121
122#-------------------------------------------------------------------------------
123# check_for_ifdef - Look for instances of #ifdef CONFIG_[symbol_name] and
124# #if defined(CONFIG_[symbol_name]).
125#
126# #ifdef symbol is valid for strings, but bool, hex, and INT are always defined.
127# #if defined(symbol) && symbol is also a valid construct.
128#-------------------------------------------------------------------------------
129sub check_for_ifdef {
130 my @ifdef_symbols = @collected_symbols;
131
132 #look for #ifdef SYMBOL
133 while ( my $line = shift @ifdef_symbols ) {
134 if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s+CONFIG_(\w+)/ ) {
135 my $file = $1;
136 my $lineno = $2;
137 my $symbol = $3;
138
139 if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700140 show_error("#ifdef 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600141 }
142 }
143 }
144
145 # look for (#if) defined SYMBOL
146 @ifdef_symbols = @collected_symbols;
147 while ( my $line = shift @ifdef_symbols ) {
148 if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_(\w+)/ ) {
149 my $file = $1;
150 my $lineno = $2;
151 my $symbol = $3;
152
153 #ignore '#if defined(symbol) && symbol' type statements
154 next if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_$symbol.*(&&|\|\|)\s*!?\s*\(?\s*CONFIG_$symbol/ );
155
156 if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700157 show_error("defined 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600158 }
159 }
160 }
161}
162
163#-------------------------------------------------------------------------------
164# check_for_def - Look for instances of #define CONFIG_[symbol_name]
165#
166# Symbols should not be redefined outside of Kconfig, and #defines should not
167# look like symbols
168#-------------------------------------------------------------------------------
169sub check_for_def {
170 my @def_symbols = @collected_symbols;
171
172 #look for #ifdef SYMBOL
173 while ( my $line = shift @def_symbols ) {
174 if ( $line =~ /^([^:]+):(\d+):\s*#\s*define\s+CONFIG_(\w+)/ ) {
175 my $file = $1;
176 my $lineno = $2;
177 my $symbol = $3;
178
179 if ((exists $symbols{$symbol})) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700180 show_warning("#define of symbol 'CONFIG_$symbol' used at $file:$lineno.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600181 } else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700182 show_warning("#define 'CONFIG_$symbol' used at $file:$lineno. Other #defines should not look like Kconfig symbols.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600183 }
184 }
185 }
186}
187
188#-------------------------------------------------------------------------------
189# check_is_enabled - The IS_ENABLED() macro is only valid for symbols of type
190# bool. It would probably work on type hex or int if the value was 0 or 1, but
191# this seems like a bad plan. Using it on strings is dead out.
192#-------------------------------------------------------------------------------
193sub check_is_enabled {
Martin Rothb6acc302015-11-27 18:51:19 -0700194 my @is_enabled_symbols = @collected_symbols;
Martin Rothbcaaad12015-10-18 11:16:25 -0600195
196 #sort through symbols found by grep and store them in a hash for easy access
197 while ( my $line = shift @is_enabled_symbols ) {
Martin Rothb6acc302015-11-27 18:51:19 -0700198 if ( $line =~ /^([^:]+):(\d+):(.+IS_ENABLED.*)/ ) {
Martin Rothbcaaad12015-10-18 11:16:25 -0600199 my $file = $1;
200 my $lineno = $2;
Martin Rothb6acc302015-11-27 18:51:19 -0700201 $line = $3;
202 if ( $line !~ /(.*)IS_ENABLED\s*\(\s*CONFIG_(\w+)(.*)/ ){
203 show_warning("# uninterpreted IS_ENABLED at $file:$lineno: $line");
204 next;
Martin Rothbcaaad12015-10-18 11:16:25 -0600205 }
Martin Rothb6acc302015-11-27 18:51:19 -0700206 while ( $line =~ /(.*)IS_ENABLED\s*\(\s*CONFIG_(\w+)(.*)/ ) {
207 my $symbol = $2;
208 $line = $1.$3;
209
210 #make sure that
211 if (exists $symbols{$symbol}) {
212 if ($symbols{$symbol}{type} ne "bool") {
213 show_error("IS_ENABLED(CONFIG_$symbol) used at $file:$lineno. IS_ENABLED is only valid for type 'bool', not '$symbols{$symbol}{type}'.");
214 }
215 } else {
216 show_error("IS_ENABLED() used on unknown value CONFIG_$symbol at $file:$lineno.");
217 }
218 }
Martin Rothbcaaad12015-10-18 11:16:25 -0600219 }
220 }
221}
222
223#-------------------------------------------------------------------------------
224# check_defaults - Look for defaults that come after a default with no
225# dependencies.
226#
227# TODO - check for defaults with the same dependencies
228#-------------------------------------------------------------------------------
229sub check_defaults {
230
231 # loop through each defined symbol
232 foreach my $sym ( sort ( keys %symbols ) ) {
233 my $default_set = 0;
234 my $default_filename = "";
235 my $default_line_no = "";
236
237 #loop through each instance of that symbol
238 for ( my $sym_num = 0 ; $sym_num <= $symbols{$sym}{count} ; $sym_num++ ) {
239
240 #loop through any defaults for that instance of that symbol, if there are any
241 next unless ( exists $symbols{$sym}{$sym_num}{default_max} );
242 for ( my $def_num = 0 ; $def_num <= $symbols{$sym}{$sym_num}{default_max} ; $def_num++ ) {
243
244 #if a default is already set, display an error
245 if ($default_set) {
246 my $filename = $symbols{$sym}{$sym_num}{file};
247 my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no};
Martin Roth7aa3cea2015-11-27 18:45:45 -0700248 show_warning("Default for '$sym' referenced at $filename:$line_no will never be set - overridden by default set at $default_filename:$default_line_no");
Martin Rothbcaaad12015-10-18 11:16:25 -0600249 }
250 else {
251 #if no default is set, see if this is a default with no dependencies
252 unless ( ( exists $symbols{$sym}{$sym_num}{default}{$def_num}{default_depends_on} )
253 || ( exists $symbols{$sym}{$sym_num}{max_dependency} ) )
254 {
255 $default_set = 1;
256 $default_filename = $symbols{$sym}{$sym_num}{file};
257 $default_line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no};
258 }
259 }
260 }
261 }
262 }
263}
264
265#-------------------------------------------------------------------------------
266# check_referenced_symbols - Make sure the symbols referenced by expressions and
267# select statements are actually valid symbols.
268#-------------------------------------------------------------------------------
269sub check_referenced_symbols {
270
271 #loop through symbols found in expressions and used by 'select' keywords
272 foreach my $key ( sort ( keys %referenced_symbols ) ) {
273
274 #make sure the symbol was defined by a 'config' or 'choice' keyword
275 next if ( exists $symbols{$key} );
276
Martin Rothd8080172015-11-26 19:12:44 -0700277 #loop through each instance of the symbol to print out all of the invalid references
278 for ( my $i = 0 ; $i <= $referenced_symbols{$key}{count} ; $i++ ) {
279 my $filename = $referenced_symbols{$key}{$i}{filename};
280 my $line_no = $referenced_symbols{$key}{$i}{line_no};
Martin Roth7aa3cea2015-11-27 18:45:45 -0700281 show_error("Undefined Symbol '$key' used at $filename:$line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600282 }
283 }
284}
285
286#-------------------------------------------------------------------------------
287#-------------------------------------------------------------------------------
288sub collect_used_symbols {
289 # find all references to CONFIG_ statements in the tree
290
291 if ($dont_use_git_grep) {
292 @collected_symbols = `grep -Irn $exclude_dirs -- "CONFIG_"`;
293 } else {
294 @collected_symbols = `git grep -In -- "CONFIG_"`;
295 }
296
297 my @used_symbols = @collected_symbols;
298
299 #sort through symbols found by grep and store them in a hash for easy access
300 while ( my $line = shift @used_symbols ) {
301 while ( $line =~ /[^A-Za-z0-9_]CONFIG_([A-Za-z0-9_]+)/g ) {
302 my $symbol = $1;
303 my $filename = "";
304 if ($line =~ /^([^:]+):/) {
305 $filename = $1;
306 }
307
308 my $skip = 0;
309 foreach my $exfile ( @exclude_files) {
310 $skip = ($filename =~ /$exfile/);
311 last if $skip;
312 }
313 last if $skip;
314
315 if (exists $used_symbols{$symbol}{count}) {
316 $used_symbols{$symbol}{count}++;
317 } else {
318 $used_symbols{$symbol}{count} = 0;
319 }
320 $used_symbols{$symbol}{"num_$used_symbols{$symbol}{count}"} = $filename;
321 }
322 }
323}
324
325#-------------------------------------------------------------------------------
326# check_used_symbols - Checks to see whether or not the created symbols are
327# actually used.
328#-------------------------------------------------------------------------------
329sub check_used_symbols {
330 # loop through all defined symbols and see if they're used anywhere
331 foreach my $key ( sort ( keys %symbols ) ) {
332
333 #see if they're used internal to Kconfig
334 next if ( exists $referenced_symbols{$key} );
335
336 #see if they're used externally
337 next if exists $used_symbols{$key};
338
339 #loop through the definitions to print out all the places the symbol is defined.
340 for ( my $i = 0 ; $i <= $symbols{$key}{count} ; $i++ ) {
341 my $filename = $symbols{$key}{$i}{file};
342 my $line_no = $symbols{$key}{$i}{line_no};
Martin Roth7aa3cea2015-11-27 18:45:45 -0700343 show_warning("Unused symbol '$key' referenced at $filename:$line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600344 }
345 }
346}
347
348#-------------------------------------------------------------------------------
349# build_and_parse_kconfig_tree
350#-------------------------------------------------------------------------------
351#load the initial file and start parsing it
352sub build_and_parse_kconfig_tree {
353 my ($top_level_kconfig) = @_;
354 my @config_to_parse;
355 my @parseline;
356 my $inside_help = 0; # set to line number of 'help' keyword if this line is inside a help block
357 my @inside_if = (); # stack of if dependencies
358 my $inside_config = ""; # set to symbol name of the config section
359 my @inside_menu = (); # stack of menu names
360 my $inside_choice = "";
361 my $configs_inside_choice;
362
363 #start the tree off by loading the top level kconfig
364 @config_to_parse = load_kconfig_file( $top_level_kconfig, "", 0, 0, "", 0 );
365
366
367 while ( ( @parseline = shift(@config_to_parse) ) && ( exists $parseline[0]{text} ) ) {
368 my $line = $parseline[0]{text};
369 my $filename = $parseline[0]{filename};
370 my $line_no = $parseline[0]{file_line_no};
371
372 #handle help - help text: "help" or "---help---"
373 $inside_help = handle_help( $line, $inside_help, $inside_config, $inside_choice, $filename, $line_no );
374 $parseline[0]{inside_help} = $inside_help;
375
376 #look for basic issues in the line, strip crlf
377 $line = simple_line_checks( $line, $filename, $line_no );
378
379 #strip comments
380 $line =~ s/\s*#.*$//;
381
382 #don't parse any more if we're inside a help block
383 if ($inside_help) {
384 #do nothing
385 }
386
387 #handle config
388 elsif ( $line =~ /^\s*config/ ) {
389 $line =~ /^\s*config\s+([^"\s]+)\s*(?>#.*)?$/;
390 my $symbol = $1;
391 $inside_config = $symbol;
392 if ($inside_choice) {
393 $configs_inside_choice++;
394 }
395 add_symbol( $symbol, \@inside_menu, $filename, $line_no, \@inside_if );
396 }
397
398 #bool|hex|int|string|tristate <expr> [if <expr>]
399 elsif ( $line =~ /^\s*(bool|string|hex|int|tristate)/ ) {
400 $line =~ /^\s*(bool|string|hex|int|tristate)\s*(.*)/;
401 my ( $type, $prompt ) = ( $1, $2 );
402 handle_type( $type, $inside_config, $filename, $line_no );
403 handle_prompt( $prompt, $type, \@inside_menu, $inside_config, $inside_choice, $filename, $line_no );
404 }
405
406 # def_bool|def_tristate <expr> [if <expr>]
407 elsif ( $line =~ /^\s*(def_bool|def_tristate)/ ) {
408 $line =~ /^\s*(def_bool|def_tristate)\s+(.*)/;
409 my ( $orgtype, $default ) = ( $1, $2 );
410 ( my $type = $orgtype ) =~ s/def_//;
411 handle_type( $type, $inside_config, $filename, $line_no );
412 handle_default( $default, $orgtype, $inside_config, $inside_choice, $filename, $line_no );
413 }
414
415 #prompt <prompt> [if <expr>]
416 elsif ( $line =~ /^\s*prompt/ ) {
417 $line =~ /^\s*prompt\s+(.+)/;
418 handle_prompt( $1, "prompt", \@inside_menu, $inside_config, $inside_choice, $filename, $line_no );
419 }
420
421 # default <expr> [if <expr>]
422 elsif ( $line =~ /^\s*default/ ) {
423 $line =~ /^\s*default\s+(.*)/;
424 my $default = $1;
425 handle_default( $default, "default", $inside_config, $inside_choice, $filename, $line_no );
426 }
427
428 # depends on <expr>
429 elsif ( $line =~ /^\s*depends\s+on/ ) {
430 $line =~ /^\s*depends\s+on\s+(.*)$/;
431 my $expr = $1;
432 handle_depends( $expr, $inside_config, $inside_choice, $filename, $line_no );
433 handle_expressions( $expr, $inside_config, $filename, $line_no );
434 }
435
436 # comment <prompt>
437 elsif ( $line =~ /^\s*comment/ ) {
438 $inside_config = "";
439 }
440
441 # choice [symbol]
442 elsif ( $line =~ /^\s*choice/ ) {
443 if ( $line =~ /^\s*choice\s*([A-Za-z0-9_]+)$/ ) {
444 my $symbol = $1;
445 add_symbol( $symbol, \@inside_menu, $filename, $line_no, \@inside_if );
446 handle_type( "bool", $symbol, $filename, $line_no );
447 }
448 $inside_config = "";
449 $inside_choice = "$filename $line_no";
450 $configs_inside_choice = 0;
451 }
452
453 # endchoice
454 elsif ( $line =~ /^\s*endchoice/ ) {
455 $inside_config = "";
456 if ( !$inside_choice ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700457 show_error("'endchoice' keyword not within a choice block at $filename:$line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600458 }
459
460 $inside_choice = "";
461 if ( $configs_inside_choice == 0 ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700462 show_error("choice block has no symbols at $filename:$line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600463 }
464 $configs_inside_choice = 0;
465 }
466
467 # [optional]
468 elsif ( $line =~ /^\s*optional/ ) {
469 if ($inside_config) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700470 show_error("Keyword 'optional' appears inside config for '$inside_config' at $filename:$line_no. This is not valid.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600471 }
472 if ( !$inside_choice ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700473 show_error("Keyword 'optional' appears outside of a choice block at $filename:$line_no. This is not valid.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600474 }
475 }
476
477 # mainmenu <prompt>
478 elsif ( $line =~ /^\s*mainmenu/ ) {
479 $inside_config = "";
480 }
481
482 # menu <prompt>
483 elsif ( $line =~ /^\s*menu/ ) {
484 $line =~ /^\s*menu\s+(.*)/;
485 my $menu = $1;
486 if ( $menu =~ /^\s*"([^"]*)"\s*$/ ) {
487 $menu = $1;
488 }
489
490 $inside_config = "";
491 $inside_choice = "";
492 push( @inside_menu, $menu );
493 }
494
495 # endmenu
496 elsif ( $line =~ /^\s*endmenu/ ) {
497 $inside_config = "";
498 $inside_choice = "";
499 pop @inside_menu;
500 }
501
502 # "if" <expr>
503 elsif ( $line =~ /^\s*if/ ) {
504 $inside_config = "";
505 $line =~ /^\s*if\s+(.*)$/;
506 my $expr = $1;
507 push( @inside_if, $expr );
508 handle_expressions( $expr, $inside_config, $filename, $line_no );
509
510 }
511
512 # endif
513 elsif ( $line =~ /^\s*endif/ ) {
514 $inside_config = "";
515 pop(@inside_if);
516 }
517
518 #range <symbol> <symbol> [if <expr>]
519 elsif ( $line =~ /^\s*range/ ) {
520 $line =~ /^\s*range\s+(\S+)\s+(.*)$/;
521 handle_range( $1, $2, $inside_config, $filename, $line_no );
522 }
523
524 # select <symbol> [if <expr>]
525 elsif ( $line =~ /^\s*select/ ) {
526 unless ($inside_config) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700527 show_error("Keyword 'select' appears outside of config at $filename:$line_no. This is not valid.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600528 }
529
530 if ( $line =~ /^\s*select\s+(.*)$/ ) {
531 $line = $1;
532 my $expression;
533 ( $line, $expression ) = handle_if_line( $line, $inside_config, $filename, $line_no );
534 if ($line) {
535 add_referenced_symbol( $line, $filename, $line_no );
536 }
537 }
538 }
539
540 # source <prompt>
541 elsif ( $line =~ /^\s*source\s+"?([^"\s]+)"?\s*(?>#.*)?$/ ) {
542 my @newfile = load_kconfig_file( $1, $filename, $line_no, 0, $filename, $line_no );
543 unshift( @config_to_parse, @newfile );
544 $parseline[0]{text} = "# '$line'\n";
545 }
546 elsif (
547 ( $line =~ /^\s*#/ ) || #comments
548 ( $line =~ /^\s*$/ ) #blank lines
549 )
550 {
551 # do nothing
552 }
553 else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700554 show_error("$line ($filename:$line_no unrecognized)");
Martin Rothbcaaad12015-10-18 11:16:25 -0600555 }
556
557 push @wholeconfig, @parseline;
558 }
559}
560
561#-------------------------------------------------------------------------------
562#-------------------------------------------------------------------------------
563sub handle_depends {
564 my ( $expr, $inside_config, $inside_choice, $filename, $line_no ) = @_;
565
566 if ($inside_config) {
567 my $sym_num = $symbols{$inside_config}{count};
568 if ( exists $symbols{$inside_config}{$sym_num}{max_dependency} ) {
569 $symbols{$inside_config}{$sym_num}{max_dependency}++;
570 }
571 else {
572 $symbols{$inside_config}{$sym_num}{max_dependency} = 0;
573 }
574
575 my $dep_num = $symbols{$inside_config}{$sym_num}{max_dependency};
576 $symbols{$inside_config}{$sym_num}{dependency}{$dep_num} = $expr;
577 }
578}
579
580#-------------------------------------------------------------------------------
581#-------------------------------------------------------------------------------
582sub add_symbol {
583 my ( $symbol, $menu_array_ref, $filename, $line_no, $ifref ) = @_;
584 my @inside_if = @{$ifref};
585
586 #initialize the symbol or increment the use count.
587 if (( !exists $symbols{$symbol}) || ( !exists $symbols{$symbol}{count} )) {
588 $symbols{$symbol}{count} = 0;
589 }
590 else {
591 $symbols{$symbol}{count}++;
592 }
593
594 # add the location of this instance
595 my $symcount = $symbols{$symbol}{count};
596 $symbols{$symbol}{$symcount}{file} = $filename;
597 $symbols{$symbol}{$symcount}{line_no} = $line_no;
598
599 #Add the menu structure
600 if ( defined @$menu_array_ref[0] ) {
601 $symbols{$symbol}{$symcount}{menu} = $menu_array_ref;
602 }
603
604 #Add any 'if' statements that the symbol is inside as dependencies
605 if (@inside_if) {
606 my $dep_num = 0;
607 for my $dependency (@inside_if) {
608 $symbols{$symbol}{$symcount}{dependency}{$dep_num} = $dependency;
609 $symbols{$symbol}{$symcount}{max_dependency} = $dep_num;
610 $dep_num++;
611 }
612 }
613}
614
615#-------------------------------------------------------------------------------
616# handle range
617#-------------------------------------------------------------------------------
618sub handle_range {
619 my ( $range1, $range2, $inside_config, $filename, $line_no ) = @_;
620
621 my $expression;
622 ( $range2, $expression ) = handle_if_line( $range2, $inside_config, $filename, $line_no );
623
624 $range1 =~ /^\s*(?:0x)?([A-Fa-f0-9]+)\s*$/;
625 my $checkrange1 = $1;
626 $range2 =~ /^\s*(?:0x)?([A-Fa-f0-9]+)\s*$/;
627 my $checkrange2 = $1;
628
629 if ( $checkrange1 && $checkrange2 && ( hex($checkrange1) > hex($checkrange2) ) ) {
Martin Rothd8080172015-11-26 19:12:44 -0700630 show_error("Range entry in $filename line $line_no value 1 ($range1) is greater than value 2 ($range2).");
Martin Rothbcaaad12015-10-18 11:16:25 -0600631 }
632
633 if ($inside_config) {
634 if ( exists( $symbols{$inside_config}{range1} ) ) {
635 if ( ( $symbols{$inside_config}{range1} != $range1 ) || ( $symbols{$inside_config}{range2} != $range2 ) ) {
Martin Rothd8080172015-11-26 19:12:44 -0700636 if ($show_note_output) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700637 print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename:$line_no does";
Martin Rothbcaaad12015-10-18 11:16:25 -0600638 print " not match the previously defined range $symbols{$inside_config}{range1} $symbols{$inside_config}{range2}";
Martin Roth7aa3cea2015-11-27 18:45:45 -0700639 print " defined at $symbols{$inside_config}{range_file}:$symbols{$inside_config}{range_line_no}.\n";
Martin Rothbcaaad12015-10-18 11:16:25 -0600640 }
641 }
642 }
643 else {
644 $symbols{$inside_config}{range1} = $range1;
645 $symbols{$inside_config}{range2} = $range2;
646 $symbols{$inside_config}{range_file} = $filename;
647 $symbols{$inside_config}{range_line_no} = $line_no;
648 }
649 }
650 else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700651 show_error("Range entry at $filename:$line_no is not inside a config block.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600652 }
653}
654
655#-------------------------------------------------------------------------------
656# handle_default
657#-------------------------------------------------------------------------------
658sub handle_default {
659 my ( $default, $name, $inside_config, $inside_choice, $filename, $line_no ) = @_;
660 my $expression;
661 ( $default, $expression ) = handle_if_line( $default, $inside_config, $filename, $line_no );
662
663 if ($inside_config) {
664 handle_expressions( $default, $inside_config, $filename, $line_no );
665 my $sym_num = $symbols{$inside_config}{count};
666
667 unless ( exists $symbols{$inside_config}{$sym_num}{default_max} ) {
668 $symbols{$inside_config}{$sym_num}{default_max} = 0;
669 }
670 my $default_max = $symbols{$inside_config}{$sym_num}{default_max};
671 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default} = $default;
672 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default_line_no} = $line_no;
673 if ($expression) {
674 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default_depends_on} = $expression;
675 }
676 }
677 elsif ($inside_choice) {
678 handle_expressions( $default, $inside_config, $filename, $line_no );
679 }
680 else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700681 show_error("$name entry at $filename:$line_no is not inside a config or choice block.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600682 }
683}
684
685#-------------------------------------------------------------------------------
686# handle_if_line
687#-------------------------------------------------------------------------------
688sub handle_if_line {
689 my ( $exprline, $inside_config, $filename, $line_no ) = @_;
690
691 if ( $exprline !~ /if/ ) {
692 return ( $exprline, "" );
693 }
694
695 #remove any quotes that might have an 'if' in them
696 my $savequote;
697 if ( $exprline =~ /^\s*("[^"]+")/ ) {
698 $savequote = $1;
699 $exprline =~ s/^\s*("[^"]+")//;
700 }
701
702 my $expr = "";
703 if ( $exprline =~ /\s*if\s+(.*)$/ ) {
704 $expr = $1;
705 $exprline =~ s/\s*if\s+.*$//;
706
707 if ($expr) {
708 handle_expressions( $expr, $inside_config, $filename, $line_no );
709 }
710 }
711
712 if ($savequote) {
713 $exprline = $savequote;
714 }
715
716 return ( $exprline, $expr );
717}
718
719#-------------------------------------------------------------------------------
720# handle_expressions - log which symbols are being used
721#-------------------------------------------------------------------------------
722sub handle_expressions {
723 my ( $exprline, $inside_config, $filename, $line_no ) = @_;
724
725 return unless ($exprline);
726
727 #filter constant symbols first
728 if ( $exprline =~ /^\s*"?([yn])"?\s*$/ ) { # constant y/n
729 return;
730 }
731 elsif ( $exprline =~ /^\s*"?((?:-)\d+)"?\s*$/ ) { # int values
732 return;
733 }
734 elsif ( $exprline =~ /^\s*"?((?:-)?(?:0x)?\p{XDigit})+"?\s*$/ ) { # hex values
735 return;
736 }
737 elsif ( $exprline =~ /^\s*("[^"]*")\s*$/ ) { # String values
738 return;
739 }
740 elsif ( $exprline =~ /^\s*([A-Za-z0-9_]+)\s*$/ ) { # <symbol> (1)
741 add_referenced_symbol( $1, $filename, $line_no );
742 }
743 elsif ( $exprline =~ /^\s*!(.+)$/ ) { # '!' <expr> (5)
744
745 handle_expressions( $1, $inside_config, $filename, $line_no );
746 }
747 elsif ( $exprline =~ /^\s*\(([^)]+)\)\s*$/ ) { # '(' <expr> ')' (4)
748 handle_expressions( $1, $inside_config, $filename, $line_no );
749 }
750 elsif ( $exprline =~ /^\s*(.+)\s*!=\s*(.+)\s*$/ ) { # <symbol> '!=' <symbol> (3)
751 handle_expressions( $1, $inside_config, $filename, $line_no );
752 handle_expressions( $2, $inside_config, $filename, $line_no );
753 }
754 elsif ( $exprline =~ /^\s*(.+)\s*=\s*(.+)\s*$/ ) { # <symbol> '=' <symbol> (2)
755 handle_expressions( $1, $inside_config, $filename, $line_no );
756 handle_expressions( $2, $inside_config, $filename, $line_no );
757 }
758 elsif ( $exprline =~ /^\s*([^(]+|\(.+\))\s*&&\s*(.+)\s*$/ ) { # <expr> '&&' <expr> (6)
759 handle_expressions( $1, $inside_config, $filename, $line_no );
760 handle_expressions( $2, $inside_config, $filename, $line_no );
761 }
762 elsif ( $exprline =~ /^\s*([^(]+|\(.+\))\s*\|\|\s*(.+)\s*$/ ) { # <expr> '||' <expr> (7)
763 handle_expressions( $1, $inside_config, $filename, $line_no );
764 handle_expressions( $2, $inside_config, $filename, $line_no );
765 }
766
767 # work around kconfig spec violation for now - paths not in quotes
768 elsif ( $exprline =~ /^\s*([A-Za-z0-9_\-\/]+)\s*$/ ) { # <symbol> (1)
769 return;
770 }
771 else {
Martin Rothd8080172015-11-26 19:12:44 -0700772 show_error("Unrecognized expression '$exprline' in $filename line $line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600773 }
774
775 return;
776}
777
778#-------------------------------------------------------------------------------
779# add_referenced_symbol
780#-------------------------------------------------------------------------------
781sub add_referenced_symbol {
782 my ( $symbol, $filename, $line_no ) = @_;
783 if ( exists $referenced_symbols{$symbol} ) {
784 $referenced_symbols{$symbol}{count}++;
785 $referenced_symbols{$symbol}{ $referenced_symbols{$symbol}{count} }{filename} = $filename;
786 $referenced_symbols{$symbol}{ $referenced_symbols{$symbol}{count} }{line_no} = $line_no;
787 }
788 else {
789 $referenced_symbols{$symbol}{count} = 0;
790 $referenced_symbols{$symbol}{0}{filename} = $filename;
791 $referenced_symbols{$symbol}{0}{line_no} = $line_no;
792 }
793}
794
795#-------------------------------------------------------------------------------
796# handle_help
797#-------------------------------------------------------------------------------
798{
799 #create a non-global static variable by enclosing it and the subroutine
800 my $help_whitespace = ""; #string to show length of the help whitespace
801
802 sub handle_help {
803 my ( $line, $inside_help, $inside_config, $inside_choice, $filename, $line_no ) = @_;
804
805 if ($inside_help) {
806
807 #get the indentation level if it's not already set.
808 if ( ( !$help_whitespace ) && ( $line !~ /^[\r\n]+/ ) ) {
809 $line =~ /^(\s+)/; #find the indentation level.
810 $help_whitespace = $1;
811 if ( !$help_whitespace ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700812 show_warning("$filename:$line_no - help text starts with no whitespace.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600813 return $inside_help;
Martin Rothbcaaad12015-10-18 11:16:25 -0600814 }
815 }
816
817 #help ends at the first line which has a smaller indentation than the first line of the help text.
818 if ( ( $line !~ /$help_whitespace/ ) && ( $line !~ /^[\r\n]+/ ) ) {
819 $inside_help = 0;
820 $help_whitespace = "";
821 }
822 else { #if it's not ended, add the line to the helptext array for the symbol's instance
823 if ($inside_config) {
824 my $sym_num = $symbols{$inside_config}{count};
825 if ($help_whitespace) { $line =~ s/^$help_whitespace//; }
826 push( @{ $symbols{$inside_config}{$sym_num}{helptext} }, $line );
827 }
828 }
829 }
830 elsif ( ( $line =~ /^(\s*)help/ ) || ( $line =~ /^(\s*)---help---/ ) ) {
831 $inside_help = $line_no;
832 if ( ( !$inside_config ) && ( !$inside_choice ) ) {
Martin Rothd8080172015-11-26 19:12:44 -0700833 if ($show_note_output) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700834 print "# Note: $filename:$line_no help is not inside a config or choice block.\n";
Martin Rothbcaaad12015-10-18 11:16:25 -0600835 }
Martin Rothbcaaad12015-10-18 11:16:25 -0600836 }
837 elsif ($inside_config) {
838 $help_whitespace = "";
839 my $sym_num = $symbols{$inside_config}{count};
840 $symbols{$inside_config}{$sym_num}{help_line_no} = $line_no;
841 $symbols{$inside_config}{$sym_num}{helptext} = ();
842 }
843 }
844 return $inside_help;
845 }
846}
847
848#-------------------------------------------------------------------------------
849# handle_type
850#-------------------------------------------------------------------------------
851sub handle_type {
852 my ( $type, $inside_config, $filename, $line_no ) = @_;
853
854 my $expression;
855 ( $type, $expression ) = handle_if_line( $type, $inside_config, $filename, $line_no );
856
857 if ($inside_config) {
858 if ( exists( $symbols{$inside_config}{type} ) ) {
859 if ( $symbols{$inside_config}{type} !~ /$type/ ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700860 show_error("Config '$inside_config' type entry $type at $filename:$line_no does not match $symbols{$inside_config}{type} defined at $symbols{$inside_config}{type_file}:$symbols{$inside_config}{type_line_no}.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600861 }
862 }
863 else {
864 $symbols{$inside_config}{type} = $type;
865 $symbols{$inside_config}{type_file} = $filename;
866 $symbols{$inside_config}{type_line_no} = $line_no;
867 }
868 }
869 else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700870 show_error("Type entry at $filename:$line_no is not inside a config block.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600871 }
872}
873
874#-------------------------------------------------------------------------------
875# handle_prompt
876#-------------------------------------------------------------------------------
877sub handle_prompt {
878 my ( $prompt, $name, $menu_array_ref, $inside_config, $inside_choice, $filename, $line_no ) = @_;
879
880 my $expression;
881 ( $prompt, $expression ) = handle_if_line( $prompt, $inside_config, $filename, $line_no );
882
883 if ($inside_config) {
884 if ( $prompt !~ /^\s*$/ ) {
885 if ( $prompt =~ /^\s*"([^"]*)"\s*$/ ) {
886 $prompt = $1;
887 }
888
889 if ( !defined @$menu_array_ref[0] ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700890 show_error("Symbol '$inside_config' with prompt '$prompt' appears outside of a menu at $filename:$line_no.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600891 }
892
893 my $sym_num = $symbols{$inside_config}{count};
894 unless ( exists $symbols{$inside_config}{$sym_num}{prompt_max} ) {
895 $symbols{$inside_config}{$sym_num}{prompt_max} = 0;
896 }
897 my $prompt_max = $symbols{$inside_config}{$sym_num}{prompt_max};
898 $symbols{$inside_config}{$sym_num}{prompt}{$prompt_max}{prompt} = $prompt;
899 $symbols{$inside_config}{$sym_num}{prompt}{$prompt_max}{prompt_line_no} = $line_no;
900 if ($expression) {
901 $symbols{$inside_config}{$sym_num}{prompt}{$prompt_max}{prompt_depends_on} = $expression;
902 }
903 }
904 }
905 elsif ($inside_choice) {
906
907 #do nothing
908 }
909 else {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700910 show_error("$name entry at $filename:$line_no is not inside a config or choice block.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600911 }
912}
913
914#-------------------------------------------------------------------------------
915# simple_line_checks - Does some basic checks on the current line, then cleans the line
916# up for further processing.
917#-------------------------------------------------------------------------------
918sub simple_line_checks {
919 my ( $line, $filename, $line_no ) = @_;
920
921 #check for spaces instead of tabs
922 if ( $line =~ /^ +/ ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700923 show_error("$filename:$line_no starts with a space.");
Martin Rothbcaaad12015-10-18 11:16:25 -0600924 }
925
926 #verify a linefeed at the end of the line
927 if ( $line !~ /.*\n/ ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700928 show_error("$filename:$line_no does not end with linefeed. This can cause the line to not be recognized by the Kconfig parser.\n#($line)");
Martin Rothbcaaad12015-10-18 11:16:25 -0600929 $line =~ s/\s*$//;
930 }
931 else {
932 chop($line);
933 }
934
935 return $line;
936}
937
938#-------------------------------------------------------------------------------
939# load_kconfig_file - Loads a single Kconfig file or expands * wildcard
940#-------------------------------------------------------------------------------
941sub load_kconfig_file {
942 my ( $input_file, $loadfile, $loadline, $expanded, $topfile, $topline ) = @_;
943 my @file_data;
944 my @dir_file_data;
945
946 #recursively handle coreboot's new source glob operator
947 if ( $input_file =~ /^(.*?)\/\*\/(.*)$/ ) {
948 my $dir_prefix = $1;
949 my $dir_suffix = $2;
950 if ( -d "$dir_prefix" ) {
951
952 opendir( D, "$dir_prefix" ) || die "Can't open directory '$dir_prefix'\n";
953 my @dirlist = sort { $a cmp $b } readdir(D);
954 closedir(D);
955
956 while ( my $directory = shift @dirlist ) {
957
958 #ignore non-directory files
959 if ( ( -d "$dir_prefix/$directory" ) && !( $directory =~ /^\..*/ ) ) {
960 push @dir_file_data, load_kconfig_file( "$dir_prefix/$directory/$dir_suffix", $input_file, $loadline, 1, $loadfile, $loadline );
961 }
962 }
963 }
964
965 #the directory should exist when using a glob
966 else {
Martin Rothd8080172015-11-26 19:12:44 -0700967 show_warning("Could not find dir '$dir_prefix'");
Martin Rothbcaaad12015-10-18 11:16:25 -0600968 }
969 }
970
971 #if the file exists, try to load it.
972 elsif ( -e "$input_file" ) {
973
974 #throw a warning if the file has already been loaded.
975 if ( exists $loaded_files{$input_file} ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700976 show_warning("'$input_file' sourced at $loadfile:$loadline was already loaded by $loaded_files{$input_file}");
Martin Rothbcaaad12015-10-18 11:16:25 -0600977 }
978
979 #load the file's contents and mark the file as loaded for checking later
980 open( my $HANDLE, "<", "$input_file" ) or die "Error: could not open file '$input_file'\n";
981 @file_data = <$HANDLE>;
982 close $HANDLE;
983 $loaded_files{$input_file} = "'$loadfile' line $loadline";
984 }
985
986 # if the file isn't being loaded from a glob, it should exist.
987 elsif ( $expanded == 0 ) {
Martin Roth7aa3cea2015-11-27 18:45:45 -0700988 show_warning("Could not find file '$input_file' sourced at $loadfile:$loadline");
Martin Rothbcaaad12015-10-18 11:16:25 -0600989 }
990
991 my $line_in_file = 0;
992 while ( my $line = shift @file_data ) {
993
994 #handle line continuation.
995 my $continue_line = 0;
996 while ($line =~ /(.*)\s+\\$/) {
997 my $text = $1;
998
999 # get rid of leading whitespace on all but the first and last lines
1000 $text =~ s/^\s*/ / if ($continue_line);
1001
1002 $dir_file_data[$line_in_file]{text} .= $text;
1003 $line = shift @file_data;
1004 $continue_line++;
1005
1006 #put the data into the continued lines (other than the first)
1007 $line =~ /^\s*(.*)\s*$/;
1008
1009 $dir_file_data[$line_in_file + $continue_line]{text} = "\t# continued line ( " . $1 . " )\n";
1010 $dir_file_data[$line_in_file + $continue_line]{filename} = $input_file;
1011 $dir_file_data[$line_in_file + $continue_line]{file_line_no} = $line_in_file + $continue_line + 1;
1012
1013 #get rid of multiple leading spaces for last line
1014 $line = " $1\n";
1015 }
1016
1017 $dir_file_data[$line_in_file]{text} .= $line;
1018 $dir_file_data[$line_in_file]{filename} = $input_file;
1019 $dir_file_data[$line_in_file]{file_line_no} = $line_in_file + 1;
1020
1021 $line_in_file++;
1022 if ($continue_line) {
1023 $line_in_file += $continue_line;
1024 }
1025 }
1026
1027 if ($topfile) {
1028 my %file_data;
1029 $file_data{text} = "\t### File '$input_file' loaded from '$topfile' line $topline\n" ;
1030 $file_data{filename} = $topfile;
1031 $file_data{file_line_no} = "($topline)";
1032 unshift (@dir_file_data, \%file_data);
1033 }
1034
1035 return @dir_file_data;
1036}
1037
1038
1039#-------------------------------------------------------------------------------
1040# print_wholeconfig - prints out the parsed Kconfig file
1041#-------------------------------------------------------------------------------
1042sub print_wholeconfig {
1043
1044 return unless $print_full_output;
1045
1046 for ( my $i = 0 ; $i < $#wholeconfig ; $i++ ) {
1047 my $line = $wholeconfig[$i];
1048 chop( $line->{text} );
1049
1050 #replace tabs with spaces for consistency
1051 $line->{text} =~ s/\t/ /g;
1052 printf "%-120s # $line->{filename} line $line->{file_line_no}\n", $line->{text};
1053 }
1054}
1055
1056#-------------------------------------------------------------------------------
1057# check_if_file_referenced - checks for kconfig files that are not being parsed
1058#-------------------------------------------------------------------------------
1059sub check_if_file_referenced {
1060 my $filename = $File::Find::name;
1061 if ( ( $filename =~ /Kconfig/ ) && ( !exists $loaded_files{$filename} ) ) {
Martin Rothd8080172015-11-26 19:12:44 -07001062 show_warning("'$filename' is never referenced");
Martin Rothbcaaad12015-10-18 11:16:25 -06001063 }
1064}
1065
1066#-------------------------------------------------------------------------------
1067# check_arguments parse the command line arguments
1068#-------------------------------------------------------------------------------
1069sub check_arguments {
1070 my $show_usage = 0;
1071 GetOptions(
1072 'help|?' => sub { usage() },
Martin Rothd8080172015-11-26 19:12:44 -07001073 'e|errors_off' => \$suppress_error_output,
1074 'n|notes' => \$show_note_output,
Martin Rothbcaaad12015-10-18 11:16:25 -06001075 'o|output=s' => \$output_file,
1076 'p|print' => \$print_full_output,
Martin Rothd8080172015-11-26 19:12:44 -07001077 'w|warnings_off' => \$suppress_warning_output,
Martin Rothbcaaad12015-10-18 11:16:25 -06001078 'path=s' => \$top_dir,
1079 'c|config=s' => \$config_file,
1080 'G|no_git_grep' => \$dont_use_git_grep,
1081 );
Martin Rothd8080172015-11-26 19:12:44 -07001082
1083 if ($suppress_error_output) {
1084 $suppress_warning_output = 1;
1085 }
1086 if ($suppress_warning_output) {
1087 $show_note_output=0;
1088 }
Martin Rothbcaaad12015-10-18 11:16:25 -06001089}
1090
1091#-------------------------------------------------------------------------------
1092# usage - Print the arguments for the user
1093#-------------------------------------------------------------------------------
1094sub usage {
1095 print "kconfig_lint <options>\n";
1096 print " -o|--output=file Set output filename\n";
1097 print " -p|--print Print full output\n";
Martin Rothd8080172015-11-26 19:12:44 -07001098 print " -e|--errors_off Don't print warnings or errors\n";
Martin Rothbcaaad12015-10-18 11:16:25 -06001099 print " -w|--warnings_off Don't print warnings\n";
Martin Rothd8080172015-11-26 19:12:44 -07001100 print " -n|--notes Show minor notes\n";
Martin Rothbcaaad12015-10-18 11:16:25 -06001101 print " --path=dir Path to top level kconfig\n";
1102 print " -c|--config=file Filename of config file to load\n";
1103 print " -G|--no_git_grep Use standard grep tools instead of git grep\n";
1104
1105 exit(0);
1106}
1107
11081;