Prefix each output line with the library being processed
authorMarius Storm-Olsen <marius.storm-olsen@nokia.com>
Thu, 7 Jul 2011 18:48:02 +0000 (18:48 +0000)
committerQt by Nokia <qt-info@nokia.com>
Thu, 21 Jul 2011 18:40:51 +0000 (20:40 +0200)
Makes it easier to track which library output is coming from,
when building Qt with -j > 1.

Change-Id: I9acda04e84014dc441e409a0b24b2f78762dcc1c
Reviewed-on: http://codereview.qt.nokia.com/1765
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
bin/syncqt

index 405f275..691f091 100755 (executable)
@@ -275,6 +275,15 @@ sub classNames {
     return @ret;
 }
 
+sub make_path {
+    my ($dir, $lib, $be_verbose) = @_;
+    unless(-e $dir) {
+        mkpath $dir;
+        $dir = "<outbase>" . substr($dir, length($out_basedir)) if ($be_verbose < 3);
+        print "$lib: mkpath $dir\n" if ($be_verbose > 1);
+    }
+}
+
 ######################################################################
 # Syntax:  syncHeader(header, iheader, copy, timestamp)
 # Params:  header, string, filename to create "symlink" for
@@ -286,14 +295,14 @@ sub classNames {
 # Returns: 1 if successful, else 0.
 ######################################################################
 sub syncHeader {
-    my ($header, $iheader, $copy, $ts) = @_;
+    my ($lib, $header, $iheader, $copy, $ts) = @_;
     $iheader =~ s=\\=/=g;
     $header =~ s=\\=/=g;
-    return copyFile($iheader, $header) if($copy);
+    return copyFile($lib, $iheader, $header) if($copy);
 
     unless(-e $header) {
         my $header_dir = dirname($header);
-        mkpath $header_dir, !$quiet;
+        make_path($header_dir, $lib, $verbose_level);
 
         #write it
         my $iheader_out = fixPaths($iheader, $header_dir);
@@ -414,7 +423,7 @@ sub fileCompare {
 ######################################################################
 sub copyFile
 {
-    my ($file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
+    my ($lib, $file,$ifile, $copy,$knowdiff,$filecontents,$ifilecontents) = @_;
     # Bi-directional synchronization
     open( I, "< " . $file ) || die "Could not open $file for reading";
     local $/;
@@ -436,7 +445,7 @@ sub copyFile
     if ( $knowdiff || ($filecontents ne $ifilecontents) ) {
         if ( $copy > 0 ) {
             my $file_dir = dirname($file);
-            mkpath $file_dir, !$quiet unless(-e $file_dir);
+            make_path($file_dir, $lib, $verbose_level);
             open(O, "> " . $file) || die "Could not open $file for writing (no write permission?)";
             local $/;
             binmode O;
@@ -446,7 +455,7 @@ sub copyFile
             return 1;
         } elsif ( $copy < 0 ) {
             my $ifile_dir = dirname($ifile);
-            mkpath $ifile_dir, !$quiet unless(-e $ifile_dir);
+            make_path($ifile_dir, $lib, $verbose_level);
             open(O, "> " . $ifile) || die "Could not open $ifile for writing (no write permission?)";
             local $/;
             binmode O;
@@ -470,10 +479,10 @@ sub copyFile
 ######################################################################
 sub symlinkFile
 {
-    my ($file,$ifile) = @_;
+    my ($lib, $file, $ifile) = @_;
 
     if ($isunix) {
-        print "symlink created for $file " unless $quiet;
+        print "$lib: symlink created for $file " if ($verbose_level);
         if ( $force_relative && ($ifile =~ /^$quoted_basedir/)) {
             my $t = getcwd();
             my $c = -1;
@@ -486,7 +495,7 @@ sub symlinkFile
         print "\n" if($verbose_level);
         return symlink($file, $ifile);
     }
-    return copyFile($file, $ifile);
+    return copyFile($lib, $file, $ifile);
 }
 
 ######################################################################
@@ -806,7 +815,7 @@ foreach my $lib (@modules_to_sync) {
             chomp $module_patch_version;
         }
     }
-    print "WARNING: Module $lib\'s pri missing QT.<module>.VERSION variable! Private headers not versioned!\n" if (!$module_version);
+    print "$lib: WARNING: Module\'s pri missing QT.<module>.VERSION variable! Private headers not versioned!\n" if (!$module_version);
 
     my $pathtoheaders = "";
     $pathtoheaders = $moduleheaders{$lib} if ($moduleheaders{$lib});
@@ -895,9 +904,9 @@ foreach my $lib (@modules_to_sync) {
             print MODULE_VERSION_HEADER_FILE "#endif // QT_". uc($lib) . "_VERSION_H\n";
             close MODULE_VERSION_HEADER_FILE;
             $moduleversionheader = "<srcbase>" . substr($moduleversionheader, length($basedir)) if ($verbose_level < 2);
-            print "$moduleversionheader created for $lib\n" if($verbose_level);
+            print "$lib: created version header $moduleversionheader\n" if($verbose_level);
         } elsif ($modulepri) {
-            print "WARNING: Module $lib\'s pri file '$modulepri' not found.\nSkipped creating module version header for $lib.\n";
+            print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating module version header.\n";
         }
     }
 
@@ -994,11 +1003,11 @@ foreach my $lib (@modules_to_sync) {
 #                                  class =~ s,::,/,g;
 #                               }
                                 $class_lib_map_contents .= "QT_CLASS_LIB($full_class, $lib, $header_base)\n";
-                                $header_copies++ if(syncHeader("$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts));
+                                $header_copies++ if(syncHeader($lib, "$out_basedir/include/$lib/$class", "$out_basedir/include/$lib/$header", 0, $ts));
 
                                 # KDE-Compat headers for Phonon
                                 if ($lib eq "phonon") {
-                                    $header_copies++ if (syncHeader("$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0, $ts));
+                                    $header_copies++ if (syncHeader($lib, "$out_basedir/include/phonon_compat/Phonon/$class", "$out_basedir/include/$lib/$header", 0, $ts));
                                 }
                             }
                         } elsif ($create_private_headers) {
@@ -1009,7 +1018,7 @@ foreach my $lib (@modules_to_sync) {
                             }
                         }
                         foreach(@headers) { #sync them
-                            $header_copies++ if(syncHeader($_, $iheader, $copy_headers && !$shadow, $ts));
+                            $header_copies++ if(syncHeader($lib, $_, $iheader, $copy_headers && !$shadow, $ts));
                         }
 
                         if($public_header) {
@@ -1046,7 +1055,7 @@ foreach my $lib (@modules_to_sync) {
                         if ($verbose_level < 3) {
                             my $line_prefix = ",";
                             if ($new_header_dirname ne $header_dirname) {
-                                $line_prefix = "created header(s) for $new_header_dirname/ {";
+                                $line_prefix = "$lib: created fwd-include header(s) for $new_header_dirname/ {";
                                 $line_prefix = " }\n".$line_prefix if ($header_dirname);
                                 $header_dirname = $new_header_dirname;
                             } else {
@@ -1055,7 +1064,7 @@ foreach my $lib (@modules_to_sync) {
                             print "$line_prefix $header_base ($header_copies)";
                         } else { # $verbose_level >= 3
                             $iheader = "<srcbase>" . substr($iheader, length($basedir)) if ($verbose_level == 3);
-                            print "header created for $iheader ($header_copies)\n";
+                            print "$lib: created $header_copies fwd-include headers for $iheader\n";
                         }
                     }
                 }
@@ -1086,11 +1095,11 @@ foreach my $lib (@modules_to_sync) {
             }
             if($master_include && $master_contents) {
                 my $master_dir = dirname($master_include);
-                mkpath $master_dir, !$quiet;
-                print "header (master) created for $lib\n" unless $quiet;
+                make_path($master_dir, $lib, $verbose_level);
                 open MASTERINCLUDE, ">$master_include";
                 print MASTERINCLUDE $master_contents;
                 close MASTERINCLUDE;
+                print "$lib: created header (master) file\n" if($verbose_level);
             }
         }
 
@@ -1111,11 +1120,11 @@ foreach my $lib (@modules_to_sync) {
         }
         if($headers_pri_file && $master_contents) {
             my $headers_pri_dir = dirname($headers_pri_file);
-            mkpath $headers_pri_dir, !$quiet;
-            print "headers.pri file created for $lib\n" unless $quiet;
+            make_path($headers_pri_dir, $lib, $verbose_level);
             open HEADERS_PRI_FILE, ">$headers_pri_file";
             print HEADERS_PRI_FILE $headers_pri_contents;
             close HEADERS_PRI_FILE;
+            print "$lib: created headers.pri file\n" if($verbose_level);
         }
 
         # create forwarding module pri in qtbase/mkspecs/modules
@@ -1123,7 +1132,7 @@ foreach my $lib (@modules_to_sync) {
             my $modulepri = $modulepris{$lib};
             if (-e $modulepri) {
                 my $modulepriname = basename($modulepri);
-                mkpath($module_fwd);
+                make_path($module_fwd, $lib, $verbose_level);
                 my $moduleprifwd = "$module_fwd/$modulepriname";
                 my $mod_base = $developer_build ? $basedir : $out_basedir;
                 my $mod_component_base = $developer_build ? $qtbasedir : $out_basedir;
@@ -1149,7 +1158,7 @@ foreach my $lib (@modules_to_sync) {
                     }
                 }
             } elsif ($modulepri) {
-                print "WARNING: Module $lib\'s pri file '$modulepri' not found.\nSkipped creating forwarding pri for $lib.\n";
+                print "$lib: WARNING: Module\'s pri file '$modulepri' not found.\n$lib: Skipped creating forwarding pri.\n";
             }
         }
     }
@@ -1167,7 +1176,7 @@ unless($showonly || !$create_uic_class_map) {
     }
     if($class_lib_map) {
         my $class_lib_map_dir = dirname($class_lib_map);
-        mkpath $class_lib_map_dir, !$quiet;
+        make_path($class_lib_map_dir, "<outdir>", $verbose_level);
         open CLASS_LIB_MAP, ">$class_lib_map";
         print CLASS_LIB_MAP $class_lib_map_contents;
         close CLASS_LIB_MAP;
@@ -1251,7 +1260,7 @@ if($check_includes) {
                                         if($include) {
                                             for my $trylib (keys(%modules)) {
                                                 if(-e "$out_basedir/include/$trylib/$include") {
-                                                    print "WARNING: $iheader includes $include when it should include $trylib/$include\n";
+                                                    print "$lib: WARNING: $iheader includes $include when it should include $trylib/$include\n";
                                                 }
                                             }
                                         }
@@ -1269,27 +1278,27 @@ if($check_includes) {
                                 }
                                 if ($header_skip_qt_begin_header_test == 0) {
                                     if ($qt_begin_header_found == 0) {
-                                        print "WARNING: $iheader does not include QT_BEGIN_HEADER\n";
+                                        print "$lib: WARNING: $iheader does not include QT_BEGIN_HEADER\n";
                                     }
 
                                     if ($qt_begin_header_found && $qt_end_header_found == 0) {
-                                        print "WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
+                                        print "$lib: WARNING: $iheader has QT_BEGIN_HEADER but no QT_END_HEADER\n";
                                     }
                                 }
 
                                 if ($header_skip_qt_begin_namespace_test == 0) {
                                     if ($qt_begin_namespace_found == 0) {
-                                        print "WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
+                                        print "$lib: WARNING: $iheader does not include QT_BEGIN_NAMESPACE\n";
                                     }
 
                                     if ($qt_begin_namespace_found && $qt_end_namespace_found == 0) {
-                                        print "WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
+                                        print "$lib: WARNING: $iheader has QT_BEGIN_NAMESPACE but no QT_END_NAMESPACE\n";
                                     }
                                 }
 
                                 if ($header_skip_qt_module_test == 0) {
                                     if ($qt_module_found == 0) {
-                                        print "WARNING: $iheader does not include QT_MODULE\n";
+                                        print "$lib: WARNING: $iheader does not include QT_MODULE\n";
                                     }
                                 }
                                 close(F);