Martin Roth (martinroth(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12561
-gerrit
commit e88c289d8ab45443e0dd09a45cd587b6f398e786
Author: Martin Roth <martinroth(a)google.com>
Date: Fri Nov 27 18:45:45 2015 -0700
kconfig_lint: Change from '$file at line $line' to $file:$line
Combine the file and line number into a combination that editors
understand when opening files. This makes it easier to edit the
errors.
Change-Id: Id2fae6a0a2ca8d726b95e252d80ac918f4edbe23
Signed-off-by: Martin Roth <martinroth(a)google.com>
---
util/lint/kconfig_lint | 55 +++++++++++++++++++++++++-------------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index 77913a6..9bad31e 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -137,7 +137,7 @@ sub check_for_ifdef {
my $symbol = $3;
if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
- show_error("#ifdef 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
+ show_error("#ifdef 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
}
}
}
@@ -154,7 +154,7 @@ sub check_for_ifdef {
next if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_$symbol.*(&&|\|\|)\s*!?\s*\(?\s*CONFIG_$symbol/ );
if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
- show_error("defined 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
+ show_error("defined 'CONFIG_$symbol' used at $file:$lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
}
}
}
@@ -177,9 +177,9 @@ sub check_for_def {
my $symbol = $3;
if ((exists $symbols{$symbol})) {
- show_warning("#define of symbol 'CONFIG_$symbol' used in $file at line $lineno.");
+ show_warning("#define of symbol 'CONFIG_$symbol' used at $file:$lineno.");
} else {
- show_warning("#define 'CONFIG_$symbol' used in $file at line $lineno. Other #defines should not look like Kconfig symbols.");
+ show_warning("#define 'CONFIG_$symbol' used at $file:$lineno. Other #defines should not look like Kconfig symbols.");
}
}
}
@@ -239,7 +239,7 @@ sub check_defaults {
if ($default_set) {
my $filename = $symbols{$sym}{$sym_num}{file};
my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no};
- show_warning("Default for '$sym' referenced in $filename at line $line_no will never be set - overridden by default set in $default_filename at line $default_line_no");
+ show_warning("Default for '$sym' referenced at $filename:$line_no will never be set - overridden by default set at $default_filename:$default_line_no");
}
else {
#if no default is set, see if this is a default with no dependencies
@@ -272,7 +272,7 @@ sub check_referenced_symbols {
for ( my $i = 0 ; $i <= $referenced_symbols{$key}{count} ; $i++ ) {
my $filename = $referenced_symbols{$key}{$i}{filename};
my $line_no = $referenced_symbols{$key}{$i}{line_no};
- show_error("Undefined Symbol '$key' used in $filename at line $line_no.");
+ show_error("Undefined Symbol '$key' used at $filename:$line_no.");
}
}
}
@@ -334,7 +334,7 @@ sub check_used_symbols {
for ( my $i = 0 ; $i <= $symbols{$key}{count} ; $i++ ) {
my $filename = $symbols{$key}{$i}{file};
my $line_no = $symbols{$key}{$i}{line_no};
- show_warning("Unused symbol '$key' referenced in $filename at line $line_no.");
+ show_warning("Unused symbol '$key' referenced at $filename:$line_no.");
}
}
}
@@ -448,12 +448,12 @@ sub build_and_parse_kconfig_tree {
elsif ( $line =~ /^\s*endchoice/ ) {
$inside_config = "";
if ( !$inside_choice ) {
- show_error("'endchoice' keyword not within a choice block in $filename at line $line_no.");
+ show_error("'endchoice' keyword not within a choice block at $filename:$line_no.");
}
$inside_choice = "";
if ( $configs_inside_choice == 0 ) {
- show_error("choice block has no symbols in $filename at line $line_no.");
+ show_error("choice block has no symbols at $filename:$line_no.");
}
$configs_inside_choice = 0;
}
@@ -461,10 +461,10 @@ sub build_and_parse_kconfig_tree {
# [optional]
elsif ( $line =~ /^\s*optional/ ) {
if ($inside_config) {
- show_error("Keyword 'optional' appears inside config for '$inside_config' in $filename at line $line_no. This is not valid.");
+ show_error("Keyword 'optional' appears inside config for '$inside_config' at $filename:$line_no. This is not valid.");
}
if ( !$inside_choice ) {
- show_error("Keyword 'optional' appears outside of a choice block in $filename at line $line_no. This is not valid.");
+ show_error("Keyword 'optional' appears outside of a choice block at $filename:$line_no. This is not valid.");
}
}
@@ -518,7 +518,7 @@ sub build_and_parse_kconfig_tree {
# select <symbol> [if <expr>]
elsif ( $line =~ /^\s*select/ ) {
unless ($inside_config) {
- show_error("Keyword 'select' appears outside of config in $filename at line $line_no. This is not valid.");
+ show_error("Keyword 'select' appears outside of config at $filename:$line_no. This is not valid.");
}
if ( $line =~ /^\s*select\s+(.*)$/ ) {
@@ -545,7 +545,7 @@ sub build_and_parse_kconfig_tree {
# do nothing
}
else {
- show_error("$line ($filename line $line_no unrecognized)");
+ show_error("$line ($filename:$line_no unrecognized)");
}
push @wholeconfig, @parseline;
@@ -628,10 +628,9 @@ sub handle_range {
if ( exists( $symbols{$inside_config}{range1} ) ) {
if ( ( $symbols{$inside_config}{range1} != $range1 ) || ( $symbols{$inside_config}{range2} != $range2 ) ) {
if ($show_note_output) {
- print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename line $line_no does";
+ print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename:$line_no does";
print " not match the previously defined range $symbols{$inside_config}{range1} $symbols{$inside_config}{range2}";
- print " defined in $symbols{$inside_config}{range_file} on line";
- print " $symbols{$inside_config}{range_line_no}.\n";
+ print " defined at $symbols{$inside_config}{range_file}:$symbols{$inside_config}{range_line_no}.\n";
}
}
}
@@ -643,7 +642,7 @@ sub handle_range {
}
}
else {
- show_error("Range entry in $filename line $line_no is not inside a config block.");
+ show_error("Range entry at $filename:$line_no is not inside a config block.");
}
}
@@ -673,7 +672,7 @@ sub handle_default {
handle_expressions( $default, $inside_config, $filename, $line_no );
}
else {
- show_error("$name entry in $filename line $line_no is not inside a config or choice block.");
+ show_error("$name entry at $filename:$line_no is not inside a config or choice block.");
}
}
@@ -804,7 +803,7 @@ sub add_referenced_symbol {
$line =~ /^(\s+)/; #find the indentation level.
$help_whitespace = $1;
if ( !$help_whitespace ) {
- show_warning("$filename line $line_no help text starts with no whitespace.");
+ show_warning("$filename:$line_no - help text starts with no whitespace.");
return $inside_help;
}
}
@@ -826,7 +825,7 @@ sub add_referenced_symbol {
$inside_help = $line_no;
if ( ( !$inside_config ) && ( !$inside_choice ) ) {
if ($show_note_output) {
- print "# Note: $filename line $line_no help is not inside a config or choice block.\n";
+ print "# Note: $filename:$line_no help is not inside a config or choice block.\n";
}
}
elsif ($inside_config) {
@@ -852,7 +851,7 @@ sub handle_type {
if ($inside_config) {
if ( exists( $symbols{$inside_config}{type} ) ) {
if ( $symbols{$inside_config}{type} !~ /$type/ ) {
- show_error("Config '$inside_config' type entry $type at $filename line $line_no does not match $symbols{$inside_config}{type} defined in $symbols{$inside_config}{type_file} on line $symbols{$inside_config}{type_line_no}.");
+ 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}.");
}
}
else {
@@ -862,7 +861,7 @@ sub handle_type {
}
}
else {
- show_error("Type entry in $filename line $line_no is not inside a config block.");
+ show_error("Type entry at $filename:$line_no is not inside a config block.");
}
}
@@ -882,7 +881,7 @@ sub handle_prompt {
}
if ( !defined @$menu_array_ref[0] ) {
- show_error("Symbol '$inside_config' with prompt '$prompt' appears outside of a menu in $filename at line $line_no.");
+ show_error("Symbol '$inside_config' with prompt '$prompt' appears outside of a menu at $filename:$line_no.");
}
my $sym_num = $symbols{$inside_config}{count};
@@ -902,7 +901,7 @@ sub handle_prompt {
#do nothing
}
else {
- show_error("$name entry in $filename line $line_no is not inside a config or choice block.");
+ show_error("$name entry at $filename:$line_no is not inside a config or choice block.");
}
}
@@ -915,12 +914,12 @@ sub simple_line_checks {
#check for spaces instead of tabs
if ( $line =~ /^ +/ ) {
- show_error("$filename line $line_no starts with a space.");
+ show_error("$filename:$line_no starts with a space.");
}
#verify a linefeed at the end of the line
if ( $line !~ /.*\n/ ) {
- show_error("$filename line $line_no does not end with linefeed. This can cause the line to not be recognized by the Kconfig parser.\n#($line)");
+ 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)");
$line =~ s/\s*$//;
}
else {
@@ -968,7 +967,7 @@ sub load_kconfig_file {
#throw a warning if the file has already been loaded.
if ( exists $loaded_files{$input_file} ) {
- show_warning("'$input_file' sourced in '$loadfile' at line $loadline was already loaded by $loaded_files{$input_file}");
+ show_warning("'$input_file' sourced at $loadfile:$loadline was already loaded by $loaded_files{$input_file}");
}
#load the file's contents and mark the file as loaded for checking later
@@ -980,7 +979,7 @@ sub load_kconfig_file {
# if the file isn't being loaded from a glob, it should exist.
elsif ( $expanded == 0 ) {
- show_warning("Could not find file '$input_file' sourced in $loadfile at line $loadline");
+ show_warning("Could not find file '$input_file' sourced at $loadfile:$loadline");
}
my $line_in_file = 0;
Martin Roth (martinroth(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12555
-gerrit
commit de3b0aa6fe1137b486e1f2126ee07865878dac08
Author: Martin Roth <martinroth(a)google.com>
Date: Thu Nov 26 19:12:44 2015 -0700
kconfig_lint: Separate errors from warnings
- Create subroutines for printing warnings and errors
- Change all the existing warning and error routines to use subroutines
- Add new command line options to suppress errors and to print notes
Change-Id: I04893faffca21c5bb7b51be920cca4620dc283c3
Signed-off-by: Martin Roth <martinroth(a)google.com>
---
util/lint/kconfig_lint | 233 ++++++++++++++++++++-----------------------------
1 file changed, 93 insertions(+), 140 deletions(-)
diff --git a/util/lint/kconfig_lint b/util/lint/kconfig_lint
index 36facb7..77913a6 100755
--- a/util/lint/kconfig_lint
+++ b/util/lint/kconfig_lint
@@ -25,18 +25,21 @@ use File::Find;
use Getopt::Long;
use Getopt::Std;
-my $suppress_error_output = 0; # flag to prevent warning and error text
-my $print_full_output = 0; # flag to print wholeconfig output
-my $output_file = "-"; # filename of output - set stdout by default
-my $dont_use_git_grep = 0;
+my $suppress_error_output = 0; # flag to prevent error text
+my $suppress_warning_output = 0; # flag to prevent warning text
+my $show_note_output = 0; # flag to show minor notes text
+my $print_full_output = 0; # flag to print wholeconfig output
+my $output_file = "-"; # filename of output - set stdout by default
+my $dont_use_git_grep = 0;
#globals
-my $top_dir = "."; # Directory where Kconfig is run
-my $root_dir = "src"; # Directory of the top level Kconfig file
-my $errors_found = 0; # count of warnings and errors
-my $exclude_dirs = '--exclude-dir="build" --exclude-dir="coreboot-builds" --exclude-dir="payloads" --exclude-dir="configs" --exclude-dir="util"'; # directories to exclude when searching for used symbols - NOT USED FOR GIT GREP (TODO)
-my @exclude_files = ('\.txt$', '\.tex$', 'config', '\.tags'); #files to exclude when looking for symbols
-my $config_file = ""; # name of config file to load symbol values from.
+my $top_dir = "."; # Directory where Kconfig is run
+my $root_dir = "src"; # Directory of the top level Kconfig file
+my $errors_found = 0; # count of errors
+my $warnings_found = 0;
+my $exclude_dirs = '--exclude-dir="build" --exclude-dir="coreboot-builds" --exclude-dir="payloads" --exclude-dir="configs" --exclude-dir="util"'; # directories to exclude when searching for used symbols - NOT USED FOR GIT GREP (TODO)
+my @exclude_files = ('\.txt$', '\.tex$', 'config', '\.tags'); #files to exclude when looking for symbols
+my $config_file = ""; # name of config file to load symbol values from.
my @wholeconfig; # document the entire kconfig structure
my %loaded_files; # list of each Kconfig file loaded
my %symbols; # main structure of all symbols declared
@@ -83,7 +86,37 @@ sub Main {
print_wholeconfig();
- exit($errors_found);
+ if ($errors_found) {
+ print "# $errors_found errors";
+ if ($warnings_found) {
+ print ", $warnings_found warnings";
+ }
+ print "\n";
+ }
+
+ exit($errors_found + $warnings_found);
+}
+
+#-------------------------------------------------------------------------------
+# Print and count errors
+#-------------------------------------------------------------------------------
+sub show_error {
+ my ($error_msg) = @_;
+ unless ($suppress_error_output) {
+ print "#!!!!! Error: $error_msg\n";
+ $errors_found++;
+ }
+}
+
+#-------------------------------------------------------------------------------
+# Print and count warnings
+#-------------------------------------------------------------------------------
+sub show_warning {
+ my ($warning_msg) = @_;
+ unless ($suppress_warning_output) {
+ print "#!!!!! Warning: $warning_msg\n";
+ $warnings_found++;
+ }
}
#-------------------------------------------------------------------------------
@@ -104,10 +137,7 @@ sub check_for_ifdef {
my $symbol = $3;
if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: #ifdef 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.\n";
- }
- $errors_found++;
+ show_error("#ifdef 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
}
}
}
@@ -124,10 +154,7 @@ sub check_for_ifdef {
next if ( $line =~ /^([^:]+):(\d+):.+defined\s*\(\s*CONFIG_$symbol.*(&&|\|\|)\s*!?\s*\(?\s*CONFIG_$symbol/ );
if ((exists $symbols{$symbol}) && ($symbols{$symbol}{type} ne "string")) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: defined 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.\n";
- }
- $errors_found++;
+ show_error("defined 'CONFIG_$symbol' used in $file at line $lineno. Symbols of type '$symbols{$symbol}{type}' are always defined.");
}
}
}
@@ -150,15 +177,9 @@ sub check_for_def {
my $symbol = $3;
if ((exists $symbols{$symbol})) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: #define of symbol 'CONFIG_$symbol' used in $file at line $lineno.\n";
- }
- $errors_found++;
+ show_warning("#define of symbol 'CONFIG_$symbol' used in $file at line $lineno.");
} else {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: #define 'CONFIG_$symbol' used in $file at line $lineno. Other #defines should not look like Kconfig symbols.\n";
- }
- $errors_found++;
+ show_warning("#define 'CONFIG_$symbol' used in $file at line $lineno. Other #defines should not look like Kconfig symbols.");
}
}
}
@@ -182,16 +203,13 @@ sub check_is_enabled {
#make sure that
if (exists $symbols{$symbol}) {
if ($symbols{$symbol}{type} ne "bool") {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: IS_ENABLED(CONFIG_$symbol) used in $file at line $lineno. IS_ENABLED is only valid for type 'bool', not '$symbols{$symbol}{type}'.\n";
- }
- $errors_found++;
+ show_error("IS_ENABLED(CONFIG_$symbol) used in $file at line $lineno. IS_ENABLED is only valid for type 'bool', not '$symbols{$symbol}{type}'.");
}
} else {
- print "#!!!!! Warning: IS_ENABLED() used on unknown value CONFIG_$symbol in $file at line $lineno.\n";
+ show_error("IS_ENABLED() used on unknown value CONFIG_$symbol in $file at line $lineno.");
}
} else {
- print "# uninterpreted IS_ENABLED line: $line\n";
+ show_error("# uninterpreted IS_ENABLED line: $line");
}
}
}
@@ -221,10 +239,7 @@ sub check_defaults {
if ($default_set) {
my $filename = $symbols{$sym}{$sym_num}{file};
my $line_no = $symbols{$sym}{$sym_num}{default}{$def_num}{default_line_no};
- unless ($suppress_error_output) {
- print "#!!!!! Error: Default for '$sym' referenced in $filename at line $line_no will never be set - overridden by default set in $default_filename at line $default_line_no \n";
- }
- $errors_found++;
+ show_warning("Default for '$sym' referenced in $filename at line $line_no will never be set - overridden by default set in $default_filename at line $default_line_no");
}
else {
#if no default is set, see if this is a default with no dependencies
@@ -253,14 +268,11 @@ sub check_referenced_symbols {
#make sure the symbol was defined by a 'config' or 'choice' keyword
next if ( exists $symbols{$key} );
- #loop through each instance of the symbol to print out all of the invalid references
- for ( my $i = 0 ; $i <= $referenced_symbols{$key}{count} ; $i++ ) {
- my $filename = $referenced_symbols{$key}{$i}{filename};
- my $line_no = $referenced_symbols{$key}{$i}{line_no};
- unless ($suppress_error_output) {
- print "#!!!!! Error: Undefined Symbol '$key' used in $filename at line $line_no.\n";
- }
- $errors_found++;
+ #loop through each instance of the symbol to print out all of the invalid references
+ for ( my $i = 0 ; $i <= $referenced_symbols{$key}{count} ; $i++ ) {
+ my $filename = $referenced_symbols{$key}{$i}{filename};
+ my $line_no = $referenced_symbols{$key}{$i}{line_no};
+ show_error("Undefined Symbol '$key' used in $filename at line $line_no.");
}
}
}
@@ -322,10 +334,7 @@ sub check_used_symbols {
for ( my $i = 0 ; $i <= $symbols{$key}{count} ; $i++ ) {
my $filename = $symbols{$key}{$i}{file};
my $line_no = $symbols{$key}{$i}{line_no};
- unless ($suppress_error_output) {
- print "#!!!!! Warning: Unused symbol '$key' referenced in $filename at line $line_no.\n";
- }
- $errors_found++;
+ show_warning("Unused symbol '$key' referenced in $filename at line $line_no.");
}
}
}
@@ -439,18 +448,12 @@ sub build_and_parse_kconfig_tree {
elsif ( $line =~ /^\s*endchoice/ ) {
$inside_config = "";
if ( !$inside_choice ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: 'endchoice' keyword not within a choice block in $filename at line $line_no.\n";
- }
- $errors_found++;
+ show_error("'endchoice' keyword not within a choice block in $filename at line $line_no.");
}
$inside_choice = "";
if ( $configs_inside_choice == 0 ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: choice block has no symbols in $filename at line $line_no.\n";
- }
- $errors_found++;
+ show_error("choice block has no symbols in $filename at line $line_no.");
}
$configs_inside_choice = 0;
}
@@ -458,16 +461,10 @@ sub build_and_parse_kconfig_tree {
# [optional]
elsif ( $line =~ /^\s*optional/ ) {
if ($inside_config) {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Keyword 'optional' appears inside config for '$inside_config' in $filename at line $line_no. This is not valid.\n";
- }
- $errors_found++;
+ show_error("Keyword 'optional' appears inside config for '$inside_config' in $filename at line $line_no. This is not valid.");
}
if ( !$inside_choice ) {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Keyword 'optional' appears outside of a choice block in $filename at line $line_no. This is not valid.\n";
- }
- $errors_found++;
+ show_error("Keyword 'optional' appears outside of a choice block in $filename at line $line_no. This is not valid.");
}
}
@@ -521,10 +518,7 @@ sub build_and_parse_kconfig_tree {
# select <symbol> [if <expr>]
elsif ( $line =~ /^\s*select/ ) {
unless ($inside_config) {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Keyword 'select' appears outside of config in $filename at line $line_no. This is not valid.\n";
- }
- $errors_found++;
+ show_error("Keyword 'select' appears outside of config in $filename at line $line_no. This is not valid.");
}
if ( $line =~ /^\s*select\s+(.*)$/ ) {
@@ -551,10 +545,7 @@ sub build_and_parse_kconfig_tree {
# do nothing
}
else {
- unless ($suppress_error_output) {
- print "### $line ($filename line $line_no unrecognized)\n";
- }
- $errors_found++;
+ show_error("$line ($filename line $line_no unrecognized)");
}
push @wholeconfig, @parseline;
@@ -630,17 +621,13 @@ sub handle_range {
my $checkrange2 = $1;
if ( $checkrange1 && $checkrange2 && ( hex($checkrange1) > hex($checkrange2) ) ) {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Range entry in $filename line $line_no value 1 ($range1) is greater than value 2 ($range2).\n";
- }
- $errors_found++;
-
+ show_error("Range entry in $filename line $line_no value 1 ($range1) is greater than value 2 ($range2).");
}
if ($inside_config) {
if ( exists( $symbols{$inside_config}{range1} ) ) {
if ( ( $symbols{$inside_config}{range1} != $range1 ) || ( $symbols{$inside_config}{range2} != $range2 ) ) {
- unless ($suppress_error_output) {
+ if ($show_note_output) {
print "#!!!!! Note: Config '$inside_config' range entry $range1 $range2 at $filename line $line_no does";
print " not match the previously defined range $symbols{$inside_config}{range1} $symbols{$inside_config}{range2}";
print " defined in $symbols{$inside_config}{range_file} on line";
@@ -656,10 +643,7 @@ sub handle_range {
}
}
else {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Range entry in $filename line $line_no is not inside a config block.\n";
- }
- $errors_found++;
+ show_error("Range entry in $filename line $line_no is not inside a config block.");
}
}
@@ -689,10 +673,7 @@ sub handle_default {
handle_expressions( $default, $inside_config, $filename, $line_no );
}
else {
- unless ($suppress_error_output) {
- print "#!!!!! Error: $name entry in $filename line $line_no is not inside a config or choice block.\n";
- }
- $errors_found++;
+ show_error("$name entry in $filename line $line_no is not inside a config or choice block.");
}
}
@@ -783,10 +764,7 @@ sub handle_expressions {
return;
}
else {
- unless ($suppress_error_output) {
- print "#### Unrecognized expression '$exprline' in $filename line $line_no.\n";
- }
- $errors_found++;
+ show_error("Unrecognized expression '$exprline' in $filename line $line_no.");
}
return;
@@ -826,11 +804,8 @@ sub add_referenced_symbol {
$line =~ /^(\s+)/; #find the indentation level.
$help_whitespace = $1;
if ( !$help_whitespace ) {
- unless ($suppress_error_output) {
- print "# Warning: $filename line $line_no help text starts with no whitespace.\n";
- }
+ show_warning("$filename line $line_no help text starts with no whitespace.");
return $inside_help;
- $errors_found++;
}
}
@@ -850,10 +825,9 @@ sub add_referenced_symbol {
elsif ( ( $line =~ /^(\s*)help/ ) || ( $line =~ /^(\s*)---help---/ ) ) {
$inside_help = $line_no;
if ( ( !$inside_config ) && ( !$inside_choice ) ) {
- unless ($suppress_error_output) {
+ if ($show_note_output) {
print "# Note: $filename line $line_no help is not inside a config or choice block.\n";
}
- $errors_found++;
}
elsif ($inside_config) {
$help_whitespace = "";
@@ -878,11 +852,7 @@ sub handle_type {
if ($inside_config) {
if ( exists( $symbols{$inside_config}{type} ) ) {
if ( $symbols{$inside_config}{type} !~ /$type/ ) {
- print "#!!!!! Error: Config '$inside_config' type entry $type at $filename line $line_no does not match";
- print " the previously defined type $symbols{$inside_config}{type}";
- print " defined in $symbols{$inside_config}{type_file} on line";
- print " $symbols{$inside_config}{type_line_no}.\n";
- $errors_found++;
+ show_error("Config '$inside_config' type entry $type at $filename line $line_no does not match $symbols{$inside_config}{type} defined in $symbols{$inside_config}{type_file} on line $symbols{$inside_config}{type_line_no}.");
}
}
else {
@@ -892,10 +862,7 @@ sub handle_type {
}
}
else {
- unless ($suppress_error_output) {
- print "#!!!!! Error: Type entry in $filename line $line_no is not inside a config block.\n";
- }
- $errors_found++;
+ show_error("Type entry in $filename line $line_no is not inside a config block.");
}
}
@@ -915,10 +882,7 @@ sub handle_prompt {
}
if ( !defined @$menu_array_ref[0] ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: Symbol '$inside_config' with prompt '$prompt' appears outside of a menu in $filename at line $line_no. This is discouraged.\n";
- }
- $errors_found++;
+ show_error("Symbol '$inside_config' with prompt '$prompt' appears outside of a menu in $filename at line $line_no.");
}
my $sym_num = $symbols{$inside_config}{count};
@@ -938,10 +902,7 @@ sub handle_prompt {
#do nothing
}
else {
- unless ($suppress_error_output) {
- print "#!!!!! Error: $name entry in $filename line $line_no is not inside a config or choice block.\n";
- }
- $errors_found++;
+ show_error("$name entry in $filename line $line_no is not inside a config or choice block.");
}
}
@@ -954,19 +915,12 @@ sub simple_line_checks {
#check for spaces instead of tabs
if ( $line =~ /^ +/ ) {
- unless ($suppress_error_output) {
- print "# Note: $filename line $line_no starts with a space.\n";
- }
- $errors_found++;
+ show_error("$filename line $line_no starts with a space.");
}
#verify a linefeed at the end of the line
if ( $line !~ /.*\n/ ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: $filename line $line_no does not end with linefeed. This can cause the line to not be recognized by the Kconfig parser.\n";
- print "#($line)\n";
- }
- $errors_found++;
+ show_error("$filename line $line_no does not end with linefeed. This can cause the line to not be recognized by the Kconfig parser.\n#($line)");
$line =~ s/\s*$//;
}
else {
@@ -1005,10 +959,7 @@ sub load_kconfig_file {
#the directory should exist when using a glob
else {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: Could not find dir '$dir_prefix'\n";
- }
- $errors_found++;
+ show_warning("Could not find dir '$dir_prefix'");
}
}
@@ -1017,10 +968,7 @@ sub load_kconfig_file {
#throw a warning if the file has already been loaded.
if ( exists $loaded_files{$input_file} ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: '$input_file' sourced in '$loadfile' at line $loadline was already loaded by $loaded_files{$input_file}\n";
- }
- $errors_found++;
+ show_warning("'$input_file' sourced in '$loadfile' at line $loadline was already loaded by $loaded_files{$input_file}");
}
#load the file's contents and mark the file as loaded for checking later
@@ -1032,10 +980,7 @@ sub load_kconfig_file {
# if the file isn't being loaded from a glob, it should exist.
elsif ( $expanded == 0 ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: Could not find file '$input_file' sourced in $loadfile at line $loadline\n";
- }
- $errors_found++;
+ show_warning("Could not find file '$input_file' sourced in $loadfile at line $loadline");
}
my $line_in_file = 0;
@@ -1109,10 +1054,7 @@ sub print_wholeconfig {
sub check_if_file_referenced {
my $filename = $File::Find::name;
if ( ( $filename =~ /Kconfig/ ) && ( !exists $loaded_files{$filename} ) ) {
- unless ($suppress_error_output) {
- print "#!!!!! Warning: '$filename' is never referenced\n";
- }
- $errors_found++;
+ show_warning("'$filename' is never referenced");
}
}
@@ -1123,13 +1065,22 @@ sub check_arguments {
my $show_usage = 0;
GetOptions(
'help|?' => sub { usage() },
+ 'e|errors_off' => \$suppress_error_output,
+ 'n|notes' => \$show_note_output,
'o|output=s' => \$output_file,
'p|print' => \$print_full_output,
- 'w|warnings_off' => \$suppress_error_output,
+ 'w|warnings_off' => \$suppress_warning_output,
'path=s' => \$top_dir,
'c|config=s' => \$config_file,
'G|no_git_grep' => \$dont_use_git_grep,
);
+
+ if ($suppress_error_output) {
+ $suppress_warning_output = 1;
+ }
+ if ($suppress_warning_output) {
+ $show_note_output=0;
+ }
}
#-------------------------------------------------------------------------------
@@ -1139,7 +1090,9 @@ sub usage {
print "kconfig_lint <options>\n";
print " -o|--output=file Set output filename\n";
print " -p|--print Print full output\n";
+ print " -e|--errors_off Don't print warnings or errors\n";
print " -w|--warnings_off Don't print warnings\n";
+ print " -n|--notes Show minor notes\n";
print " --path=dir Path to top level kconfig\n";
print " -c|--config=file Filename of config file to load\n";
print " -G|--no_git_grep Use standard grep tools instead of git grep\n";
Denis Carikli (GNUtoo(a)no-log.org) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/11873
-gerrit
commit 6e4fd82da0cb8363200c60341aec1415e9e35113
Author: Denis 'GNUtoo' Carikli <GNUtoo(a)no-log.org>
Date: Sun Oct 11 12:35:51 2015 +0200
genbuild_h: Report the git revision in use, and the upstream one it's based on
This fixes the following commit:
"a74d569 genbuild_h.sh: use the last git commit as timesource if available"
This issue also affected reproducible builds when origin/master was not the
same between build setup: different git revision ended up in the "revision"
component in coreboot.rom's cbfs.
In such case the errors will inform the user what to do.
Handling all possible configurations to find the upstream commit is not trivial.
If such configuration is used, the build process will fail on purpose to prevent
from silently introducing non-reproducible builds.
Change-Id: Id1ba8b1ee6d48eecd547df2b6302820719c578ac
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo(a)no-log.org>
---
util/genbuild_h/genbuild_h.sh | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/util/genbuild_h/genbuild_h.sh b/util/genbuild_h/genbuild_h.sh
index 0fac0d0..55cc75f 100755
--- a/util/genbuild_h/genbuild_h.sh
+++ b/util/genbuild_h/genbuild_h.sh
@@ -22,10 +22,36 @@ export LANG=C
export LC_ALL=C
export TZ=UTC
-top=`dirname $0`/../..
+# TODO:
+# Handle git detached branches
+# Handle git branches not tracking upstream remotes
+# Detect which upstream we are using (coreboot, chromeOS) from git
+top=`dirname $0`/../..
if [ -d "${top}/.git" -a -x "$(command -v git)" ]; then
- GITREV=$(LANG= git log remotes/origin/master -1 --format=format:%h)
+ if git branch | grep '^\* (HEAD detached at ' > /dev/null ; then
+ printf " Error: Using a git branch is now required:\n" > /dev/stderr
+ printf " This is required because of reproducible builds.\n" > /dev/stderr
+ printf " Use git checkout -b <branchname>\n" > /dev/stderr
+ exit 1
+ fi
+
+ LOCAL_BRANCH=$(git branch | grep '^\* ' | sed 's#^\* ##')
+ if ! git config --get branch.${LOCAL_BRANCH}.merge > /dev/null ; then
+ printf " Error: Your local branch need to track a remote repository:\n" > /dev/stderr
+ printf " This is required because of reproducible builds.\n" > /dev/stderr
+ printf " Fix example: git branch --set-upstream-to=origin/master\n" > /dev/stderr
+ exit 1
+ fi
+
+ REMOTE_BRANCH_REF=$(git config --get branch.${LOCAL_BRANCH}.merge)
+ REMOTE_NAME=$(git config --get branch.${LOCAL_BRANCH}.remote)
+ REMOTE_BRANCH_NAME=$(basename ${REMOTE_BRANCH_REF})
+ GITREV=$(LANG= git log HEAD -1 --format=format:%h)
+ UPSTREAM_GITREV_FULL=$(git merge-base HEAD \
+ ${REMOTE_NAME}/${REMOTE_BRANCH_NAME})
+ UPSTREAM_GITREV_SHORT=$(git log ${UPSTREAM_GITREV_FULL} --pretty="%h" \
+ | head -n1)
TIMESOURCE=git
DATE=$(git log --pretty=format:%ct -1)
else
@@ -53,7 +79,8 @@ printf "#define COREBOOT_VERSION %s\n" "\"$KERNELVERSION\""
#See if the build is running in a git repo and the git command is available
printf "/* timesource: $TIMESOURCE */\n"
printf "#define COREBOOT_VERSION_TIMESTAMP $DATE\n"
-printf "#define COREBOOT_ORIGIN_GIT_REVISION \"$GITREV\"\n"
+printf "#define COREBOOT_UPSTREAM_GIT_REVISION \"$UPSTREAM_GITREV\"\n"
+printf "#define COREBOOT_GIT_REVISION \"$GITREV\"\n"
printf "#define COREBOOT_EXTRA_VERSION \"%s\"\n" "$COREBOOT_EXTRA_VERSION"
printf "#define COREBOOT_BUILD \"$(our_date "$DATE")\"\n"
the following patch was just integrated into master:
commit edf965a01eab654433a901e15426064b0700c603
Author: Martin Roth <martinroth(a)google.com>
Date: Wed Nov 25 16:58:33 2015 -0700
crossgcc/buildgcc: add parameter to show version number of tool
By adding the version number of tools, we can help people keep up to
date with their tool versions. This will be used now to determine
whether the IASL version being used is the version supported by
coreboot.
Change-Id: I24a68b01c819871f90403869570125e71b96bd70
Signed-off-by: Martin Roth <martinroth(a)google.com>
Reviewed-on: https://review.coreboot.org/12545
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
See https://review.coreboot.org/12545 for details.
-gerrit
Martin Roth (martinroth(a)google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12542
-gerrit
commit e85d46eed357223afc89b09d3e15974ccd2db5c6
Author: Martin Roth <martinroth(a)google.com>
Date: Wed Nov 25 12:50:25 2015 -0700
Makefile: Individualize help targets & set as non-compile targets
- Including the help targets in the list of NOCOMPILE targets means they
can run even if the toolchain is mucked up. Since they contain info on
building the toolchin, this is useful.
- Separate the three current parts of the help target into individual
components: help_coreboot, help_toolchain, and help_kconfig. This is
mostly for the help_toolchin target which will be printed out by
toolchain.inc.
Change-Id: I365d95fd63e22bddd122fb1fede6f04270e03d63
Signed-off-by: Martin Roth <martinroth(a)google.com>
---
Makefile | 2 +-
Makefile.inc | 4 ++--
util/kconfig/Makefile | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile b/Makefile
index 05da7be..99d7139 100644
--- a/Makefile
+++ b/Makefile
@@ -121,7 +121,7 @@ ifeq ($(strip $(HAVE_DOTCONFIG)),)
NOCOMPILE:=1
endif
ifneq ($(MAKECMDGOALS),)
-ifneq ($(filter %config %clean cross% clang iasl lint% what-jenkins-does,$(MAKECMDGOALS)),)
+ifneq ($(filter %config %clean cross% clang iasl lint% help% what-jenkins-does,$(MAKECMDGOALS)),)
NOCOMPILE:=1
endif
ifeq ($(MAKECMDGOALS), %clean)
diff --git a/Makefile.inc b/Makefile.inc
index a1c882b..8caf36b 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -446,8 +446,8 @@ gitconfig:
git config remote.origin.push HEAD:refs/for/master
(git config --global user.name >/dev/null && git config --global user.email >/dev/null) || (printf 'Please configure your name and email in git:\n\n git config --global user.name "Your Name Comes Here"\n git config --global user.email your.email(a)example.com\n'; exit 1)
-help::
- @echo '*** Toolchain ***'
+help_toolchain help::
+ @echo '*** Toolchain targets ***'
@echo ' crossgcc - Build coreboot cross-compilers for all platforms'
@echo ' crosstools - Build coreboot cross-compiler and GDB for all platforms'
@echo ' crossgcc-clean - Remove all built coreboot cross-compilers'
diff --git a/util/kconfig/Makefile b/util/kconfig/Makefile
index a468125..cec676b 100644
--- a/util/kconfig/Makefile
+++ b/util/kconfig/Makefile
@@ -104,8 +104,8 @@ olddefconfig: $(objk)/conf
$< --defconfig=configs/$@ $(Kconfig)
# Help text used by make help
-help::
- @echo '*** Kconfig Help ***'
+help_kconfig help::
+ @echo '*** Kconfig Targets ***'
@echo ' config - Update current config utilising a line-oriented program'
@echo ' nconfig - Update current config utilising a ncurses menu based program'
@echo ' menuconfig - Update current config utilising a menu based program'
the following patch was just integrated into master:
commit 3bb9405494a48f3857862d41361ec756cfa27752
Author: Martin Roth <martinroth(a)google.com>
Date: Tue Nov 24 16:37:15 2015 -0700
ibase/mb899: Fix IASL warning and remark
- Add an empty Operating Region for the empty _REG method
- Move Named objects out of _CRS Method
- Remove Kconfig default disabling IASL warnings as errors
Fixes these items:
dsdt.aml 1449: Method (_CRS, 0)
Remark 2120 - ^ Control Method should be made Serialized
(due to creation of named objects within)
dsdt.aml 1458: Method (_REG, 2)
Warning 3079 - ^ _REG has no corresponding Operation Region
Change-Id: I801a84468097687c91d6ee3f44cec06243355fac
Signed-off-by: Martin Roth <martinroth(a)google.com>
Reviewed-on: https://review.coreboot.org/12531
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
See https://review.coreboot.org/12531 for details.
-gerrit
the following patch was just integrated into master:
commit 4eea174695564f9bef4da5157c0e1684cb3ae7af
Author: Martin Roth <martinroth(a)google.com>
Date: Wed Nov 25 11:50:04 2015 -0700
Makefile.inc: Add build targets for IASL & Clang
- Add specific build targets for IASL & CLANG and help for those targets
- Consolidate tool target .PHONY entries
Change-Id: If2960d75310495d9e486b3a08808463a2ff0c644
Signed-off-by: Martin Roth <martinroth(a)google.com>
Reviewed-on: https://review.coreboot.org/12541
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
See https://review.coreboot.org/12541 for details.
-gerrit