2011-04-06 Pavel Podivilov <podivilov@chromium.org>

        Reviewed by Yury Semikhatsky.

        Web Inspector: inline script imports in ScriptFormatterWorker.js so it works in Safari release.
        https://bugs.webkit.org/show_bug.cgi?id=57641

        * WebCore.xcodeproj/project.pbxproj:
        * gyp/streamline-inspector-source.sh:
        * inspector/combine-javascript-resources.pl: Renamed from Source/WebCore/combine-javascript-resources.
        * inspector/inline-javascript-imports.py: Added.

git-svn-id: svn://svn.chromium.org/blink/trunk@83040 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 51c849b5
2011-04-06 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
Web Inspector: inline script imports in ScriptFormatterWorker.js so it works in Safari release.
https://bugs.webkit.org/show_bug.cgi?id=57641
* WebCore.xcodeproj/project.pbxproj:
* gyp/streamline-inspector-source.sh:
* inspector/combine-javascript-resources.pl: Renamed from Source/WebCore/combine-javascript-resources.
* inspector/inline-javascript-imports.py: Added.
2011-04-06 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Eric Seidel.
......@@ -22963,16 +22963,18 @@
);
inputPaths = (
"$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/inspector",
"$(SRCROOT)/combine-javascript-resources",
"$(SRCROOT)/inspector/combine-javascript-resources.pl",
"$(SRCROOT)/inspector/inline-javascript-imports.py",
);
name = "Streamline Inspector Source";
outputPaths = (
"$(DERIVED_FILE_DIR)/WebCore/inspector.html",
"$(DERIVED_FILE_DIR)/WebCore/inspector.js",
"$(DERIVED_FILE_DIR)/WebCore/scriptFormatterWorker.js",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "# Don't do anything for Debug builds, so the Inspector is easier to debug.\nif [[ ${CONFIGURATION:=Debug} == \"Debug\" ]]; then\n exit\nfi\n\n# Combine all script resources in the inspector.html file.\n\"$SRCROOT/combine-javascript-resources\" --input-html \"${SRCROOT}/inspector/front-end/inspector.html\" --generated-scripts-dir ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore --output-dir \"${DERIVED_FILE_DIR}/WebCore\" --output-script-name inspector.js\n\nif [ -d \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\" ]; then\n # Remove any JavaScript files, since they will be replaced with the combined file.\n cd \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\"\n rm *.js\n\n # Copy the modified HTML file and the combined script.\n cp \"${DERIVED_FILE_DIR}/WebCore/inspector.html\" inspector.html\n cp \"${DERIVED_FILE_DIR}/WebCore/inspector.js\" inspector.js\nfi\n";
shellScript = "# Don't do anything for Debug builds, so the Inspector is easier to debug.\nif [[ ${CONFIGURATION:=Debug} == \"Debug\" ]]; then\n exit\nfi\n\n# Combine all script resources in the inspector.html file.\n\"$SRCROOT/inspector/combine-javascript-resources.pl\" --input-html \"${SRCROOT}/inspector/front-end/inspector.html\" --generated-scripts-dir ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore --output-dir \"${DERIVED_FILE_DIR}/WebCore\" --output-script-name inspector.js\n\n# Inline script imports in ScriptFormatterWorker.js file.\n\"$SRCROOT/inspector/inline-javascript-imports.py\" \"${SRCROOT}/inspector/front-end/ScriptFormatterWorker.js\" \"${SRCROOT}/inspector/front-end/UglifyJS\" \"${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js\"\n\nif [ -d \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\" ]; then\n # Remove any JavaScript files, since they will be replaced with the combined file.\n cd \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector\"\n rm *.js\n\n # Copy the modified HTML file and the combined scripts.\n cp \"${DERIVED_FILE_DIR}/WebCore/inspector.html\" inspector.html\n cp \"${DERIVED_FILE_DIR}/WebCore/inspector.js\" inspector.js\n cp \"${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js\" scriptFormatterWorker.js\nfi\n";
};
1C81BA330E97357C00266E07 /* Copy Inspector Resources */ = {
isa = PBXShellScriptBuildPhase;
......@@ -6,14 +6,18 @@ if [[ ${CONFIGURATION:=Debug} == "Debug" ]]; then
fi
# Combine all script resources in the inspector.html file.
"$SRCROOT/../combine-javascript-resources" --input-html "${SRCROOT}/../inspector/front-end/inspector.html" --generated-scripts-dir ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore --output-dir "${DERIVED_FILE_DIR}/WebCore" --output-script-name inspector.js
"$SRCROOT/../inspector/combine-javascript-resources.pl" --input-html "${SRCROOT}/../inspector/front-end/inspector.html" --generated-scripts-dir ${BUILT_PRODUCTS_DIR}/DerivedSources/WebCore --output-dir "${DERIVED_FILE_DIR}/WebCore" --output-script-name inspector.js
# Inline script imports in ScriptFormatterWorker.js file.
"$SRCROOT/../inspector/inline-javascript-imports.py" "${SRCROOT}/../inspector/front-end/ScriptFormatterWorker.js" "${SRCROOT}/../inspector/front-end/UglifyJS" "${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js"
if [ -d "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector" ]; then
# Remove any JavaScript files, since they will be replaced with the combined file.
# Remove any JavaScript files, since they will be replaced with the combined files.
cd "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/inspector"
rm *.js
# Copy the modified HTML file and the combined script.
# Copy the modified HTML file and the combined scripts.
cp "${DERIVED_FILE_DIR}/WebCore/inspector.html" inspector.html
cp "${DERIVED_FILE_DIR}/WebCore/inspector.js" inspector.js
cp "${DERIVED_FILE_DIR}/WebCore/scriptFormatterWorker.js" scriptFormatterWorker.js
fi
#!/usr/bin/env python
#
# Copyright (C) 2011 Google 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:
#
# * 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# 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 THE COPYRIGHT
# OWNER OR 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.
#
# This script replaces calls to importScripts with script sources
# in input script file and dumps result into output script file.
from cStringIO import StringIO
import os.path
import re
import sys
def main(argv):
if len(argv) < 3:
print('usage: %s inputFile importsDir outputFile' % argv[0])
return 1
inputFileName = argv[1]
importsDir = argv[2]
outputFileName = argv[3]
inputFile = open(inputFileName, 'r')
inputScript = inputFile.read()
inputFile.close()
def replace(match):
importFileName = match.group(1)
fullPath = os.path.join(importsDir, importFileName)
if not os.access(fullPath, os.F_OK):
raise Exception('File %s referenced in %s not found on any source paths, '
'check source tree for consistency' %
(importFileName, inputFileName))
importFile = open(fullPath, 'r')
importScript = importFile.read()
importFile.close()
return importScript
outputScript = re.sub(r'importScripts\([\'"]([^\'"]+)[\'"]\)', replace, inputScript)
outputFile = open(outputFileName, 'w')
outputFile.write(outputScript)
outputFile.close()
# Touch output file directory to make sure that Xcode will copy
# modified resource files.
if sys.platform == 'darwin':
outputDirName = os.path.dirname(outputFileName)
os.utime(outputDirName, None)
if __name__ == '__main__':
sys.exit(main(sys.argv))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment