Skip to content
Permalink
Browse files
Web Inspector: Combine and minify Esprima
https://bugs.webkit.org/show_bug.cgi?id=135728

Reviewed by Joseph Pecoraro.

* Scripts/combine-resources.pl:
* Scripts/copy-user-interface-resources.pl:
* UserInterface/External/Esprima/LICENSE: Added.


Canonical link: https://commits.webkit.org/153622@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@172331 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
xeenon committed Aug 8, 2014
1 parent eb0bb2c commit b1d34e21768bb11f068c3d6318cba7ba0e094f12
Showing 4 changed files with 82 additions and 20 deletions.
@@ -1,3 +1,14 @@
2014-08-07 Timothy Hatcher <timothy@apple.com>

Web Inspector: Combine and minify Esprima
https://bugs.webkit.org/show_bug.cgi?id=135728

Reviewed by Joseph Pecoraro.

* Scripts/combine-resources.pl:
* Scripts/copy-user-interface-resources.pl:
* UserInterface/External/Esprima/LICENSE: Added.

2014-08-07 Timothy Hatcher <timothy@apple.com>

Fix regression where tree outline keyboard navigation is broken.
@@ -21,8 +21,8 @@
'input-html-dir=s' => \$htmlDirectory,
'input-html=s' => \$htmlFile);

unless (defined $htmlFile and defined $derivedSourcesDirectory and defined $outputDirectory and defined $outputScriptName and defined $outputStylesheetName) {
print "Usage: $0 --input-html <path> --derived-sources-dir <path> --output-dir <path> --output-script-name <name> --output-style-name <name>\n";
unless (defined $htmlFile and defined $derivedSourcesDirectory and defined $outputDirectory and (defined $outputScriptName or defined $outputStylesheetName)) {
print "Usage: $0 --input-html <path> --derived-sources-dir <path> --output-dir <path> [--output-script-name <name>] [--output-style-name <name>]\n";
exit;
}

@@ -76,8 +76,8 @@ ($$$)
my $inputDirectoryPattern = "(?!External\/)[^\"]*";
$inputDirectoryPattern = $inputDirectory . "\/[^\"]*" if $inputDirectory;

concatinateFiles($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">");
concatinateFiles($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", "<script src=\"$outputScriptName\"></script>");
concatinateFiles($outputStylesheetName, "<link rel=\"stylesheet\" href=\"($inputDirectoryPattern)\">", "<link rel=\"stylesheet\" href=\"$outputStylesheetName\">") if defined $outputStylesheetName;
concatinateFiles($outputScriptName, "<script src=\"($inputDirectoryPattern)\"><\/script>", "<script src=\"$outputScriptName\"></script>") if defined $outputScriptName;

$htmlContents =~ s/<head>.*<\/head>/<head>$headContents<\/head>/si;

@@ -38,21 +38,36 @@ ($$)
}
}

my $LICENSE = <<'EOF';
sub readLicenseFile($)
{
my ($licenseFilePath) = @_;

open(LICENSE_FILE, '<', $licenseFilePath) or die "Unable to open $licenseFilePath: $!";

my $license = "/*\n";
$license .= ' * ' . $_ while <LICENSE_FILE>;
$license .= " */\n";

close(LICENSE_FILE);

return $license;
}

my $inspectorLicense = <<'EOF';
/*
* Copyright (C) 2007-2014 Apple Inc. All rights reserved.
* Copyright (C) 2009-2011 Google Inc. All rights reserved.
* Copyright (C) 2009-2010 Joseph Pecoraro. All rights reserved.
* Copyright (C) 2008 Matt Lilek. All rights reserved.
* Copyright (C) 2008-2009 Anthony Ricaud <rik@webkit.org>
* Copyright (C) 2009-2010 Joseph Pecoraro. All rights reserved.
* Copyright (C) 2009-2011 Google Inc. All rights reserved.
* Copyright (C) 2009 280 North Inc. All Rights Reserved.
* Copyright (C) 2010 Nikita Vasilyev. All rights reserved.
* Copyright (C) 2011 Brian Grinstead All rights reserved.
* Copyright (C) 2013 Matt Holden <jftholden@yahoo.com>
* Copyright (C) 2013 Samsung Electronics. All rights reserved.
* Copyright (C) 2013 Seokju Kwon (seokju.kwon@gmail.com)
* Copyright (C) 2013 Adobe Systems Inc. All rights reserved.
* Copyright (C) 2013 University of Washington. All rights reserved.
* Copyright (C) 2013-2014 University of Washington. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -84,15 +99,10 @@ ($$)
my $targetResourcePath = File::Spec->catdir($ENV{'TARGET_BUILD_DIR'}, $ENV{'UNLOCALIZED_RESOURCES_FOLDER_PATH'});
my $protocolDir = File::Spec->catdir($targetResourcePath, 'Protocol');
my $codeMirrorPath = File::Spec->catdir($uiRoot, 'External', 'CodeMirror');
my $esprimaPath = File::Spec->catdir($uiRoot, 'External', 'Esprima');

my $codeMirrorLicenseFile = File::Spec->catfile($codeMirrorPath, 'LICENSE');
open(CMLFILE, '<', $codeMirrorLicenseFile) or die "Unable to open $codeMirrorLicenseFile: $!";
my $CODE_MIRROR_LICENSE = "/*\n";
while (<CMLFILE>) {
$CODE_MIRROR_LICENSE .= ' * ' . $_;
}
close(CMLFILE);
$CODE_MIRROR_LICENSE .= " */\n";
my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE'));
my $esprimaMirrorLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE'));

make_path($protocolDir, $targetResourcePath);

@@ -110,6 +120,9 @@ ($$)
my $derivedSourcesMainHTML = File::Spec->catfile($derivedSourcesDir, 'Main.html');
system($combineResourcesCmd, '--input-dir', 'External/CodeMirror', '--input-html', $derivedSourcesMainHTML, '--input-html-dir', $uiRoot, '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'CodeMirror.js', '--output-style-name', 'CodeMirror.css');

# Combine the Esprima JavaScript files in Production builds into a single file (Esprima.js).
system($combineResourcesCmd, '--input-dir', 'External/Esprima', '--input-html', $derivedSourcesMainHTML, '--input-html-dir', $uiRoot, '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'Esprima.js');

# Remove console.assert calls from the Main.js file.
my $derivedSourcesMainJS = File::Spec->catfile($derivedSourcesDir, 'Main.js');
system(File::Spec->catfile($scriptsRoot, 'remove-console-asserts.pl'), '--input-script', $derivedSourcesMainJS, '--output-script', $derivedSourcesMainJS);
@@ -128,17 +141,21 @@ ($$)

# Export the license into Main.js.
my $targetMainJS = File::Spec->catfile($targetResourcePath, 'Main.js');
seedFile($targetMainJS, $LICENSE);
seedFile($targetMainJS, $inspectorLicense);

my $targetMainCSS = File::Spec->catfile($targetResourcePath, 'Main.css');
seedFile($targetMainCSS, $LICENSE);
seedFile($targetMainCSS, $inspectorLicense);

# Export the license into CodeMirror.js and CodeMirror.css.
my $targetCodeMirrorJS = File::Spec->catfile($targetResourcePath, 'CodeMirror.js');
seedFile($targetCodeMirrorJS, $CODE_MIRROR_LICENSE);
seedFile($targetCodeMirrorJS, $codeMirrorLicense);

my $targetCodeMirrorCSS = File::Spec->catfile($targetResourcePath, 'CodeMirror.css');
seedFile($targetCodeMirrorCSS, $CODE_MIRROR_LICENSE);
seedFile($targetCodeMirrorCSS, $codeMirrorLicense);

# Export the license into Esprima.js.
my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'Esprima.js');
seedFile($targetEsprimaJS, $esprimaMirrorLicense);

# Minify the Main.js and Main.css files, with Main.js appending to the license that was exported above.
my $jsMinScript = File::Spec->catfile($scriptsRoot, 'jsmin.py');
@@ -152,6 +169,10 @@ ($$)
system(qq("$python" "$jsMinScript" < "$derivedSouressCodeMirrorJS" >> "$targetCodeMirrorJS")) and die "Failed to minify $derivedSouressCodeMirrorJS: $!";
system(qq("$python" "$cssMinScript" < "$derivedSourcesCodeMirrorCSS" >> "$targetCodeMirrorCSS")) and die "Failed to minify $derivedSourcesCodeMirrorCSS: $!";

# Minify the Esprima.js file, appending to the license that was exported above.
my $derivedSouressEsprimaJS = File::Spec->catfile($derivedSourcesDir, 'Esprima.js');
system(qq("$python" "$jsMinScript" < "$derivedSouressEsprimaJS" >> "$targetEsprimaJS")) and die "Failed to minify $derivedSouressEsprimaJS: $!";

# Copy over Main.html and the Images directory.
copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html'));

@@ -0,0 +1,30 @@
Copyright (C) 2013 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2013 Thaddee Tyl <thaddee.tyl@gmail.com>
Copyright (C) 2013 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Ariya Hidayat <ariya.hidayat@gmail.com>
Copyright (C) 2012 Mathias Bynens <mathias@qiwi.be>
Copyright (C) 2012 Joost-Wim Boekesteijn <joost-wim@boekesteijn.nl>
Copyright (C) 2012 Kris Kowal <kris.kowal@cixar.com>
Copyright (C) 2012 Yusuke Suzuki <utatane.tea@gmail.com>
Copyright (C) 2012 Arpad Borsos <arpad.borsos@googlemail.com>
Copyright (C) 2011 Ariya Hidayat <ariya.hidayat@gmail.com>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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 THE COPYRIGHT HOLDERS AND 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 <COPYRIGHT HOLDER> 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.

0 comments on commit b1d34e2

Please sign in to comment.