X-Git-Url: https://ruderich.org/simon/gitweb/?a=blobdiff_plain;f=bin%2Fblhc;h=e183027e22886699b7e4c66639ad77c12555034e;hb=d9bd7570d07a93026a3147971c8e34be6c1c6c86;hp=bf5f8ff58dc1edddd4208c703ee8c702d808266a;hpb=fa2e7db77f6c7c9ae52841d5b4cfc8d9a1f221a9;p=blhc%2Fblhc.git diff --git a/bin/blhc b/bin/blhc index bf5f8ff..e183027 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', @@ -318,8 +394,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 /(?