]> ruderich.org/simon Gitweb - blhc/blhc.git/blobdiff - bin/blhc
Don't use Term::ANSIColor in buildd mode.
[blhc/blhc.git] / bin / blhc
index 5adfca6c13ea2d28d7e3c43c3a61d43c8530e443..10b39f388c9b1769d3e308b2903a01524b2e6ddf 100755 (executable)
--- a/bin/blhc
+++ b/bin/blhc
@@ -22,7 +22,6 @@ use strict;
 use warnings;
 
 use Getopt::Long ();
-use Term::ANSIColor ();
 use Text::ParseWords ();
 
 our $VERSION = '0.01';
@@ -138,7 +137,7 @@ my $file_extension_regex = qr/
     \s
     \S+             # Filename without extension.
     \.
-    ([^\\.,;:\s]+)  # File extension.
+    ([^\/\\.,;:\s]+)# File extension.
     (?=\s|\\)       # At end of word. Can't use \b because some files have non
                     # word characters at the end and because \b matches double
                     # extensions (like .cpp.o). Works always as all lines are
@@ -331,7 +330,14 @@ sub is_non_verbose_build {
     }
 
     # False positives.
+    #
+    # C++ compiler setting.
     return 0 if $line =~ /^\s*C\+\+.+?:\s+(?:yes|no)\s*$/;
+    # "Compiling" with no file name.
+    if ($line =~ /^\s*(?:C|c)ompiling\s+(.+?)(?:\.\.\.)?$/) {
+        # $file_extension_regex may need spaces around the filename.
+        return 0 if not " $1 " =~ /$file_extension_regex/o;
+    }
 
     my $file = $1;
 
@@ -442,6 +448,12 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     exit 0;
 }
 
+# Don't load Term::ANSIColor in buildd mode because Term::ANSIColor is not
+# installed on Debian's buildds.
+if (not $option_buildd) {
+    require Term::ANSIColor;
+}
+
 if ($option_all) {
     $option_pie     = 1;
     $option_bindnow = 1;
@@ -556,7 +568,7 @@ FILE: foreach my $file (@ARGV) {
         # Ignore compiler warnings for now.
         next if $line =~ /$warning_regex/o;
 
-        if ($line =~ /\033/) { # esc
+        if (not $option_buildd and $line =~ /\033/) { # esc
             # Remove all ANSI color sequences which are sometimes used in
             # non-verbose builds.
             $line = Term::ANSIColor::colorstrip($line);
@@ -731,6 +743,7 @@ FILE: foreach my $file (@ARGV) {
         # Skip unnecessary tests when only preprocessing.
         my $flag_preprocess = 0;
 
+        my $dependency = 0;
         my $preprocess = 0;
         my $compile    = 0;
         my $link       = 0;
@@ -740,11 +753,25 @@ FILE: foreach my $file (@ARGV) {
             $preprocess      = 1;
             $flag_preprocess = 1 if $1 eq '-E';
             $compile         = 1 if $1 eq '-S' or $1 eq '-c';
+        # Dependency generation for Makefiles. The other flags (-MF -MG -MP
+        # -MT -MQ) are always used with -M/-MM.
+        } elsif ($line =~ /\s(?:-M|-MM)\b/) {
+            $dependency = 1;
         # Otherwise assume we are linking.
         } else {
             $link = 1;
         }
 
+        # -MD/-MMD also cause dependency generation, but they don't imply -E!
+        if ($line =~ /\s(?:-MD|-MMD)\b/) {
+            $dependency      = 0;
+            $flag_preprocess = 0;
+        }
+
+        # Dependency generation for Makefiles, no preprocessing or other flags
+        # needed.
+        next if $dependency;
+
         # Get all file extensions on this line.
         my @extensions = $line =~ /$file_extension_regex/go;
         # Ignore all unknown extensions to speedup the search below.