Title: [94746] trunk/Tools
Revision
94746
Author
mdela...@apple.com
Date
2011-09-08 00:05:15 -0700 (Thu, 08 Sep 2011)

Log Message

Add standalone script that filters the output of build-webkit to be more human-readable
https://bugs.webkit.org/show_bug.cgi?id=44081

Reviewed by Daniel Bates.

* Scripts/filter-build-webkit: Added. Just need to feed it the output of
a build script (e.g. build-webkit) and it spits out a prettier version.
* Scripts/VCSUtils.pm: Refactored "possiblyColored" out of run-api-tests into VCSUtils.
* Scripts/run-api-tests: Now includes VCSUtils to use "possiblyColored"

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (94745 => 94746)


--- trunk/Tools/ChangeLog	2011-09-08 04:31:48 UTC (rev 94745)
+++ trunk/Tools/ChangeLog	2011-09-08 07:05:15 UTC (rev 94746)
@@ -1,3 +1,15 @@
+2011-09-07  Matthew Delaney  <mdela...@apple.com>
+
+        Add standalone script that filters the output of build-webkit to be more human-readable
+        https://bugs.webkit.org/show_bug.cgi?id=44081
+
+        Reviewed by Daniel Bates.
+
+        * Scripts/filter-build-webkit: Added. Just need to feed it the output of
+        a build script (e.g. build-webkit) and it spits out a prettier version.
+        * Scripts/VCSUtils.pm: Refactored "possiblyColored" out of run-api-tests into VCSUtils.
+        * Scripts/run-api-tests: Now includes VCSUtils to use "possiblyColored"
+
 2011-09-07  Noel Gordon  <noel.gor...@gmail.com>
 
         Add myself to committers.py                 

Modified: trunk/Tools/Scripts/VCSUtils.pm (94745 => 94746)


--- trunk/Tools/Scripts/VCSUtils.pm	2011-09-08 04:31:48 UTC (rev 94745)
+++ trunk/Tools/Scripts/VCSUtils.pm	2011-09-08 07:05:15 UTC (rev 94746)
@@ -37,6 +37,7 @@
 use File::Basename;
 use File::Spec;
 use POSIX;
+use Term::ANSIColor qw(colored);
 
 BEGIN {
     use Exporter   ();
@@ -72,6 +73,7 @@
         &parseFirstEOL
         &parsePatch
         &pathRelativeToSVNRepositoryRootForPath
+        &possiblyColored
         &prepareParsedPatch
         &removeEOL
         &runPatchCommand
@@ -410,6 +412,17 @@
     return $path;
 }
 
