3 # SPDX-License-Identifier: GPL-2.0-only
11 use English
qw( -no_match_vars );
16 # If taint mode is enabled, Untaint the path - git and grep must be in /bin, /usr/bin or /usr/local/bin
18 $ENV{'PATH'} = '/bin:/usr/bin:/usr/local/bin';
19 delete @ENV{ 'IFS', 'CDPATH', 'ENV', 'BASH_ENV' };
22 my $suppress_error_output = 0; # flag to prevent error text
23 my $suppress_warning_output = 0; # flag to prevent warning text
24 my $show_note_output = 0; # flag to show minor notes text
25 my $print_full_output = 0; # flag to print wholeconfig output
26 my $output_file = "-"; # filename of output - set stdout by default
27 my $dont_use_git_grep = 0;
28 my $include_site_local = 0;
31 my $top_dir = "."; # Directory where Kconfig is run
32 my $root_dir = "src"; # Directory of the top level Kconfig file
33 my $errors_found = 0; # count of errors
34 my $warnings_found = 0;
35 my $exclude_dirs_and_files =
36 '^build/\|^coreboot-builds/\|^configs/\|^util/\|^\.git/\|^payloads\|^Documentation\|^3rdparty'
37 . '\|' . # directories to exclude when searching for used symbols
38 '\.config\|\.txt$\|\.tex$\|\.tags\|/kconfig.h\|\.fmd'; #files to exclude when looking for symbols
39 my $payload_files_to_check='payloads/Makefile.mk payloads/external/Makefile.mk';
40 my $config_file = ""; # name of config file to load symbol values from.
41 my @wholeconfig; # document the entire kconfig structure
42 my %loaded_files; # list of each Kconfig file loaded
43 my %symbols; # main structure of all symbols declared
44 my %referenced_symbols; # list of symbols referenced by expressions or select statements
45 my %used_symbols; # structure of symbols used in the tree, and where they're found
46 my @collected_symbols; #
47 my %selected_symbols; # list of symbols that are enabled by a select statement
49 my $exclude_unused = '_SPECIFIC_OPTIONS';
53 #-------------------------------------------------------------------------------
56 # Start by loading and parsing the top level Kconfig, this pulls in the other
57 # files. Parsing the tree creates several arrays and hashes that can be used
59 #-------------------------------------------------------------------------------
63 if ( !($dont_use_git_grep || `git rev-parse --is-inside-work-tree`) ) {
64 $dont_use_git_grep = 1;
65 print STDERR
"\nGit grep unavailable, falling back to regular grep...\n";
67 if ( !$include_site_local) {
68 $exclude_dirs_and_files = "^site-local\|" . $exclude_dirs_and_files;
71 open( STDOUT
, "> $output_file" ) or die "Can't open $output_file for output: $!\n";
73 if ( defined $top_dir ) {
74 chdir $top_dir or die "Error: can't cd to $top_dir\n";
77 die "Error: $top_dir/$root_dir does not exist.\n" unless ( -d
$root_dir );
79 #load the Kconfig tree, checking what we can and building up all the hash tables
80 build_and_parse_kconfig_tree
("$root_dir/Kconfig");
82 load_config
($config_file) if ($config_file);
86 check_referenced_symbols
();
88 collect_used_symbols
();
93 check_selected_symbols
();
95 # Run checks based on the data that was found
96 if ( ( !$suppress_warning_output ) && ( ${^TAINT
} == 0 ) ) {
98 # The find function is tainted - only run it if taint checking
99 # is disabled and warnings are enabled.
100 find
( \
&check_if_file_referenced
, $root_dir );
106 print "# $errors_found errors";
107 if ($warnings_found) {
108 print ", $warnings_found warnings";
113 exit( $errors_found + $warnings_found );
116 #-------------------------------------------------------------------------------
117 # Print and count errors
118 #-------------------------------------------------------------------------------
120 my ($error_msg) = @_;
121 unless ($suppress_error_output) {
122 print "#!!!!! Error: $error_msg\n";
127 #-------------------------------------------------------------------------------
128 # Print and count warnings
129 #-------------------------------------------------------------------------------
131 my ($warning_msg) = @_;
132 unless ($suppress_warning_output) {
133 print "#!!!!! Warning: $warning_msg\n";
138 #-------------------------------------------------------------------------------
139 # check selected symbols for validity
141 # they cannot select symbols created in 'choice' blocks
142 #-------------------------------------------------------------------------------
143 sub check_selected_symbols
{
145 #loop through symbols found in expressions and used by 'select' keywords
146 foreach my $symbol ( sort ( keys %selected_symbols ) ) {
147 my $type_failure = 0;
148 my $choice_failure = 0;
150 #errors selecting symbols that don't exist are already printed, so we
151 #don't need to print them again here
153 #make sure the selected symbols are bools
154 if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type
} ne "bool" ) ) {
158 #make sure we're not selecting choice symbols
159 if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{choice
} ) ) {
163 #loop through each instance of the symbol to print out all of the failures
164 for ( my $i = 0 ; $i <= $referenced_symbols{$symbol}{count
} ; $i++ ) {
165 next if ( !exists $selected_symbols{$symbol}{$i} );
166 my $file = $referenced_symbols{$symbol}{$i}{filename
};
167 my $lineno = $referenced_symbols{$symbol}{$i}{line_no
};
170 "CONFIG_$symbol' selected at $file:$lineno." . " Selects only work on symbols of type bool." );
172 if ($choice_failure) {
174 "'CONFIG_$symbol' selected at $file:$lineno." . " Symbols created in a choice cannot be selected." );
180 #-------------------------------------------------------------------------------
181 # check_for_ifdef - Look for instances of #ifdef CONFIG_[symbol_name] and
182 # #if defined(CONFIG_[symbol_name]).
184 # #ifdef symbol is valid for strings, but bool, hex, and INT are always defined.
185 # #if defined(symbol) && symbol is also a valid construct.
186 #-------------------------------------------------------------------------------
187 sub check_for_ifdef
{
188 my @ifdef_symbols = @collected_symbols;
190 #look for #ifdef SYMBOL
191 while ( my $line = shift @ifdef_symbols ) {
192 if ( $line =~ /^([^:]+):(\d+):\s*#\s*ifn?def\s*\(?\s*CONFIG(?:_|\()(\w+)/ ) {
197 if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type
} ne "string" ) ) {
198 show_error
( "#ifdef 'CONFIG_$symbol' used at $file:$lineno."
199 . " Symbols of type '$symbols{$symbol}{type}' are always defined." );
201 } elsif ( $line =~ /^([^:]+):(\d+):.+defined\s*\(?\s*CONFIG(?:_|\()(\w+)/ ) {
206 if ( ( exists $symbols{$symbol} ) && ( $symbols{$symbol}{type
} ne "string" ) ) {
207 show_error
( "defined(CONFIG_$symbol) used at $file:$lineno."
208 . " Symbols of type '$symbols{$symbol}{type}' are always defined." );
214 #-------------------------------------------------------------------------------
215 # check_for_def - Look for instances of #define CONFIG_[symbol_name]
217 # Symbols should not be redefined outside of Kconfig, and #defines should not
219 #-------------------------------------------------------------------------------
221 my @def_symbols = @collected_symbols;
223 #look for #ifdef SYMBOL
224 while ( my $line = shift @def_symbols ) {
225 if ( $line =~ /^([^:]+):(\d+):\s*#\s*define\s+CONFIG_(\w+)/ ) {
230 if ( ( exists $symbols{$symbol} ) ) {
231 show_error
("#define of symbol 'CONFIG_$symbol' used at $file:$lineno.");
234 show_error
( "#define 'CONFIG_$symbol' used at $file:$lineno."
235 . " Other #defines should not look like Kconfig symbols." );
241 #-------------------------------------------------------------------------------
242 # check_type - Make sure that all symbols have a type defined.
244 # Conflicting types are found when parsing the Kconfig tree.
245 #-------------------------------------------------------------------------------
248 # loop through each defined symbol
249 foreach my $sym ( sort ( keys %symbols ) ) {
251 # Make sure there's a type set for the symbol
252 if (!defined $symbols{$sym}{type
}) {
254 #loop through each instance of that symbol
255 for ( my $sym_num = 0 ; $sym_num <= $symbols{$sym}{count
} ; $sym_num++ ) {
257 my $filename = $symbols{$sym}{$sym_num}{file
};
258 my $line_no = $symbols{$sym}{$sym_num}{line_no
};
260 show_error
("No type defined for symbol $sym defined at $filename:$line_no.");
266 #-------------------------------------------------------------------------------
267 # check_config_macro - The CONFIG() macro is only valid for symbols of type
268 # bool. It would probably work on type hex or int if the value was 0 or 1,
269 # but this seems like a bad plan. Using it on strings is dead out.
271 # The IS_ENABLED() macro is forbidden in coreboot now. Though, as long as
272 # we keep its definition in libpayload for compatibility, we have to check
273 # that it doesn't sneak back in.
274 #-------------------------------------------------------------------------------
275 sub check_config_macro
{
276 my @is_enabled_symbols = @collected_symbols;
278 #sort through symbols found by grep and store them in a hash for easy access
279 while ( my $line = shift @is_enabled_symbols ) {
280 if ( $line =~ /^([^:]+):(\d+):(.+\bCONFIG\(.*)/ ) {
284 while ( $line =~ /(.*)\bCONFIG\(([^)]*)\)(.*)/ ) {
288 #make sure that the type is bool
289 if ( exists $symbols{$symbol} ) {
290 if ( $symbols{$symbol}{type
} ne "bool" ) {
291 show_error
( "CONFIG($symbol) used at $file:$lineno."
292 . " CONFIG() is only valid for type 'bool', not '$symbols{$symbol}{type}'." );
294 } elsif ($symbol =~ /\S+##\S+/ ) {
295 show_warning
( "C preprocessor macro CONFIG_$symbol found at $file:$lineno." );
297 show_error
("CONFIG() used on unknown value ($symbol) at $file:$lineno.");
300 } elsif ( $line =~ /^([^:]+):(\d+):(.+IS_ENABLED.*)/ ) {
304 if ( ( $line !~ /(.*)IS_ENABLED\s*\(\s*CONFIG_(\w+)(.*)/ ) && ( $line !~ /(\/[\
*\
/])(.*)IS_ENABLED/ ) ) {
305 show_error
("# uninterpreted IS_ENABLED at $file:$lineno: $line");
308 while ( $line =~ /(.*)IS_ENABLED\s*\(\s*CONFIG_(\w+)(.*)/ ) {
311 show_error
("IS_ENABLED(CONFIG_$symbol) at $file:$lineno is deprecated. Use CONFIG($symbol) instead.");
313 } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?.*?$/ ) {
317 # If the type is bool, give a warning that CONFIG() should be used
318 if ( exists $symbols{$symbol} ) {
319 if ( $symbols{$symbol}{type
} eq "bool" ) {
320 show_error
( "#if CONFIG_$symbol used at $file:$lineno."
321 . " CONFIG($symbol) should be used for type 'bool'" );
324 } elsif ( $line =~ /^([^:]+):(\d+):\s*#\s*(?:el)?if.*(?:&&|\|\|)\s+!?\s*\(?\s*CONFIG_(\w+)\)?(\s*==\s*1)?$/ ) {
328 # If the type is bool, give a warning that CONFIG() should be used
329 if ( exists $symbols{$symbol} ) {
330 if ( $symbols{$symbol}{type
} eq "bool" ) {
331 show_error
( "#if CONFIG_$symbol used at $file:$lineno."
332 . " CONFIG($symbol) should be used for type 'bool'" );
335 } elsif ( $line =~ /^([^:]+):(\d+):(.+\bCONFIG_.+)/ ) {
339 if ( $file =~ /.*\.(c|h|asl|ld)/ ) {
340 while ( $line =~ /(.*)\bCONFIG_(\w+)(.*)/ && $1 !~ /\/\
/|\/\
*/ ) {
343 if ( exists $symbols{$symbol} ) {
344 if ( $symbols{$symbol}{type
} eq "bool" ) {
345 show_error
( "Naked reference to CONFIG_$symbol used at $file:$lineno."
346 . " A 'bool' Kconfig should always be accessed through CONFIG($symbol)." );
349 show_warning
( "Unknown config option CONFIG_$symbol used at $file:$lineno." );
357 #-------------------------------------------------------------------------------
358 # check_defaults - Look for defaults that come after a default with no
361 # TODO - check for defaults with the same dependencies
362 #-------------------------------------------------------------------------------
365 # loop through each defined symbol
366 foreach my $sym ( sort ( keys %symbols ) ) {
368 my $default_filename = "";
369 my $default_line_no = "";
371 #loop through each instance of that symbol
372 for ( my $sym_num = 0 ; $sym_num <= $symbols{$sym}{count
} ; $sym_num++ ) {
374 #loop through any defaults for that instance of that symbol, if there are any
375 next unless ( exists $symbols{$sym}{$sym_num}{default_max
} );
376 for ( my $def_num = 0 ; $def_num <= $symbols{$sym}{$sym_num}{default_max
} ; $def_num++ ) {
378 my $filename = $symbols{$sym}{$sym_num}{file
};
379 my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no
};
381 # Make sure there's a type set for the symbol
382 next if (!defined $symbols{$sym}{type
});
384 # Symbols created/used inside a choice must not have a default set. The default is set by the choice itself.
385 if ($symbols{$sym}{choice
}) {
386 show_error
("Defining a default for symbol '$sym' at $filename:$line_no, used inside choice at "
387 . "$symbols{$sym}{choice}, is not allowed.");
391 if (! ((($symbols{$sym}{type
} eq "hex") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^0x/)) ||
392 (($symbols{$sym}{type
} eq "int") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^[-0-9]+$/)) ||
393 (($symbols{$sym}{type
} eq "string") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^".*"$/)) ||
394 (($symbols{$sym}{type
} eq "bool") && ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /^[yn]$/)))
397 my ($checksym) = $symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /(\w+)/;
399 if (! exists $symbols{$checksym}) {
401 # verify the symbol type against the default value
402 if ($symbols{$sym}{type
} eq "hex") {
403 show_error
("non hex default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for hex symbol $sym at $filename:$line_no.");
404 } elsif ($symbols{$sym}{type
} eq "int") {
405 show_error
("non int default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for int symbol $sym at $filename:$line_no.");
406 } elsif ($symbols{$sym}{type
} eq "string") {
407 # TODO: Remove special MAINBOARD_DIR check
408 if ($sym ne "MAINBOARD_DIR") {
409 show_error
("no quotes around default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for string symbol $sym at $filename:$line_no.");
411 } elsif ($symbols{$sym}{type
} eq "bool") {
412 if ($symbols{$sym}{$sym_num}{default}{$def_num}{default} =~ /[01YN]/) {
413 show_error
("default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) for bool symbol $sym uses value other than y/n at $filename:$line_no.");
415 show_error
("non bool default value ($symbols{$sym}{$sym_num}{default}{$def_num}{default}) used for bool symbol $sym at $filename:$line_no.");
421 #if a default is already set, display an error
423 show_error
( "Default for '$sym' referenced at $filename:$line_no will never be set"
424 . " - overridden by default set at $default_filename:$default_line_no" );
427 #if no default is set, see if this is a default with no dependencies
428 unless ( ( exists $symbols{$sym}{$sym_num}{default}{$def_num}{default_depends_on
} )
429 || ( exists $symbols{$sym}{$sym_num}{max_dependency
} ) )
432 $default_filename = $symbols{$sym}{$sym_num}{file
};
433 $default_line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no
};
441 #-------------------------------------------------------------------------------
442 # check_referenced_symbols - Make sure the symbols referenced by expressions and
443 # select statements are actually valid symbols.
444 #-------------------------------------------------------------------------------
445 sub check_referenced_symbols
{
447 #loop through symbols found in expressions and used by 'select' keywords
448 foreach my $key ( sort ( keys %referenced_symbols ) ) {
450 #make sure the symbol was defined by a 'config' or 'choice' keyword
451 next if ( exists $symbols{$key} );
453 #loop through each instance of the symbol to print out all of the invalid references
454 for ( my $i = 0 ; $i <= $referenced_symbols{$key}{count
} ; $i++ ) {
455 my $filename = $referenced_symbols{$key}{$i}{filename
};
456 my $line_no = $referenced_symbols{$key}{$i}{line_no
};
457 show_error
("Undefined Symbol '$key' used at $filename:$line_no.");
462 #-------------------------------------------------------------------------------
463 #-------------------------------------------------------------------------------
464 sub collect_used_symbols
{
465 # find all references to CONFIG_ statements in the tree
467 if ($dont_use_git_grep) {
468 @collected_symbols = `grep -Irn -- "CONFIG\\(_\\|(\\)" | grep -v '$exclude_dirs_and_files'; grep -In -- "CONFIG\\(_\\|(\\)" $payload_files_to_check`;
471 @collected_symbols = `git grep -In -- "CONFIG\\(_\\|(\\)" | grep -v '$exclude_dirs_and_files'; git grep -In -- "CONFIG\\(_\\|(\\)" $payload_files_to_check`;
474 my @used_symbols = @collected_symbols;
476 #sort through symbols found by grep and store them in a hash for easy access
477 while ( my $line = shift @used_symbols ) {
478 while ( $line =~ /[^A-Za-z0-9_]CONFIG(?:_|\()([A-Za-z0-9_]+)/g ) {
481 if ( $line =~ /^([^:]+):/ ) {
485 if ( exists $used_symbols{$symbol}{count
} ) {
486 $used_symbols{$symbol}{count
}++;
489 $used_symbols{$symbol}{count
} = 0;
491 $used_symbols{$symbol}{"num_$used_symbols{$symbol}{count}"} = $filename;
496 #-------------------------------------------------------------------------------
497 # check_used_symbols - Checks to see whether or not the created symbols are
499 #-------------------------------------------------------------------------------
500 sub check_used_symbols
{
501 # loop through all defined symbols and see if they're used anywhere
502 foreach my $key ( sort ( keys %symbols ) ) {
504 if ( $key =~ /$exclude_unused/ ) {
508 #see if they're used internal to Kconfig
509 next if ( exists $referenced_symbols{$key} );
511 #see if they're used externally
512 next if exists $used_symbols{$key};
514 #loop through the definitions to print out all the places the symbol is defined.
515 for ( my $i = 0 ; $i <= $symbols{$key}{count
} ; $i++ ) {
516 my $filename = $symbols{$key}{$i}{file
};
517 my $line_no = $symbols{$key}{$i}{line_no
};
518 show_warning
("Unused symbol '$key' referenced at $filename:$line_no.");
523 #-------------------------------------------------------------------------------
524 # build_and_parse_kconfig_tree
525 #-------------------------------------------------------------------------------
526 #load the initial file and start parsing it
527 sub build_and_parse_kconfig_tree
{
528 my ($top_level_kconfig) = @_;
531 my $inside_help = 0; # set to line number of 'help' keyword if this line is inside a help block
532 my @inside_if = (); # stack of if dependencies
533 my $inside_config = ""; # set to symbol name of the config section
534 my @inside_menu = (); # stack of menu names
535 my $inside_choice = "";
536 my $choice_symbol = "";
537 my $configs_inside_choice;
540 #start the tree off by loading the top level kconfig
541 @config_to_parse = load_kconfig_file
( $top_level_kconfig, "", 0, 0, "", 0 );
543 while ( ( @parseline = shift(@config_to_parse) ) && ( exists $parseline[0]{text
} ) ) {
544 my $line = $parseline[0]{text
};
545 my $filename = $parseline[0]{filename
};
546 my $line_no = $parseline[0]{file_line_no
};
548 #handle help - help text: "help" or "---help---"
549 my $lastline_was_help = $inside_help;
550 $inside_help = handle_help
( $line, $inside_help, $inside_config, $inside_choice, $filename, $line_no );
551 $parseline[0]{inside_help
} = $inside_help;
553 #look for basic issues in the line, strip crlf
554 $line = simple_line_checks
( $line, $filename, $line_no );
557 $line =~ s/\s*#.*$//;
559 #don't parse any more if we're inside a help block
565 elsif ( $line =~ /^\s*config\s+/ ) {
566 $line =~ /^\s*config\s+([^"\s]+)\s*(?>#.*)?$/;
568 $inside_config = $symbol;
569 if ($inside_choice) {
570 $configs_inside_choice++;
572 add_symbol
( $symbol, \
@inside_menu, $filename, $line_no, \
@inside_if, $inside_choice );
575 #bool|hex|int|string|tristate <expr> [if <expr>]
576 elsif ( $line =~ /^\s*(bool|string|hex|int|tristate)/ ) {
577 $line =~ /^\s*(bool|string|hex|int|tristate)\s*(.*)/;
578 my ( $type, $prompt ) = ( $1, $2 );
579 handle_type
( $type, $inside_config, $filename, $line_no );
580 handle_prompt
( $prompt, $type, \
@inside_menu, $inside_config, $inside_choice, $filename, $line_no );
583 # def_bool|def_tristate <expr> [if <expr>]
584 elsif ( $line =~ /^\s*(def_bool|def_tristate)/ ) {
585 $line =~ /^\s*(def_bool|def_tristate)\s+(.*)/;
586 my ( $orgtype, $default ) = ( $1, $2 );
587 ( my $type = $orgtype ) =~ s/def_//;
588 handle_type
( $type, $inside_config, $filename, $line_no );
589 handle_default
( $default, $orgtype, $inside_config, $inside_choice, $filename, $line_no );
592 #prompt <prompt> [if <expr>]
593 elsif ( $line =~ /^\s*prompt/ ) {
594 $line =~ /^\s*prompt\s+(.+)/;
595 handle_prompt
( $1, "prompt", \
@inside_menu, $inside_config, $inside_choice, $filename, $line_no );
598 # default <expr> [if <expr>]
599 elsif ( $line =~ /^\s*default/ ) {
600 $line =~ /^\s*default\s+(.*)/;
602 handle_default
( $default, "default", $inside_config, $inside_choice, $filename, $line_no );
606 elsif ( $line =~ /^\s*depends\s+on/ ) {
607 $line =~ /^\s*depends\s+on\s+(.*)$/;
609 handle_depends
( $expr, $inside_config, $inside_choice, $filename, $line_no );
610 handle_expressions
( $expr, $inside_config, $filename, $line_no );
614 elsif ( $line =~ /^\s*comment/ ) {
619 elsif ( $line =~ /^\s*choice/ ) {
620 if ( $line =~ /^\s*choice\s*([A-Za-z0-9_]+)$/ ) {
622 add_symbol
( $symbol, \
@inside_menu, $filename, $line_no, \
@inside_if );
623 handle_type
( "bool", $symbol, $filename, $line_no );
624 $choice_symbol = $symbol;
627 $inside_choice = "$filename:$line_no";
628 $configs_inside_choice = 0;
630 # Kconfig verifies that choice blocks have a prompt
634 elsif ( $line =~ /^\s*endchoice/ ) {
636 if ( !$inside_choice ) {
637 show_error
("'endchoice' keyword not within a choice block at $filename:$line_no.");
641 if (( $configs_inside_choice == 0 ) &&
642 ( $choice_symbol eq "" )) {
643 show_error
("unnamed choice block has no symbols at $filename:$line_no.");
645 $configs_inside_choice = 0;
650 elsif ( $line =~ /^\s*optional/ ) {
651 if ($inside_config) {
652 show_error
( "Keyword 'optional' appears inside config for '$inside_config'"
653 . " at $filename:$line_no. This is not valid." );
655 if ( !$inside_choice ) {
656 show_error
( "Keyword 'optional' appears outside of a choice block"
657 . " at $filename:$line_no. This is not valid." );
662 elsif ( $line =~ /^\s*mainmenu/ ) {
665 # Kconfig alread checks for multiple 'mainmenu' entries and mainmenu entries with no prompt
666 # Possible check: look for 'mainmenu ""'
667 # Possible check: verify that a mainmenu has been specified
671 elsif ( $line =~ /^\s*menu/ ) {
672 $line =~ /^\s*menu\s+(.*)/;
674 if ( $menu =~ /^\s*"([^"]*)"\s*$/ ) {
680 push( @inside_menu, $menu );
684 elsif ( $line =~ /^\s*visible if.*$/ ) {
685 # Must come directly after menu line (and on a separate line)
686 # but kconfig already checks for that.
691 elsif ( $line =~ /^\s*endmenu/ ) {
698 elsif ( $line =~ /^\s*if/ ) {
700 $line =~ /^\s*if\s+(.*)$/;
702 push( @inside_if, $expr );
703 handle_expressions
( $expr, $inside_config, $filename, $line_no );
704 $fileinfo{$filename}{iflevel
}++;
708 elsif ( $line =~ /^\s*endif/ ) {
711 $fileinfo{$filename}{iflevel
}--;
714 #range <symbol> <symbol> [if <expr>]
715 elsif ( $line =~ /^\s*range/ ) {
716 $line =~ /^\s*range\s+(\S+)\s+(.*)$/;
717 handle_range
( $1, $2, $inside_config, $filename, $line_no );
720 # select <symbol> [if <expr>]
721 elsif ( $line =~ /^\s*select/ ) {
722 unless ($inside_config) {
723 show_error
("Keyword 'select' appears outside of config at $filename:$line_no. This is not valid.");
726 if ( $line =~ /^\s*select\s+(.*)$/ ) {
729 ( $line, $expression ) = handle_if_line
( $line, $inside_config, $filename, $line_no );
731 add_referenced_symbol
( $line, $filename, $line_no, 'select' );
737 elsif ( $line =~ /^\s*source\s+"?([^"\s]+)"?\s*(?>#.*)?$/ ) {
739 $parseline[0]{text
} = "# '$line'\n";
740 if ( $line !~ "site-local" || $include_site_local ) {
741 my @newfile = load_kconfig_file
( $input_file, $filename, $line_no, 0, $filename, $line_no );
742 unshift( @config_to_parse, @newfile );
746 ( $line =~ /^\s*#/ ) || #comments
747 ( $line =~ /^\s*$/ ) #blank lines
753 if ($lastline_was_help) {
754 show_error
("The line \"$line\" ($filename:$line_no) wasn't recognized - supposed to be inside help?");
757 show_error
("The line \"$line\" ($filename:$line_no) wasn't recognized");
761 if ( defined $inside_menu[0] ) {
762 $parseline[0]{menus
} = "";
765 $parseline[0]{menus
} = "top";
769 while ( defined $inside_menu[$i] ) {
770 $parseline[0]{menus
} .= "$inside_menu[$i]";
772 if ( defined $inside_menu[$i] ) {
773 $parseline[0]{menus
} .= "->";
776 push @wholeconfig, @parseline;
779 foreach my $file ( keys %fileinfo ) {
780 if ( $fileinfo{$file}{iflevel
} > 0 ) {
781 show_error
("$file has $fileinfo{$file}{iflevel} more 'if' statement(s) than 'endif' statements.");
783 elsif ( $fileinfo{$file}{iflevel
} < 0 ) {
785 "$file has " . ( $fileinfo{$file}{iflevel
} * -1 ) . " more 'endif' statement(s) than 'if' statements." );
790 #-------------------------------------------------------------------------------
791 #-------------------------------------------------------------------------------
793 my ( $expr, $inside_config, $inside_choice, $filename, $line_no ) = @_;
795 if ($inside_config) {
796 my $sym_num = $symbols{$inside_config}{count
};
797 if ( exists $symbols{$inside_config}{$sym_num}{max_dependency
} ) {
798 $symbols{$inside_config}{$sym_num}{max_dependency
}++;
801 $symbols{$inside_config}{$sym_num}{max_dependency
} = 0;
804 my $dep_num = $symbols{$inside_config}{$sym_num}{max_dependency
};
805 $symbols{$inside_config}{$sym_num}{dependency
}{$dep_num} = $expr;
809 #-------------------------------------------------------------------------------
810 #-------------------------------------------------------------------------------
812 my ( $symbol, $menu_array_ref, $filename, $line_no, $ifref, $inside_choice ) = @_;
813 my @inside_if = @
{$ifref};
815 #initialize the symbol or increment the use count.
816 if ( ( !exists $symbols{$symbol} ) || ( !exists $symbols{$symbol}{count
} ) ) {
817 $symbols{$symbol}{count
} = 0;
818 # remember the location of the choice (or "")
819 $symbols{$symbol}{choice
} = $inside_choice;
822 $symbols{$symbol}{count
}++;
823 if ( $inside_choice && $symbols{$symbol}{choice
} ) {
824 show_error
( "$symbol entry at $filename:$line_no has already been created inside another choice block "
825 . "at $symbols{$symbol}{0}{file}:$symbols{$symbol}{0}{line_no}." );
829 # add the location of this instance
830 my $symcount = $symbols{$symbol}{count
};
831 $symbols{$symbol}{$symcount}{file
} = $filename;
832 $symbols{$symbol}{$symcount}{line_no
} = $line_no;
834 #Add the menu structure
835 if ( defined @
$menu_array_ref[0] ) {
836 $symbols{$symbol}{$symcount}{menu
} = $menu_array_ref;
839 #Add any 'if' statements that the symbol is inside as dependencies
842 for my $dependency (@inside_if) {
843 $symbols{$symbol}{$symcount}{dependency
}{$dep_num} = $dependency;
844 $symbols{$symbol}{$symcount}{max_dependency
} = $dep_num;
850 #-------------------------------------------------------------------------------
852 #-------------------------------------------------------------------------------
854 my ( $range1, $range2, $inside_config, $filename, $line_no ) = @_;
857 ( $range2, $expression ) = handle_if_line
( $range2, $inside_config, $filename, $line_no );
859 # Use bigint for large hexadecimal values
861 $range1 =~ /^\s*(?:0x)?([A-Fa-f0-9]+)\s*$/;
862 my $checkrange1 = Math
::BigInt
->new($1);
863 $range2 =~ /^\s*(?:0x)?([A-Fa-f0-9]+)\s*$/;
864 my $checkrange2 = Math
::BigInt
->new($1);
866 if ( $checkrange1 && $checkrange2 && ( $checkrange1 > $checkrange2 ) ) {
867 show_error
("Range entry in $filename line $line_no value 1 ($range1) is greater than value 2 ($range2).");
870 if ($inside_config) {
871 if ( exists( $symbols{$inside_config}{range1
} ) ) {
872 # Convert existing range values to BigInt objects
873 $symbols{$inside_config}{range1
} = Math
::BigInt
->new($symbols{$inside_config}{range1
});
874 $symbols{$inside_config}{range2
} = Math
::BigInt
->new($symbols{$inside_config}{range2
});
876 if ( ( $symbols{$inside_config}{range1
} != $checkrange1 ) || ( $symbols{$inside_config}{range2
} != $checkrange2 ) ) {
877 if ($show_note_output) {
878 print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename:$line_no does";
879 print " not match the previously defined range $symbols{$inside_config}{range1}"
880 . " $symbols{$inside_config}{range2}";
881 print " defined at $symbols{$inside_config}{range_file}:$symbols{$inside_config}{range_line_no}.\n";
886 $symbols{$inside_config}{range1
} = $checkrange1;
887 $symbols{$inside_config}{range2
} = $checkrange2;
888 $symbols{$inside_config}{range_file
} = $filename;
889 $symbols{$inside_config}{range_line_no
} = $line_no;
893 show_error
("Range entry at $filename:$line_no is not inside a config block.");
897 #-------------------------------------------------------------------------------
899 #-------------------------------------------------------------------------------
901 my ( $default, $name, $inside_config, $inside_choice, $filename, $line_no ) = @_;
903 ( $default, $expression ) = handle_if_line
( $default, $inside_config, $filename, $line_no );
905 if ($inside_config) {
906 handle_expressions
( $default, $inside_config, $filename, $line_no );
907 my $sym_num = $symbols{$inside_config}{count
};
909 unless ( exists $symbols{$inside_config}{$sym_num}{default_max
} ) {
910 $symbols{$inside_config}{$sym_num}{default_max
} = 0;
912 my $default_max = $symbols{$inside_config}{$sym_num}{default_max
};
913 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default} = $default;
914 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default_line_no
} = $line_no;
916 $symbols{$inside_config}{$sym_num}{default}{$default_max}{default_depends_on
} = $expression;
919 elsif ($inside_choice) {
920 handle_expressions
( $default, $inside_config, $filename, $line_no );
923 show_error
("$name entry at $filename:$line_no is not inside a config or choice block.");
927 #-------------------------------------------------------------------------------
929 #-------------------------------------------------------------------------------
931 my ( $exprline, $inside_config, $filename, $line_no ) = @_;
933 if ( $exprline !~ /if/ ) {
934 return ( $exprline, "" );
937 #remove any quotes that might have an 'if' in them
939 if ( $exprline =~ /^\s*("[^"]+")/ ) {
941 $exprline =~ s/^\s*("[^"]+")//;
945 if ( $exprline =~ /\s*if\s+(.*)$/ ) {
947 $exprline =~ s/\s*if\s+.*$//;
950 handle_expressions
( $expr, $inside_config, $filename, $line_no );
955 $exprline = $savequote;
958 return ( $exprline, $expr );
961 #-------------------------------------------------------------------------------
962 # handle_symbol - log which symbols are being used
963 #-------------------------------------------------------------------------------
965 my ( $symbol, $filename, $line_no ) = @_;
967 #filter constant symbols first
968 if ( $symbol =~ /^[yn]$/ ) { # constant y/n
971 if ( $symbol =~ /^-?(?:0x)?\p{XDigit}+$/ ) { # int/hex values
974 if ( $symbol =~ /^"[^"]*"$/ ) { # string values
978 if ( $symbol =~ /^([A-Za-z0-9_]+)$/ ) { # actual symbol
979 add_referenced_symbol
( $1, $filename, $line_no, 'expression' );
982 show_error
("Unrecognized expression: expected symbol, "
983 . "found '$symbol' in $filename line $line_no.");
987 #-------------------------------------------------------------------------------
988 # handle_expressions - find symbols in expressions
989 #-------------------------------------------------------------------------------
990 sub handle_expressions
{
991 my ( $exprline, $inside_config, $filename, $line_no ) = @_;
993 my $strip = qr/\s*(.*[^\s]+)\s*/;
995 my $parens = qr/(\((?:[^\(\)]++|(?-1))*\))/;
996 my $quotes = qr/"[^"]*"/;
997 my $balanced = qr/((?:$parens|$quotes|[^\(\)"])+)/;
999 if ( $exprline =~ /^\s*$balanced\s*(?:\|\||&&)\s*(.+)$/ ) {
1000 # <expr> '||' <expr>, <expr> '&&' <expr> (8)(7)
1001 my ( $lhs, $rhs ) = ( $1, $3 );
1002 handle_expressions
( $lhs, $inside_config, $filename, $line_no );
1003 handle_expressions
( $rhs, $inside_config, $filename, $line_no );
1005 elsif ( $exprline =~ /^\s*!(.+)$/ ) {
1007 handle_expressions
( $1, $inside_config, $filename, $line_no );
1009 elsif ( $exprline =~ /^\s*$parens\s*$/ ) {
1010 # '(' <expr> ')' (5)
1011 $exprline =~ /^\s*\((.*)\)\s*$/;
1012 handle_expressions
( $1, $inside_config, $filename, $line_no );
1014 elsif ( $exprline =~ /^\s*($quotes|[^"\s]+)\s*(?:[<>]=?|!=)$strip$/ ) {
1015 # <symbol> '<' <symbol>, <symbol> '!=' <symbol>, etc. (4)(3)
1016 my ( $lhs, $rhs ) = ( $1, $2 );
1017 handle_symbol
( $lhs, $filename, $line_no );
1018 handle_symbol
( $rhs, $filename, $line_no );
1020 elsif ( $exprline =~ /^\s*($quotes|[^"\s]+)\s*=$strip$/ ) {
1021 # <symbol> '=' <symbol> (2)
1022 my ( $lhs, $rhs ) = ( $1, $2 );
1023 handle_symbol
( $lhs, $filename, $line_no );
1024 handle_symbol
( $rhs, $filename, $line_no );
1026 elsif ( $exprline =~ /^$strip$/ ) {
1028 handle_symbol
( $1, $filename, $line_no );
1032 #-------------------------------------------------------------------------------
1033 # add_referenced_symbol
1034 #-------------------------------------------------------------------------------
1035 sub add_referenced_symbol
{
1036 my ( $symbol, $filename, $line_no, $reftype ) = @_;
1037 if ( exists $referenced_symbols{$symbol} ) {
1038 $referenced_symbols{$symbol}{count
}++;
1039 $referenced_symbols{$symbol}{ $referenced_symbols{$symbol}{count
} }{filename
} = $filename;
1040 $referenced_symbols{$symbol}{ $referenced_symbols{$symbol}{count
} }{line_no
} = $line_no;
1043 $referenced_symbols{$symbol}{count
} = 0;
1044 $referenced_symbols{$symbol}{0}{filename
} = $filename;
1045 $referenced_symbols{$symbol}{0}{line_no
} = $line_no;
1048 #mark the symbol as being selected, use referenced symbols for location
1049 if ( $reftype eq 'select' ) {
1050 $selected_symbols{$symbol}{ $referenced_symbols{$symbol}{count
} } = 1;
1054 #-------------------------------------------------------------------------------
1056 #-------------------------------------------------------------------------------
1058 #create a non-global static variable by enclosing it and the subroutine
1059 my $help_whitespace = ""; #string to show length of the help whitespace
1060 my $help_keyword_whitespace = "";
1063 my ( $line, $inside_help, $inside_config, $inside_choice, $filename, $line_no ) = @_;
1067 #get the indentation level if it's not already set.
1068 if ( ( !$help_whitespace ) && ( $line !~ /^[\r\n]+/ ) ) {
1069 $line =~ /^(\s+)/; #find the indentation level.
1070 $help_whitespace = $1;
1071 if ( !$help_whitespace ) {
1072 show_error
("$filename:$line_no - help text starts with no whitespace.");
1073 return $inside_help;
1075 elsif ($help_keyword_whitespace eq $help_whitespace) {
1076 show_error
("$filename:$line_no - help text needs additional indentation.");
1077 return $inside_help;
1081 #help ends at the first line which has a smaller indentation than the first line of the help text.
1082 if ( ( $line !~ /^$help_whitespace/ ) && ( $line !~ /^[\r\n]+/ ) ) {
1084 $help_whitespace = "";
1085 $help_keyword_whitespace = "";
1087 else { #if it's not ended, add the line to the helptext array for the symbol's instance
1088 if ($inside_config) {
1089 my $sym_num = $symbols{$inside_config}{count
};
1090 if ($help_whitespace) { $line =~ s/^$help_whitespace//; }
1091 push( @
{ $symbols{$inside_config}{$sym_num}{helptext
} }, $line );
1093 if ( ($help_keyword_whitespace eq $help_whitespace) && ( $line !~ /^[\r\n]+/ ) ) {
1094 show_error
("$filename:$line_no - help text needs additional indentation.");
1098 elsif ( ( $line =~ /^(\s*)help/ ) || ( $line =~ /^(\s*)---help---/ ) ) {
1099 $inside_help = $line_no;
1101 $help_keyword_whitespace = $1;
1102 if ( ( !$inside_config ) && ( !$inside_choice ) ) {
1103 if ($show_note_output) {
1104 print "# Note: $filename:$line_no help is not inside a config or choice block.\n";
1107 elsif ($inside_config) {
1108 $help_whitespace = "";
1109 my $sym_num = $symbols{$inside_config}{count
};
1110 $symbols{$inside_config}{$sym_num}{help_line_no
} = $line_no;
1111 $symbols{$inside_config}{$sym_num}{helptext
} = ();
1114 return $inside_help;
1118 #-------------------------------------------------------------------------------
1120 #-------------------------------------------------------------------------------
1122 my ( $type, $inside_config, $filename, $line_no ) = @_;
1125 ( $type, $expression ) = handle_if_line
( $type, $inside_config, $filename, $line_no );
1127 if ( $type =~ /tristate/ ) {
1128 show_error
("$filename:$line_no - tristate types are not used.");
1131 if ($inside_config) {
1132 if ( exists( $symbols{$inside_config}{type
} ) ) {
1133 if ( $symbols{$inside_config}{type
} !~ /$type/ ) {
1134 show_error
( "Config '$inside_config' type entry $type"
1135 . " at $filename:$line_no does not match $symbols{$inside_config}{type}"
1136 . " defined at $symbols{$inside_config}{type_file}:$symbols{$inside_config}{type_line_no}." );
1140 $symbols{$inside_config}{type
} = $type;
1141 $symbols{$inside_config}{type_file
} = $filename;
1142 $symbols{$inside_config}{type_line_no
} = $line_no;
1146 show_error
("Type entry at $filename:$line_no is not inside a config block.");
1150 #-------------------------------------------------------------------------------
1152 #-------------------------------------------------------------------------------
1154 my ( $prompt, $name, $menu_array_ref, $inside_config, $inside_choice, $filename, $line_no ) = @_;
1157 ( $prompt, $expression ) = handle_if_line
( $prompt, $inside_config, $filename, $line_no );
1159 if ($inside_config) {
1160 if ( $prompt !~ /^\s*$/ ) {
1161 if ( $prompt =~ /^\s*"([^"]*)"\s*$/ ) {
1165 #display an error if there's a prompt at the top menu level
1166 if ( !defined @
$menu_array_ref[0] ) {
1167 show_error
( "Symbol '$inside_config' with prompt '$prompt' appears outside of a menu"
1168 . " at $filename:$line_no." );
1171 my $sym_num = $symbols{$inside_config}{count
};
1172 if ( !exists $symbols{$inside_config}{$sym_num}{prompt_max
} ) {
1173 $symbols{$inside_config}{$sym_num}{prompt_max
} = 0;
1176 $symbols{$inside_config}{$sym_num}{prompt_max
}++;
1178 my $prompt_max = $symbols{$inside_config}{$sym_num}{prompt_max
};
1179 $symbols{$inside_config}{$sym_num}{prompt
}{$prompt_max}{prompt
} = $prompt;
1180 $symbols{$inside_config}{$sym_num}{prompt
}{$prompt_max}{prompt_line_no
} = $line_no;
1182 $symbols{$inside_config}{$sym_num}{prompt
}{$prompt_max}{prompt_menu
} = @
$menu_array_ref;
1184 $symbols{$inside_config}{$sym_num}{prompt
}{$prompt_max}{prompt_depends_on
} = $expression;
1188 elsif ($inside_choice) {
1193 show_error
("$name entry at $filename:$line_no is not inside a config or choice block.");
1197 #-------------------------------------------------------------------------------
1198 # simple_line_checks - Does some basic checks on the current line, then cleans the line
1199 # up for further processing.
1200 #-------------------------------------------------------------------------------
1201 sub simple_line_checks
{
1202 my ( $line, $filename, $line_no ) = @_;
1204 #check for spaces instead of tabs
1205 if ( $line =~ /^ +/ ) {
1206 show_error
("$filename:$line_no starts with a space.");
1209 #verify a linefeed at the end of the line
1210 if ( $line !~ /.*\n/ ) {
1211 show_error
( "$filename:$line_no does not end with linefeed."
1212 . " This can cause the line to not be recognized by the Kconfig parser.\n#($line)" );
1222 #-------------------------------------------------------------------------------
1223 # load_kconfig_file - Loads a single Kconfig file or expands * wildcard
1224 #-------------------------------------------------------------------------------
1225 sub load_kconfig_file
{
1226 my ( $input_file, $loadfile, $loadline, $expanded, $topfile, $topline ) = @_;
1230 #recursively handle coreboot's new source glob operator
1231 if ( $input_file =~ /^(.*?)\/(\w
*)\
*(\w
*)\
/(.*)$/ ) {
1232 my $dir_prefix = $1;
1233 my $dir_glob_prefix = $2;
1234 my $dir_glob_suffix = $3;
1235 my $dir_suffix = $4;
1236 if ( -d
"$dir_prefix" ) {
1238 opendir( D
, "$dir_prefix" ) || die "Can't open directory '$dir_prefix'\n";
1239 my @dirlist = sort { $a cmp $b } readdir(D
);
1242 while ( my $directory = shift @dirlist ) {
1244 #ignore non-directory files
1245 if ( ( -d
"$dir_prefix/$directory" ) && !( $directory =~ /^\
..*/ )
1246 && ( $directory =~ /\Q$dir_glob_prefix\E.*\Q$dir_glob_suffix\E/ ) ) {
1247 push @dir_file_data,
1248 load_kconfig_file
( "$dir_prefix/$directory/$dir_suffix",
1249 $input_file, $loadline, 1, $loadfile, $loadline );
1254 #the directory should exist when using a glob
1256 show_error
("Could not find dir '$dir_prefix'");
1260 #if the file exists, try to load it.
1261 elsif ( -e
"$input_file" ) {
1263 #throw a warning if the file has already been loaded.
1264 if ( exists $loaded_files{$input_file} ) {
1265 show_warning
("'$input_file' sourced at $loadfile:$loadline was already loaded by $loaded_files{$input_file}");
1268 #load the file's contents and mark the file as loaded for checking later
1269 open( my $HANDLE, "<", "$input_file" ) or die "Error: could not open file '$input_file'\n";
1270 @file_data = <$HANDLE>;
1272 $loaded_files{$input_file} = "'$loadfile' line $loadline";
1275 # if the file isn't being loaded from a glob, it should exist.
1276 elsif ( $expanded == 0 ) {
1277 show_warning
("Could not find file '$input_file' sourced at $loadfile:$loadline");
1280 my $line_in_file = 0;
1281 while ( my $line = shift @file_data ) {
1283 #handle line continuation.
1284 my $continue_line = 0;
1285 while ( $line =~ /(.*)\s+\\$/ ) {
1288 # get rid of leading whitespace on all but the first and last lines
1289 $text =~ s/^\s*/ / if ($continue_line);
1291 $dir_file_data[$line_in_file]{text
} .= $text;
1292 $line = shift @file_data;
1295 #put the data into the continued lines (other than the first)
1296 $line =~ /^\s*(.*)\s*$/;
1298 $dir_file_data[ $line_in_file + $continue_line ]{text
} = "\t# continued line ( " . $1 . " )\n";
1299 $dir_file_data[ $line_in_file + $continue_line ]{filename
} = $input_file;
1300 $dir_file_data[ $line_in_file + $continue_line ]{file_line_no
} = $line_in_file + $continue_line + 1;
1302 #get rid of multiple leading spaces for last line
1306 $dir_file_data[$line_in_file]{text
} .= $line;
1307 $dir_file_data[$line_in_file]{filename
} = $input_file;
1308 $dir_file_data[$line_in_file]{file_line_no
} = $line_in_file + 1;
1311 if ($continue_line) {
1312 $line_in_file += $continue_line;
1318 $file_data{text
} = "\t### File '$input_file' loaded from '$topfile' line $topline\n";
1319 $file_data{filename
} = $topfile;
1320 $file_data{file_line_no
} = "($topline)";
1321 unshift( @dir_file_data, \
%file_data );
1324 return @dir_file_data;
1327 #-------------------------------------------------------------------------------
1328 # print_wholeconfig - prints out the parsed Kconfig file
1329 #-------------------------------------------------------------------------------
1330 sub print_wholeconfig
{
1332 return unless $print_full_output;
1334 for ( my $i = 0 ; $i <= $#wholeconfig ; $i++ ) {
1335 my $line = $wholeconfig[$i];
1336 chop( $line->{text
} );
1338 #replace tabs with spaces for consistency
1339 $line->{text
} =~ s/\t/ /g;
1340 printf "%-120s # $line->{filename} line $line->{file_line_no} ($line->{menus})\n", $line->{text
};
1344 #-------------------------------------------------------------------------------
1345 # check_if_file_referenced - checks for kconfig files that are not being parsed
1346 #-------------------------------------------------------------------------------
1347 sub check_if_file_referenced
{
1348 my $filename = $File::Find
::name
;
1349 if ( ( $filename =~ /Kconfig/ )
1350 && ( !$filename =~ /\.orig$/ )
1351 && ( !$filename =~ /~$/ )
1352 && ( !exists $loaded_files{$filename} ) )
1354 show_warning
("'$filename' is never referenced");
1358 #-------------------------------------------------------------------------------
1359 # check_arguments parse the command line arguments
1360 #-------------------------------------------------------------------------------
1361 sub check_arguments
{
1364 'help|?' => sub { usage
() },
1365 'e|errors_off' => \
$suppress_error_output,
1366 'n|notes' => \
$show_note_output,
1367 'o|output=s' => \
$output_file,
1368 'p|print' => \
$print_full_output,
1369 'w|warnings_off' => \
$suppress_warning_output,
1370 'path=s' => \
$top_dir,
1371 'c|config=s' => \
$config_file,
1372 'G|no_git_grep' => \
$dont_use_git_grep,
1373 'S|site_local' => \
$include_site_local,
1376 if ($suppress_error_output) {
1377 $suppress_warning_output = 1;
1379 if ($suppress_warning_output) {
1380 $show_note_output = 0;
1384 #-------------------------------------------------------------------------------
1385 # usage - Print the arguments for the user
1386 #-------------------------------------------------------------------------------
1388 print "kconfig_lint <options>\n";
1389 print " -o|--output=file Set output filename\n";
1390 print " -p|--print Print full output\n";
1391 print " -e|--errors_off Don't print warnings or errors\n";
1392 print " -w|--warnings_off Don't print warnings\n";
1393 print " -n|--notes Show minor notes\n";
1394 print " --path=dir Path to top level kconfig\n";
1395 print " -c|--config=file Filename of config file to load\n";
1396 print " -G|--no_git_grep Use standard grep tools instead of git grep\n";
1397 print " -S|--site_local Include the site-local directory\n";