X-Git-Url: https://ruderich.org/simon/gitweb/?p=blhc%2Fblhc.git;a=blobdiff_plain;f=bin%2Fblhc;h=03e8ebfb8b90da4f1472619c05ef7c756aa304be;hp=d966f9340248c5331157568f1fe2673f852d99cb;hb=99243a356c2d5a818b8d1bffb354cd38d2424146;hpb=4d6308c34fb0182db05846df83118bb83ad5497d diff --git a/bin/blhc b/bin/blhc index d966f93..03e8ebf 100755 --- a/bin/blhc +++ b/bin/blhc @@ -44,7 +44,7 @@ sub error_flags { error_color($message, 'red'), $flags, error_color(':', 'yellow'), $line; } -sub error_nonverbose_build { +sub error_non_verbose_build { my ($line) = @_; printf "%s%s %s", @@ -67,7 +67,7 @@ sub any_flags_used { my ($line, @flags) = @_; foreach my $flag (@flags) { - return 1 if $line =~ /\s$flag(\s|\\|$)/; + return 1 if $line =~ /\s$flag(?:\s|\\|$)/; } return 0; @@ -77,7 +77,7 @@ sub all_flags_used { my @missing_flags = (); foreach my $flag (@flags) { - if ($line !~ /\s$flag(\s|\\|$)/) { + if ($line !~ /\s$flag(?:\s|\\|$)/) { push @missing_flags, $flag; } } @@ -112,9 +112,48 @@ sub pic_pie_conflict { return scalar @result == 0; } +sub is_non_verbose_build { + my ($line, $next_line, $cc_regex, $skip_ref) = @_; + + my $cmake_non_verbose = qr/^\s*\[[\d ]+%\] Building (?:C|CXX) object (.+?)$/; + if (not ($line =~ /^checking if you want to see long compiling messages\.\.\. no/ + or $line =~ /^\s*(?:CC|CCLD)\s+/ + or $line =~ /^\s*(?:C|c)ompiling\s+/ + or $line =~ /$cmake_non_verbose/)) { + return 0; + } + + # On the first pass we only check if this line is verbose or not. + return 1 if not defined $next_line; + + # Second pass, we have access to the next line. + ${$skip_ref} = 0; + + # CMake prints the non-verbose messages also when building verbose. If a + # compiler and the file name occurs in the next line, treat it as verbose + # build. + if ($line =~ /$cmake_non_verbose/) { + # Get filename, we can't use the complete path as only parts of it are + # used in the real compiler command ... + $1 =~ m{/([a-zA-Z0-9._-]+)$}; + my $file = $1; + + if ($next_line =~ /\Q$file\E/ and $next_line =~ /$cc_regex/) { + # We still have to skip the current line as it doesn't contain any + # compiler commands. + ${$skip_ref} = 1; + return 0; + } + } + + return 1; +} + # CONSTANTS/VARIABLES +# Regex to catch compiler commands. +my $cc_regex = qr/(?:x86_64-linux-gnu-)?(?:(?) { # Ignore compiler warnings for now. next if $line =~ /$warning_regex/; - # Try to detect non verbose build logs. - if ($line =~ /^checking if you want to see long compiling messages\.\.\. no/ - or $line =~ /^\s*(CC|CCLD)\s+/ - or $line =~ /^\s*(C|c)ompiling\s+/ - or $line =~ /^\s*\[[\d ]+%\] Building /) { - error_nonverbose_build($line); - $exit |= 1 << 2; - } - + # Check if this line indicates a non verbose build. + my $non_verbose = is_non_verbose_build($line); # One line may contain multiple commands (";"). Treat each one as single # line. @@ -242,14 +274,12 @@ while (my $line = <>) { } else { # Ignore lines with no compiler commands. - next if $line !~ /\b((?