Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1380)

Unified Diff: Source/devtools/scripts/compile_frontend.py

Issue 458753003: Revert of DevTools: Introduce module initializers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/scripts/compile_frontend.py
diff --git a/Source/devtools/scripts/compile_frontend.py b/Source/devtools/scripts/compile_frontend.py
index 0b1f1f228a8dd7d3e32887ca2592e2e731b4228b..632ce53652c1067619bf3126ea13983210790a66 100755
--- a/Source/devtools/scripts/compile_frontend.py
+++ b/Source/devtools/scripts/compile_frontend.py
@@ -36,9 +36,9 @@
import sys
import tempfile
try:
+ import json
+except ImportError:
import simplejson as json
-except ImportError:
- import json
scripts_path = path.dirname(path.abspath(__file__))
devtools_path = path.dirname(scripts_path)
@@ -57,9 +57,8 @@
generate_protocol_externs.generate_protocol_externs(protocol_externs_file, path.join(devtools_path, "protocol.json"))
jsmodule_name_prefix = "jsmodule_"
-frontend_modules_name = "frontend_modules.json"
+js_modules_name = "frontend_modules.json"
runtime_module_name = "_runtime"
-module_initializer_name = "_module.js"
def error_excepthook(exctype, value, traceback):
@@ -68,11 +67,30 @@
sys.excepthook = error_excepthook
try:
- with open(path.join(scripts_path, frontend_modules_name), "rt") as js_modules_file:
+ with open(path.join(scripts_path, js_modules_name), "rt") as js_modules_file:
modules = json.loads(js_modules_file.read())
except:
- log_error("Failed to read %s" % frontend_modules_name)
+ print "ERROR: Failed to read %s" % js_modules_name
raise
+
+# `importScript` function must not be used in any files
+# except module headers. Refer to devtools.gyp file for
+# the module header list.
+allowed_import_statements_files = [
+ "console/ConsolePanel.js",
+ "elements/ElementsPanel.js",
+ "resources/ResourcesPanel.js",
+ "network/NetworkPanel.js",
+ "settings/SettingsScreen.js",
+ "sources/SourcesPanel.js",
+ "timeline/TimelinePanel.js",
+ "profiler/ProfilesPanel.js",
+ "audits/AuditsPanel.js",
+ "layers/LayersPanel.js",
+ "extensions/ExtensionServer.js",
+ "source_frame/SourceFrame.js",
+ "documentation/DocumentationView.js",
+]
type_checked_jsdoc_tags_list = ["param", "return", "type", "enum"]
@@ -96,26 +114,21 @@
def hasErrors(output):
return re.search(error_warning_regex, output) != None
-
-def log_error(message):
- print "ERROR: " + message
def verify_importScript_usage():
errors_found = False
for module in modules:
- for file_name in module["sources"]:
- if path.basename(file_name) == module_initializer_name:
- log_error("Module initializer (%s) may not be listed among module's scripts; found in '%s'" % (module_initializer_name, module["name"]))
- errors_found = True
+ for file_name in module['sources']:
+ if file_name in allowed_import_statements_files:
continue
try:
with open(path.join(devtools_frontend_path, file_name), "r") as sourceFile:
source = sourceFile.read()
if re.search(importscript_regex, source):
- log_error("importScript() call only allowed in module initializers (%s); found in %s" % (module_initializer_name, file_name))
+ print "ERROR: importScript function call is allowed in module header files only (found in %s)" % file_name
errors_found = True
except:
- log_error("Failed to access %s" % file_name)
+ print "ERROR: Failed to access %s" % file_name
raise
return errors_found
@@ -213,7 +226,7 @@
for module in modules:
for dependency in module["dependencies"]:
if dependency in standalone_modules_by_name:
- log_error("Standalone module '%s' may not be present among the dependencies of '%s'" % (dependency, module["name"]))
+ print "ERROR: Standalone module %s may not be present among the dependencies of %s" % (dependency, module["name"])
errors_found = True
verify_standalone_modules()
@@ -230,7 +243,7 @@
for source in module["sources"]:
referencing_module = seen_files.get(source)
if referencing_module:
- log_error("Duplicate use of %s in '%s' (previously seen in '%s')" % (source, name, referencing_module))
+ print "ERROR: Duplicate use of %s in '%s' (previously seen in '%s')" % (source, name, referencing_module)
seen_files[source] = name
for module_name in standalone_modules_by_name:
« no previous file with comments | « Source/devtools/front_end/timeline/module.json ('k') | Source/devtools/scripts/concatenate_module_descriptors.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698