Title: [198968] trunk/Source/WebInspectorUI
- Revision
- 198968
- Author
- [email protected]
- Date
- 2016-04-01 22:23:32 -0700 (Fri, 01 Apr 2016)
Log Message
Web Inspector: Remove console.asserts from Worker code in optimized builds
https://bugs.webkit.org/show_bug.cgi?id=156124
<rdar://problem/25505031>
Patch by Joseph Pecoraro <[email protected]> on 2016-04-01
Reviewed by Timothy Hatcher.
* Scripts/copy-user-interface-resources.pl:
Remove console asserts on the Worker results directory.
* Scripts/remove-console-asserts.pl:
(removeConsoleAssertsInFile):
(removeConsoleAssertsInDirectory):
Refactor into functions for a file and a file for
recursing through directories.
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (198967 => 198968)
--- trunk/Source/WebInspectorUI/ChangeLog 2016-04-02 03:21:38 UTC (rev 198967)
+++ trunk/Source/WebInspectorUI/ChangeLog 2016-04-02 05:23:32 UTC (rev 198968)
@@ -1,3 +1,20 @@
+2016-04-01 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Remove console.asserts from Worker code in optimized builds
+ https://bugs.webkit.org/show_bug.cgi?id=156124
+ <rdar://problem/25505031>
+
+ Reviewed by Timothy Hatcher.
+
+ * Scripts/copy-user-interface-resources.pl:
+ Remove console asserts on the Worker results directory.
+
+ * Scripts/remove-console-asserts.pl:
+ (removeConsoleAssertsInFile):
+ (removeConsoleAssertsInDirectory):
+ Refactor into functions for a file and a file for
+ recursing through directories.
+
2016-03-31 Joseph Pecoraro <[email protected]>
Web Inspector: ScriptSyntaxTree doesn't handle RestElement AST nodes
Modified: trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl (198967 => 198968)
--- trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl 2016-04-02 03:21:38 UTC (rev 198967)
+++ trunk/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl 2016-04-02 05:23:32 UTC (rev 198968)
@@ -242,6 +242,9 @@
# Copy the Protocol/Legacy and Workers directories.
ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy'));
ditto(File::Spec->catfile($uiRoot, 'Workers'), $workersDir);
+
+ # Remove console.assert calls from the Worker js files.
+ system(File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'), '--input-directory', $workersDir);
} else {
# Keep the files separate for engineering builds.
ditto($uiRoot, $targetResourcePath);
Modified: trunk/Source/WebInspectorUI/Scripts/remove-console-asserts.pl (198967 => 198968)
--- trunk/Source/WebInspectorUI/Scripts/remove-console-asserts.pl 2016-04-02 03:21:38 UTC (rev 198967)
+++ trunk/Source/WebInspectorUI/Scripts/remove-console-asserts.pl 2016-04-02 05:23:32 UTC (rev 198968)
@@ -4,45 +4,87 @@
use Getopt::Long;
use File::Copy qw/move/;
use File::Temp qw/tempfile/;
+use File::Spec;
+sub removeConsoleAssertsInFile($$);
+sub removeConsoleAssertsInDirectory($);
+
+our $inputDirectory;
our $inputScriptFilename;
our $outputScriptFilename;
-GetOptions('input-script=s' => \$inputScriptFilename,
+GetOptions('input-directory=s' => \$inputDirectory,
+ 'input-script=s' => \$inputScriptFilename,
'output-script=s' => \$outputScriptFilename);
-unless (defined $inputScriptFilename and defined $outputScriptFilename) {
- print "Usage: $0 --input-script <path> --output-script <path>\n";
+if (defined $inputScriptFilename and defined $outputScriptFilename) {
+ removeConsoleAssertsInFile($inputScriptFilename, $outputScriptFilename);
exit;
}
-open IN, $inputScriptFilename or die "Couldn't open $inputScriptFilename: $!";
-our ($out, $tempFilename) = tempfile(UNLINK => 0) or die;
+if (defined $inputDirectory) {
+ removeConsoleAssertsInDirectory($inputDirectory);
+ exit;
+}
-our $previousLine = "";
-while (<IN>) {
- # Warn about console.assert in control flow statement without braces. Can change logic when stripped.
- if (/console\.assert/) {
- if ($previousLine =~ /^\s*(for|if|else|while|do)\b/ && $previousLine !~ /\{\s*$/) {
- print "WARNING: console.assert inside control flow statement without braces on line: $.: $_";
+print "Usage: $0 --input-script <path> --output-script <path>\n";
+print "Usage: $0 --input-directory <path>\n";
+exit;
+
+sub removeConsoleAssertsInFile($$)
+{
+ my $inputScriptFilename = shift;
+ my $outputScriptFilename = shift;
+
+ print "STRIPPING: $inputScriptFilename\n";
+
+ open IN, $inputScriptFilename or die "Couldn't open $inputScriptFilename: $!";
+ my ($out, $tempFilename) = tempfile(UNLINK => 0) or die;
+
+ my $previousLine = "";
+ while (<IN>) {
+ # Warn about console.assert in control flow statement without braces. Can change logic when stripped.
+ if (/console\.assert/) {
+ if ($previousLine =~ /^\s*(for|if|else|while|do)\b/ && $previousLine !~ /\{\s*$/) {
+ print "WARNING: console.assert inside control flow statement without braces on line: $.: $_";
+ }
}
- }
- s/\s*console\.assert\(.*\);\s*//g;
- print $out $_;
- $previousLine = $_ if $_ !~ /^\s*$/;
+ s/\s*console\.assert\(.*\);\s*//g;
+ print $out $_;
+ $previousLine = $_ if $_ !~ /^\s*$/;
- # If console.assert is still on the line, either we missed a semicolon or it is multi-line. These did not get stripped.
- if ($_ =~ /\s*console\.assert\(/) {
- if ($_ =~ /\)\s*$/) {
- print "WARNING: console.assert missing trailing semicolon on line $.: $_" ;
- } else {
- print "WARNING: Multi-line console.assert on line $.: $_" ;
+ # If console.assert is still on the line, either we missed a semicolon or it is multi-line. These did not get stripped.
+ if ($_ =~ /\s*console\.assert\(/) {
+ if ($_ =~ /\)\s*$/) {
+ print "WARNING: console.assert missing trailing semicolon on line $.: $_" ;
+ } else {
+ print "WARNING: Multi-line console.assert on line $.: $_" ;
+ }
}
}
+
+ close $out;
+ close IN;
+
+ move $tempFilename, $outputScriptFilename or die "$!";
}
-close $out;
-close IN;
+sub removeConsoleAssertsInDirectory($)
+{
+ my $inputDirectory = shift;
-move $tempFilename, $outputScriptFilename or die "$!";
+ opendir(DIR, $inputDirectory) || die "$!";
+ my @files = grep { !/^\.{1,2}$/ } readdir (DIR);
+ closedir(DIR);
+
+ foreach my $file (@files) {
+ next if $file eq '.' or $file eq '..';
+ my $path = File::Spec->catdir($inputDirectory, $file);
+ if (-d $path) {
+ removeConsoleAssertsInDirectory($path);
+ } elsif ($file =~ /\.js$/) {
+ removeConsoleAssertsInFile($path, $path);
+ }
+ }
+}
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes