X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=e602106b5fd8f6d0140634cf517f21e67471a6f8;hb=7e0037c0788371d6911d2dae5e919bd1b963aedb;hp=bf5f8ff58dc1edddd4208c703ee8c702d808266a;hpb=fa2e7db77f6c7c9ae52841d5b4cfc8d9a1f221a9;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index bf5f8ff..e602106 100755 --- a/bin/blhc +++ b/bin/blhc @@ -23,6 +23,7 @@ use warnings; use Getopt::Long (); use Term::ANSIColor (); +use Text::ParseWords (); our $VERSION = '0.01'; @@ -36,6 +37,81 @@ my $cc_regex = qr/(?:[a-z0-9_]+-(?:linux|kfreebsd)-gnu(?:eabi|eabihf)?-)? # Regex to catch (GCC) compiler warnings. my $warning_regex = qr/^(.+?):([0-9]+):[0-9]+: warning: (.+?) \[(.+?)\]$/; +# Regex for source files which require preprocessing. +my $source_preprocess_compile_regex = qr/ + # C + c + # Objective-C + | m + # C++ + | cc | cp | cxx | cpp | CPP | c\+\+ | C + # Objective-C++ + | mm | M + # Fortran + | F | FOR | fpp | FPP | FTN | F90 | F95 | F03 | F08 + /x; +my $source_preprocess_no_compile_regex = qr/ + # Assembly + s + /x; +my $source_preprocess_regex = qr/ + $source_preprocess_compile_regex + | $source_preprocess_no_compile_regex + /x; +# Regex for source files which don't require preprocessing. +my $source_no_preprocess_compile_regex = qr/ + # C + i + # C++ + | ii + # Objective-C + | mi + # Objective-C++ + | mii + # Fortran + | f | for | ftn | f90 | f95 | f03 | f08 + /x; +my $source_no_preprocess_no_compile_regex = qr/ + # Assembly + S | sx + /x; +my $source_no_preprocess_regex = qr/ + $source_no_preprocess_compile_regex + | $source_no_preprocess_no_compile_regex + /x; +# Regex for header files which require preprocessing. +my $header_preprocess_regex = qr/ + # C, C++, Objective-C, Objective-C++ + h + # C++ + | hh | H | hp | hxx | hpp | HPP | h\+\+ | tcc + /x; +# Regexps to match files with the given characteristics. +my $file_no_preprocess_regex = qr/ + $cc_regex.+? + \.(?: $source_no_preprocess_regex)\b + /x; +my $file_preprocess_regex = qr/ + $cc_regex.+? + \.(?: $header_preprocess_regex + | $source_preprocess_regex)\b + /x; +my $file_compile_link_regex = qr/ + $cc_regex.+? + \.(?: $source_preprocess_regex + | $source_no_preprocess_regex)\b + /x; +my $file_compile_regex = qr/ + $cc_regex.+? + \.(?: $source_preprocess_compile_regex + | $source_no_preprocess_compile_regex)\b + /x; +my $file_no_compile_regex = qr/ + $cc_regex.+ + \.(?: $source_preprocess_no_compile_regex + | $source_no_preprocess_no_compile_regex)\b + /x; + # Expected (hardening) flags. All flags are used as regexps. my @cflags = ( '-g', @@ -294,6 +370,10 @@ while (my $line = <>) { # false positives. $start = 1 if $line =~ /^dpkg-buildpackage:/; next if not $start; + # And stop at the end of the build log. Package details (reported by the + # buildd logs) are not important for us. This also prevents false + # positives. + last if $line =~ /^Build finished at \d{8}-\d{4}$/; # Detect architecture automatically unless overridden. if (not $option_arch @@ -318,8 +398,10 @@ while (my $line = <>) { my $non_verbose = is_non_verbose_build($line); # One line may contain multiple commands (";"). Treat each one as single - # line. - my @line = split /(?