+sub possiblyColored($$)
+{
+    my ($colors, $string) = @_;
+
+    if (-t STDOUT) {
+        return colored([$colors], $string);
+    } else {
+        return $string;
+    }
+}
+
 sub adjustPathForRecentRenamings($)
 {
     my ($fullPath) = @_;

Added: trunk/Tools/Scripts/filter-build-webkit (0 => 94746)


--- trunk/Tools/Scripts/filter-build-webkit	                        (rev 0)
+++ trunk/Tools/Scripts/filter-build-webkit	2011-09-08 07:05:15 UTC (rev 94746)
@@ -0,0 +1,202 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2011 Apple Inc. All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+# 
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Filters the output of build-webkit into a more human-readable format.
+
+use strict;
+use warnings;
+
+use CGI qw(escapeHTML);
+use File::Basename;
+use FindBin;
+use lib $FindBin::Bin;
+use Getopt::Long;
+use VCSUtils;
+
+use constant {    
+    STYLE_PLAIN => 0,
+    STYLE_HEADER => 1,
+    STYLE_SUCCESS => 2,
+    STYLE_ALERT => 3,
+    
+    HTML_HEADER =><<HTMLHEADER,
+<html>
+    <head>
+        <title>Build Log</title>
+        <style>
+            body { font-family: Monaco, monospace; font-size: 10px; color: #666; line-height: 1.5em; }
+            h2 { margin: 1.5em 0 0 0; font-size: 1.0em; font-weight: bold; color: blue; }
+            p { margin: 0; padding-left: 1.5em; border-left: 3px solid #fff; }
+            p.alert { border-left-color: red; color: red; margin: 1.5em 0 0 0; }
+            p.alert + p { margin: 1.5em 0 0 0; }
+            p.alert + p.alert { margin: 0; }
+            p.success { color: green; }
+        </style>
+    </head>
+    <body>
+HTMLHEADER
+
+    HTML_FOOTER =><<HTMLFOOTER,
+    </body>
+</html>
+HTMLFOOTER
+};
+
+sub printLine($$);
+sub setLogfileOption($$);
+sub setOutputFormatOption($$);
+sub usageAndExit();
+
+# Defined in VCSUtils.
+sub possiblyColored($$);
+
+my $showHelp;
+my $outputPath = "&STDOUT";
+my $outputFormat = "text";
+my $useColor = -t STDOUT;
+my $unfilteredOutputPath = "build.log";
+my $logUnfilteredOutput;
+
+sub usageAndExit()
+{
+    print STDERR <<__END__;
+Usage: @{[ basename($0) ]} [options] buildlog1 [buildlog2 ...]
+       build-webkit | @{[ basename($0) ]} [options]
+  -h|--help     Show this help message
+Output Options:
+  -o|--output   Path for output (default: STDOUT)
+  -f|--format   Output format (default: $outputFormat)
+                  text: Plain text
+                  html: Standalone HTML document
+  --[no-]color  ANSI color output for text (default: on, if -o is STDOUT)
+Unfiltered Logging Options:
+  -l|--log      Save unfiltered output to file (see --log-file)
+  --logfile     Path to save unfiltered output (implies --log, default: $unfilteredOutputPath)
+__END__
+    exit 1;
+}
+
+my $getOptionsResult = GetOptions(
+    'h|help'                => \$showHelp,
+    'o|output=s'            => \$outputPath,
+    'f|format=s'            => \&setOutputFormatOption,
+    'color!'                => \$useColor,
+    'l|log'                 => \$logUnfilteredOutput,
+    'logfile=s'             => \&setLogfileOption,
+);
+
+if (-t STDIN || $showHelp || !$getOptionsResult) {
+    usageAndExit();
+}
+
+open(OUTPUT_HANDLE, ">$outputPath") or die "Failed to open $outputPath : $!";
+if ($logUnfilteredOutput) {
+    open(UNFILTERED_OUTPUT_HANDLE, ">$unfilteredOutputPath") or die "Failed to open $unfilteredOutputPath : $!";
+}
+
+print OUTPUT_HANDLE HTML_HEADER if ($outputFormat eq "html");
+
+my $buildFinished;
+while (my $line = <>) {
+    print UNFILTERED_OUTPUT_HANDLE $line if $logUnfilteredOutput;
+    
+    chomp($line);
+
+    next if $line =~ /^\s*$/;
+    next if $line =~ /^Build settings from command line:/;
+    next if $line =~ /make: Nothing to be done for `all'\./;
+    next if $line =~ /^_javascript_Core\/create_hash_table/;
+    next if $line =~ /_javascript_Core.framework\/PrivateHeaders\/create_hash_table/;
+    next if $line =~ /^_javascript_Core\/pcre\/dftables/;
+    next if $line =~ /^Creating hashtable for /;
+    next if $line =~ /^Wrote output to /;
+    next if $line =~ /^(touch|perl|cat|rm -f|bison|flex|python|\/usr\/bin\/g\+\+|gperf|echo|sed|if \[ \-f|WebCore\/generate-export-file) /;
+    next if $line =~ /^UNDOCUMENTED: /;
+    next if $line =~ /libtool.*has no symbols/;
+    next if $line =~ /^# Lower case all the values, as CSS values are case-insensitive$/;
+    next if $line =~ /^if sort /;
+    next if $line =~ /^    /;
+
+    if ($line =~ /^={10}/) {
+        printLine($line, STYLE_SUCCESS);
+        $buildFinished = 1;
+    } elsif ($line =~ /^===/) {
+        printLine($line, STYLE_HEADER);
+    } elsif ($line =~ /Checking Dependencies|Check dependencies/) {
+        printLine($line, STYLE_PLAIN);
+    } elsif ($line =~ /\*\* BUILD SUCCEEDED \*\*/) {
+        printLine("Build Succeeded", STYLE_SUCCESS);
+    } elsif ($line =~ /^(PhaseScriptExecution|CompileC|Ld|PBXCp|CpResource|CopyPNGFile|CopyTiffFile|CpHeader|Processing|ProcessInfoPlistFile|ProcessPCH|ProcessPCH\+\+|Touch|Libtool|CopyStringsFile|Mig|CreateUniversalBinary|Analyze) ("[^"]+"|\S+)/) {
+        my ($command, $path) = ($1, basename($2));
+        printLine("$command $path", STYLE_PLAIN);
+    } else {
+        printLine($line, $buildFinished ? STYLE_SUCCESS : STYLE_ALERT);
+    }
+}
+
+print OUTPUT_HANDLE HTML_FOOTER if ($outputFormat eq "html");
+
+close(OUTPUT_HANDLE);
+close(UNFILTERED_OUTPUT_HANDLE) if ($logUnfilteredOutput);
+
+exit 0;
+
+sub printLine($$)
+{
+    my ($line, $style) = @_;
+    
+    if ($outputFormat eq "html") {
+        $line = escapeHTML($line);
+        if    ($style == STYLE_HEADER)  { print OUTPUT_HANDLE "<h2>$line</h2>"; }
+        elsif ($style == STYLE_SUCCESS) { print OUTPUT_HANDLE "<p class=\"success\">$line</p>"; }
+        elsif ($style == STYLE_ALERT)   { print OUTPUT_HANDLE "<p class=\"alert\">$line</p>"; }
+        else                            { print OUTPUT_HANDLE "<p>$line</p>"; }
+    } else {
+        my $colors = "reset";
+        if ($useColor) {
+            if ($style == STYLE_HEADER)  { $colors = "blue"; }
+            if ($style == STYLE_SUCCESS) { $colors = "green"; }
+            if ($style == STYLE_ALERT)   { $colors = "red"; }
+        }
+        print OUTPUT_HANDLE possiblyColored($colors, $line);
+    }
+    print OUTPUT_HANDLE "\n";
+}
+
+sub setLogfileOption($$)
+{
+    my ($opt, $value) = @_;
+    $unfilteredOutputPath = $value;
+    $logUnfilteredOutput = 1;
+}
+
+sub setOutputFormatOption($$)
+{
+    my ($opt, $value) = @_;
+    $value = lc($value);
+    if ($value ne "html" && $value ne "text") {
+        die "The $opt option must be either \"html\" or \"text\"";
+    }
+    $outputFormat = $value;
+}
Property changes on: trunk/Tools/Scripts/filter-build-webkit
___________________________________________________________________

Added: svn:executable

Modified: trunk/Tools/Scripts/run-api-tests (94745 => 94746)


--- trunk/Tools/Scripts/run-api-tests	2011-09-08 04:31:48 UTC (rev 94745)
+++ trunk/Tools/Scripts/run-api-tests	2011-09-08 07:05:15 UTC (rev 94746)
@@ -36,7 +36,7 @@
 use IPC::Open3;
 use lib $FindBin::Bin;
 use webkitdirs;
-use Term::ANSIColor qw(colored);
+use VCSUtils;
 
 sub buildTestTool();
 sub dumpAllTests();
@@ -44,10 +44,12 @@
 sub runAllTests();
 sub runAllTestsInSuite($);
 sub runTest($$);
-sub possiblyColored($$);
 sub prepareEnvironmentForRunningTestTool();
 sub testToolPath();
 
+# Defined in VCSUtils.
+sub possiblyColored($$);
+
 # Timeout for individual test, in sec
 my $timeout = 10;
 
@@ -291,17 +293,6 @@
     chdir $originalCwd;
 }
 
-sub possiblyColored($$)
-{
-    my ($colors, $string) = @_;
-
-    if (-t STDOUT) {
-        return colored([$colors], $string);
-    } else {
-        return $string;
-    }
-}
-
 sub prepareEnvironmentForRunningTestTool()
 {
     return unless isAppleMacWebKit();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to