diff options
| author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
|---|---|---|
| committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-05-20 09:56:07 +0000 |
| commit | 41386e9cb918eed93b3f13648cbef387e371e451 (patch) | |
| tree | a97f9d7bd1d9d091833286085f72da9d83fd0606 /Source/WebInspectorUI/Scripts | |
| parent | e15dd966d523731101f70ccf768bba12435a0208 (diff) | |
| download | WebKitGtk-tarball-41386e9cb918eed93b3f13648cbef387e371e451.tar.gz | |
webkitgtk-2.4.9webkitgtk-2.4.9
Diffstat (limited to 'Source/WebInspectorUI/Scripts')
9 files changed, 0 insertions, 825 deletions
diff --git a/Source/WebInspectorUI/Scripts/combine-resources.pl b/Source/WebInspectorUI/Scripts/combine-resources.pl deleted file mode 100755 index 5add3fc72..000000000 --- a/Source/WebInspectorUI/Scripts/combine-resources.pl +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use Getopt::Long; -use File::Basename; -use File::Path; - -our $inputDirectory; -our $outputDirectory; -our $outputScriptName; -our $outputStylesheetName; -our $derivedSourcesDirectory; -our $htmlDirectory; -our $htmlFile; - -GetOptions('output-dir=s' => \$outputDirectory, - 'output-script-name=s' => \$outputScriptName, - 'output-style-name=s' => \$outputStylesheetName, - 'derived-sources-dir=s' => \$derivedSourcesDirectory, - 'input-dir=s' => \$inputDirectory, - 'input-html-dir=s' => \$htmlDirectory, - 'input-html=s' => \$htmlFile); - -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; -} - -$htmlDirectory = dirname($htmlFile) unless $htmlDirectory; - -our $htmlContents; - -{ - local $/; - open HTML, $htmlFile or die; - $htmlContents = <HTML>; - close HTML; -} - -$htmlContents =~ m/<head>(.*)<\/head>/si; -our $headContents = $1; - -mkpath $outputDirectory; - -sub concatinateFiles($$$) -{ - my $filename = shift; - my $tagExpression = shift; - my $concatinatedTag = shift; - my $fileCount = 0; - - open OUT, ">", "$outputDirectory/$filename" or die "Can't open $outputDirectory/$filename: $!"; - - while ($headContents =~ m/$tagExpression/gi) { - local $/; - open IN, "$htmlDirectory/$1" or open IN, "$derivedSourcesDirectory/$1" or die "Can't open $htmlDirectory/$1: $!"; - print OUT "\n" if $fileCount++; - print OUT "/* $1 */\n\n"; - print OUT <IN>; - close IN; - } - - close OUT; - - # Don't use \s so we can control the newlines we consume. - my $replacementExpression = "([\t ]*)" . $tagExpression . "[\t ]*\n+"; - - # Replace the first occurance with a token so we can inject the concatinated tag in the same place - # as the first file that got consolidated. This makes sure we preserve some order if there are other - # items in the head that we didn't consolidate. - $headContents =~ s/$replacementExpression/$1%CONCATINATED%\n/i; - $headContents =~ s/$replacementExpression//gi; - $headContents =~ s/%CONCATINATED%/$concatinatedTag/; -} - -my $inputDirectoryPattern = "(?!External\/)[^\"]*"; -$inputDirectoryPattern = $inputDirectory . "\/[^\"]*" if $inputDirectory; - -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; - -open HTML, ">", "$outputDirectory/" . basename($htmlFile) or die "Can't open $outputDirectory/" . basename($htmlFile) . ": $!"; -print HTML $htmlContents; -close HTML; diff --git a/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb b/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb deleted file mode 100755 index d34e13872..000000000 --- a/Source/WebInspectorUI/Scripts/copy-user-interface-resources-dryrun.rb +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/ruby - -require 'fileutils' -require 'tmpdir' - -if ARGV.size != 1 - puts "usage: #{File.basename $0} <output-directory>" - exit 1 -end - -WEB_INSPECTOR_PATH = File.expand_path File.join(File.dirname(__FILE__), "..") -COPY_USER_INTERFACE_RESOURCES_PATH = File.join WEB_INSPECTOR_PATH, "Scripts", "copy-user-interface-resources.pl" - -$output_directory = File.expand_path ARGV[0] - -Dir.mktmpdir do |tmpdir| - - # Create the output directory if needed. - FileUtils.mkdir_p $output_directory - - # Create empty derived sources expected to exist. - FileUtils.touch(File.join(tmpdir, 'InspectorBackendCommands.js')) - - # Setup the environment and run. - ENV["DERIVED_SOURCES_DIR"] = tmpdir - ENV["JAVASCRIPTCORE_PRIVATE_HEADERS_DIR"] = tmpdir - ENV["SRCROOT"] = WEB_INSPECTOR_PATH - ENV["TARGET_BUILD_DIR"] = $output_directory - ENV["UNLOCALIZED_RESOURCES_FOLDER_PATH"] = "" - ENV["COMBINE_INSPECTOR_RESOURCES"] = "YES" - exec COPY_USER_INTERFACE_RESOURCES_PATH - -end diff --git a/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl b/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl deleted file mode 100755 index 8858bbd87..000000000 --- a/Source/WebInspectorUI/Scripts/copy-user-interface-resources.pl +++ /dev/null @@ -1,211 +0,0 @@ -#!/usr/bin/perl -w - -use English; -use File::Copy qw(copy); -use File::Path qw(make_path remove_tree); -use File::Spec; - -my $useDirCopy = 0; - -# Not all systems (e.g., OS X) include File::Copy::Recursive. Only -# use it if we have it installed. -eval "use File::Copy::Recursive"; -unless ($@) { - $useDirCopy = 1; - File::Copy::Recursive->import(); -} - -sub ditto($$) -{ - my ($source, $destination) = @_; - - if ($useDirCopy) { - File::Copy::Recursive::dircopy($source, $destination) or die "Unable to copy directory $source to $destination: $!"; - } elsif ($^O eq 'darwin') { - system('ditto', $source, $destination); - } else { - die "Please install the PEP module File::Copy::Recursive"; - } -} - -sub seedFile($$) -{ - my ($targetFile, $seedText) = @_; - - if (open(TARGET_FILE, '>', $targetFile)) { - print TARGET_FILE $seedText; - close(TARGET_FILE); - } -} - -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) 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-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 - * 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. - */ -EOF - -my $python = ($OSNAME =~ /cygwin/) ? "/usr/bin/python" : "python"; -my $derivedSourcesDir = $ENV{'DERIVED_SOURCES_DIR'}; -my $scriptsRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'Scripts'); -my $uiRoot = File::Spec->catdir($ENV{'SRCROOT'}, 'UserInterface'); -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 $eslintPath = File::Spec->catdir($uiRoot, 'External', 'ESLint'); - -my $codeMirrorLicense = readLicenseFile(File::Spec->catfile($codeMirrorPath, 'LICENSE')); -my $esprimaLicense = readLicenseFile(File::Spec->catfile($esprimaPath, 'LICENSE')); -my $eslintLicense = readLicenseFile(File::Spec->catfile($eslintPath, 'LICENSE')); - -make_path($protocolDir, $targetResourcePath); - -# Copy over dynamically loaded files from other frameworks, even if we aren't combining resources. -copy(File::Spec->catfile($ENV{'JAVASCRIPTCORE_PRIVATE_HEADERS_DIR'}, 'InspectorBackendCommands.js'), File::Spec->catfile($protocolDir, 'InspectorBackendCommands.js')) or die "Copy of InspectorBackendCommands.js failed: $!"; - -if (defined $ENV{'FORCE_TOOL_INSTALL'} && ($ENV{'FORCE_TOOL_INSTALL'} eq 'YES')) { - # Copy all files over individually to ensure we have Test.html / Test.js and files included from Test.html. - # We may then proceed to include combined & optimized resources which will output mostly to different paths - # but overwrite Main.html / Main.js with optimized versions. - ditto($uiRoot, $targetResourcePath); -} - -if (defined $ENV{'COMBINE_INSPECTOR_RESOURCES'} && ($ENV{'COMBINE_INSPECTOR_RESOURCES'} eq 'YES')) { - my $combineResourcesCmd = File::Spec->catfile($scriptsRoot, 'combine-resources.pl'); - - # Combine the JavaScript and CSS files in Production builds into single files (Main.js and Main.css). - system($combineResourcesCmd, '--input-html', File::Spec->catfile($uiRoot, 'Main.html'), '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'Main.js', '--output-style-name', 'Main.css'); - - # Combine the CodeMirror JavaScript and CSS files in Production builds into single files (CodeMirror.js and CodeMirror.css). - 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'); - - # Combine the ESLint JavaScript files in Production builds into a single file (ESLint.js). - system($combineResourcesCmd, '--input-dir', 'External/ESLint', '--input-html', $derivedSourcesMainHTML, '--input-html-dir', $uiRoot, '--derived-sources-dir', $derivedSourcesDir, '--output-dir', $derivedSourcesDir, '--output-script-name', 'ESLint.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); - - # Fix Image URLs in the Main.css file by removing the "../". - my $derivedSourcesMainCSS = File::Spec->catfile($derivedSourcesDir, 'Main.css'); - if (open(INPUT_MAIN, '<', $derivedSourcesMainCSS)) { - local $/; - my $cssContents = <INPUT_MAIN>; - close(INPUT_MAIN); - open(OUTPUT_MAIN, '>', $derivedSourcesMainCSS); - $cssContents =~ s/\.\.\/Images/Images/g; - print OUTPUT_MAIN $cssContents; - close(OUTPUT_MAIN); - } - - # Export the license into Main.js. - my $targetMainJS = File::Spec->catfile($targetResourcePath, 'Main.js'); - seedFile($targetMainJS, $inspectorLicense); - - my $targetMainCSS = File::Spec->catfile($targetResourcePath, 'Main.css'); - seedFile($targetMainCSS, $inspectorLicense); - - # Export the license into CodeMirror.js and CodeMirror.css. - my $targetCodeMirrorJS = File::Spec->catfile($targetResourcePath, 'CodeMirror.js'); - seedFile($targetCodeMirrorJS, $codeMirrorLicense); - - my $targetCodeMirrorCSS = File::Spec->catfile($targetResourcePath, 'CodeMirror.css'); - seedFile($targetCodeMirrorCSS, $codeMirrorLicense); - - # Export the license into Esprima.js. - my $targetEsprimaJS = File::Spec->catfile($targetResourcePath, 'Esprima.js'); - seedFile($targetEsprimaJS, $esprimaLicense); - - # Export the license into ESLint.js. - my $targetESLintJS = File::Spec->catfile($targetResourcePath, 'ESLint.js'); - seedFile($targetESLintJS, $eslintLicense); - - # 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'); - my $cssMinScript = File::Spec->catfile($scriptsRoot, 'cssmin.py'); - system(qq("$python" "$jsMinScript" < "$derivedSourcesMainJS" >> "$targetMainJS")) and die "Failed to minify $derivedSourcesMainJS: $!"; - system(qq("$python" "$cssMinScript" < "$derivedSourcesMainCSS" >> "$targetMainCSS")) and die "Failed to minify $derivedSourcesMainCSS: $!"; - - # Minify the CodeMirror.js and CodeMirror.css files, appending to the license that was exported above. - my $derivedSouressCodeMirrorJS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.js'); - my $derivedSourcesCodeMirrorCSS = File::Spec->catfile($derivedSourcesDir, 'CodeMirror.css'); - 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: $!"; - - # Minify the ESLint.js file, appending to the license that was exported above. - my $derivedSouressESLintJS = File::Spec->catfile($derivedSourcesDir, 'ESLint.js'); - system(qq("$python" "$jsMinScript" < "$derivedSouressESLintJS" >> "$targetESLintJS")) and die "Failed to minify $derivedSouressESLintJS: $!"; - - # Copy over Main.html and the Images directory. - copy($derivedSourcesMainHTML, File::Spec->catfile($targetResourcePath, 'Main.html')); - - ditto(File::Spec->catdir($uiRoot, 'Images'), File::Spec->catdir($targetResourcePath, 'Images')); - - # Remove Images/Legacy on modern systems (OS X 10.10 Yosemite and greater or Windows). - remove_tree(File::Spec->catdir($targetResourcePath, 'Images', 'Legacy')) if (defined $ENV{'MAC_OS_X_VERSION_MAJOR'} && $ENV{'MAC_OS_X_VERSION_MAJOR'} ge 101000) or defined $ENV{'OFFICIAL_BUILD'}; - - # Remove Images/gtk on Mac and Windows builds. - remove_tree(File::Spec->catdir($targetResourcePath, 'Images', 'gtk')) if defined $ENV{'MAC_OS_X_VERSION_MAJOR'} or defined $ENV{'OFFICIAL_BUILD'}; - - # Copy the Legacy directory. - ditto(File::Spec->catfile($uiRoot, 'Protocol', 'Legacy'), File::Spec->catfile($protocolDir, 'Legacy')); -} else { - # Keep the files separate for engineering builds. - ditto($uiRoot, $targetResourcePath); -} diff --git a/Source/WebInspectorUI/Scripts/cssmin.py b/Source/WebInspectorUI/Scripts/cssmin.py deleted file mode 100755 index 548c200ec..000000000 --- a/Source/WebInspectorUI/Scripts/cssmin.py +++ /dev/null @@ -1,46 +0,0 @@ -#!/usr/bin/python - -# Copyright (C) 2013 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. - -import re - -def cssminify(css): - rules = ( - (r"\/\*.*?\*\/", ""), # delete comments - (r"\n", ""), # delete new lines - (r"\s+", " "), # change multiple spaces to one space - (r"\s?([;{},~>!])\s?", r"\1"), # delete space where it is not needed - (r":\s", ":"), # delete spaces after colons, but not before. E.g. do not break selectors "a :focus", "b :matches(...)", "c :not(...)" where the leading space is significant - (r"\s?([-+])(?:\s(?![0-9(]))", r"\1"), # delete whitespace around + and - when not followed by a number or paren. E.g. strip for selector "a + b" but not "calc(a + b)" which requires spaces. - (r";}", "}") # change ';}' to '}' because the semicolon is not needed - ) - - css = css.replace("\r\n", "\n") - for rule in rules: - css = re.compile(rule[0], re.MULTILINE | re.UNICODE | re.DOTALL).sub(rule[1], css) - return css - -if __name__ == "__main__": - import sys - sys.stdout.write(cssminify(sys.stdin.read())) diff --git a/Source/WebInspectorUI/Scripts/jsmin.py b/Source/WebInspectorUI/Scripts/jsmin.py deleted file mode 100644 index 83d2a50ac..000000000 --- a/Source/WebInspectorUI/Scripts/jsmin.py +++ /dev/null @@ -1,238 +0,0 @@ -# This code is original from jsmin by Douglas Crockford, it was translated to -# Python by Baruch Even. It was rewritten by Dave St.Germain for speed. -# -# The MIT License (MIT) -# -# Copyright (c) 2013 Dave St.Germain -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -import sys -is_3 = sys.version_info >= (3, 0) -if is_3: - import io -else: - import StringIO - try: - import cStringIO - except ImportError: - cStringIO = None - - -__all__ = ['jsmin', 'JavascriptMinify'] -__version__ = '2.0.9' - - -def jsmin(js): - """ - returns a minified version of the javascript string - """ - if not is_3: - if cStringIO and not isinstance(js, unicode): - # strings can use cStringIO for a 3x performance - # improvement, but unicode (in python2) cannot - klass = cStringIO.StringIO - else: - klass = StringIO.StringIO - else: - klass = io.StringIO - ins = klass(js) - outs = klass() - JavascriptMinify(ins, outs).minify() - return outs.getvalue() - - -class JavascriptMinify(object): - """ - Minify an input stream of javascript, writing - to an output stream - """ - - def __init__(self, instream=None, outstream=None): - self.ins = instream - self.outs = outstream - - def minify(self, instream=None, outstream=None): - if instream and outstream: - self.ins, self.outs = instream, outstream - - self.is_return = False - self.return_buf = '' - - def write(char): - # all of this is to support literal regular expressions. - # sigh - if char in 'return': - self.return_buf += char - self.is_return = self.return_buf == 'return' - self.outs.write(char) - if self.is_return: - self.return_buf = '' - - read = self.ins.read - - space_strings = "abcdefghijklmnopqrstuvwxyz"\ - "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$\\" - starters, enders = '{[(+-', '}])+-"\'' - newlinestart_strings = starters + space_strings - newlineend_strings = enders + space_strings - do_newline = False - do_space = False - escape_slash_count = 0 - doing_single_comment = False - previous_before_comment = '' - doing_multi_comment = False - in_re = False - in_quote = '' - quote_buf = [] - - previous = read(1) - if previous == '\\': - escape_slash_count += 1 - next1 = read(1) - if previous == '/': - if next1 == '/': - doing_single_comment = True - elif next1 == '*': - doing_multi_comment = True - previous = next1 - next1 = read(1) - else: - write(previous) - elif not previous: - return - elif previous >= '!': - if previous in "'\"": - in_quote = previous - write(previous) - previous_non_space = previous - else: - previous_non_space = ' ' - if not next1: - return - - while 1: - next2 = read(1) - if not next2: - last = next1.strip() - if not (doing_single_comment or doing_multi_comment)\ - and last not in ('', '/'): - if in_quote: - write(''.join(quote_buf)) - write(last) - break - if doing_multi_comment: - if next1 == '*' and next2 == '/': - doing_multi_comment = False - next2 = read(1) - elif doing_single_comment: - if next1 in '\r\n': - doing_single_comment = False - while next2 in '\r\n': - next2 = read(1) - if not next2: - break - if previous_before_comment in ')}]': - do_newline = True - elif previous_before_comment in space_strings: - write('\n') - elif in_quote: - quote_buf.append(next1) - - if next1 == in_quote: - numslashes = 0 - for c in reversed(quote_buf[:-1]): - if c != '\\': - break - else: - numslashes += 1 - if numslashes % 2 == 0: - in_quote = '' - write(''.join(quote_buf)) - elif next1 in '\r\n': - if previous_non_space in newlineend_strings \ - or previous_non_space > '~': - while 1: - if next2 < '!': - next2 = read(1) - if not next2: - break - else: - if next2 in newlinestart_strings \ - or next2 > '~' or next2 == '/': - do_newline = True - break - elif next1 < '!' and not in_re: - if (previous_non_space in space_strings \ - or previous_non_space > '~') \ - and (next2 in space_strings or next2 > '~'): - do_space = True - elif previous_non_space in '-+' and next2 == previous_non_space: - # protect against + ++ or - -- sequences - do_space = True - elif self.is_return and next2 == '/': - # returning a regex... - write(' ') - elif next1 == '/': - if do_space: - write(' ') - if in_re: - if previous != '\\' or (not escape_slash_count % 2) or next2 in 'gimy': - in_re = False - write('/') - elif next2 == '/': - doing_single_comment = True - previous_before_comment = previous_non_space - elif next2 == '*': - doing_multi_comment = True - previous = next1 - next1 = next2 - next2 = read(1) - else: - in_re = previous_non_space in '(,=:[?!&|' or self.is_return # literal regular expression - write('/') - else: - if do_space: - do_space = False - write(' ') - if do_newline: - write('\n') - do_newline = False - - write(next1) - if not in_re and next1 in "'\"": - in_quote = next1 - quote_buf = [] - - previous = next1 - next1 = next2 - - if previous >= '!': - previous_non_space = previous - - if previous == '\\': - escape_slash_count += 1 - else: - escape_slash_count = 0 - -if __name__ == '__main__': - minifier = JavascriptMinify(sys.stdin, sys.stdout) - minifier.minify() - sys.stdout.write('\n') diff --git a/Source/WebInspectorUI/Scripts/remove-console-asserts-dryrun.rb b/Source/WebInspectorUI/Scripts/remove-console-asserts-dryrun.rb deleted file mode 100755 index 3ecff58ce..000000000 --- a/Source/WebInspectorUI/Scripts/remove-console-asserts-dryrun.rb +++ /dev/null @@ -1,23 +0,0 @@ -#!/usr/bin/ruby - -require "find" - -$verbose = ARGV.include?("--verbose"); -$remove_console_asserts_path = File.expand_path File.join(File.dirname(__FILE__), "remove-console-asserts.pl") -$web_inspector_user_interface_path = File.expand_path File.join(File.dirname(__FILE__), "..", "UserInterface") - -Find.find($web_inspector_user_interface_path) do |path| - # Skip directories, External, Images, and non-js. - next if File.directory?(path) - next if path =~ /\/(External|Images)\// - next if path !~ /\.js$/ - - # Run remove-console-asserts on each file. - puts "Checking: #{path} ..." if $verbose - output = %x{ perl '#{$remove_console_asserts_path}' --input-script '#{path}' --output-script /dev/null } - if !output.empty? - puts "#{File.basename(path)}:" - puts output - puts - end -end diff --git a/Source/WebInspectorUI/Scripts/remove-console-asserts.pl b/Source/WebInspectorUI/Scripts/remove-console-asserts.pl deleted file mode 100755 index 19ec1cfce..000000000 --- a/Source/WebInspectorUI/Scripts/remove-console-asserts.pl +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/perl -w - -use strict; -use Getopt::Long; -use File::Copy qw/move/; -use File::Temp qw/tempfile/; - -our $inputScriptFilename; -our $outputScriptFilename; - -GetOptions('input-script=s' => \$inputScriptFilename, - 'output-script=s' => \$outputScriptFilename); - -unless (defined $inputScriptFilename and defined $outputScriptFilename) { - print "Usage: $0 --input-script <path> --output-script <path>\n"; - exit; -} - -open IN, $inputScriptFilename or die "Couldn't open $inputScriptFilename: $!"; -our ($out, $tempFilename) = tempfile(UNLINK => 0) or die; - -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: $.: $_"; - } - } - - 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 $.: $_" ; - } - } -} - -close $out; -close IN; - -move $tempFilename, $outputScriptFilename or die "$!"; diff --git a/Source/WebInspectorUI/Scripts/update-LegacyInspectorBackendCommands.rb b/Source/WebInspectorUI/Scripts/update-LegacyInspectorBackendCommands.rb deleted file mode 100755 index 21d306e2c..000000000 --- a/Source/WebInspectorUI/Scripts/update-LegacyInspectorBackendCommands.rb +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/ruby - -require 'fileutils' -require 'tmpdir' - -if ARGV.size != 0 - puts "usage: #{File.basename $0}" - exit 1 -end - -WEB_INSPECTOR_PATH = File.expand_path File.join(File.dirname(__FILE__), "..") -JAVASCRIPTCORE_PATH = File.expand_path File.join(File.dirname(__FILE__), "..", "..", "JavaScriptCore") - -$code_generator_path = File.join JAVASCRIPTCORE_PATH, "inspector", "scripts", "generate-inspector-protocol-bindings.py" -$versions_directory_path = File.join WEB_INSPECTOR_PATH, "Versions" -$web_inspector_protocol_legacy_path = File.join WEB_INSPECTOR_PATH, "UserInterface", "Protocol", "Legacy" - -class Task - def initialize(input_json_path, output_directory_path) - @input_json_path = input_json_path - @output_directory_path = output_directory_path - end - - def run - output_filename = "InspectorBackendCommands.js" - display_input = File.basename @input_json_path - display_output = File.join @output_directory_path.gsub(/^.*?\/UserInterface/, "UserInterface"), output_filename - puts "#{display_input} -> #{display_output}" - - Dir.mktmpdir do |tmpdir| - dependency = @dependency_json_path ? "'#{@dependency_json_path}'" : "" - cmd = "#{$code_generator_path} --force --outputDir '#{tmpdir}' --framework JavaScriptCore '#{@input_json_path}' #{dependency}" - %x{ #{cmd} } - if $?.exitstatus != 0 - puts "ERROR: Error Code (#{$?.exitstatus}) Evaluating: #{cmd}" - exit 1 - end - - generated_path = File.join tmpdir, output_filename - if !File.exists?(generated_path) - puts "ERROR: Generated file does not exist at expected path." - exit 1 - end - - FileUtils.mkdir_p @output_directory_path - FileUtils.cp generated_path, @output_directory_path - end - end -end - -def all_tasks - tasks = [] - - had_error = false - Dir.glob(File.join($versions_directory_path, "*.json")).each do |version_path| - match = File.basename(version_path).match(/^Inspector\-(.*?)\-([^-]+?)\.json$/) - if match - output_path = File.join $web_inspector_protocol_legacy_path, match[2] - tasks << Task.new(version_path, output_path) - else - puts "ERROR: Version file (#{version_path}) did not match the template Inspector-<ANYTHING>-<VERSION>.js" - had_error = true - end - end - exit 1 if had_error - - tasks -end - -def main - all_tasks.each { |task| task.run } -end - -main diff --git a/Source/WebInspectorUI/Scripts/update-codemirror-resources.rb b/Source/WebInspectorUI/Scripts/update-codemirror-resources.rb deleted file mode 100755 index e75b9dbf7..000000000 --- a/Source/WebInspectorUI/Scripts/update-codemirror-resources.rb +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/ruby - -require 'fileutils' - -if ARGV.size != 1 - puts "usage: #{File.basename $0} <codemirror-repo-path>" - exit 1 -end - -def verify_code_mirror_repository_path(path) - if !File.directory? path - puts "ERROR: Provided CodeMirror path is not a directory." - exit 1 - end - - Dir.chdir(path) do - results = `git config --list | grep 'marijnh/CodeMirror\.git'` - if $?.exitstatus != 0 || results.split("\n").empty? - puts "ERROR: Provided CodeMirror path does not appear to be a CodeMirror checkout." - exit 1 - end - end -end - -code_mirror_repository_path = File.expand_path ARGV[0] -verify_code_mirror_repository_path code_mirror_repository_path - -web_inspector_user_interface_path = File.expand_path File.join(File.dirname(__FILE__), "../UserInterface") -web_inspector_code_mirror_resources_path = File.join web_inspector_user_interface_path, "/External/CodeMirror" - -CODE_MIRROR_FILES_TO_COPY = %w( - addon/comment/comment.js - addon/display/placeholder.js - addon/edit/closebrackets.js - addon/edit/matchbrackets.js - addon/mode/overlay.js - addon/runmode/runmode.js - addon/search/searchcursor.js - lib/codemirror.css - lib/codemirror.js - mode/clojure/clojure.js - mode/coffeescript/coffeescript.js - mode/css/css.js - mode/htmlmixed/htmlmixed.js - mode/javascript/javascript.js - mode/livescript/livescript.js - mode/sass/sass.js - mode/sql/sql.js - mode/xml/xml.js -) - -all_success = true - -CODE_MIRROR_FILES_TO_COPY.each do |subpath| - from_path = File.join code_mirror_repository_path, subpath - to_path = File.join web_inspector_code_mirror_resources_path, File.basename(subpath) - begin - puts "Copying #{File.basename(subpath)}..." - FileUtils.cp from_path, to_path - rescue Exception => e - puts "WARNING: #{e}" - all_success = false - end -end - -exit all_success ? 0 : 1 |
