2 # Copyright (c) 2012 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 import generate_protocol_externs
37 inspector_path = "Source/WebCore/inspector"
38 inspector_frontend_path = inspector_path + "/front-end"
39 protocol_externs_path = inspector_frontend_path + "/protocol-externs.js"
41 generate_protocol_externs.generate_protocol_externs(protocol_externs_path, inspector_path + "/Inspector.json")
43 jsmodule_name_prefix = "jsmodule_"
62 "dependencies": ["common"],
64 "ApplicationCacheModel.js",
65 "CompilerScriptMapping.js",
68 "ContentProviders.js",
72 "BreakpointManager.js",
77 "DebuggerScriptMapping.js",
80 "FileSystemMapping.js",
82 "FileSystemProjectDelegate.js",
86 "InspectorBackend.js",
87 "IsolatedFileSystemModel.js",
90 "NetworkUISourceCodeProvider.js",
91 "PresentationConsoleMessageHelper.js",
93 "SASSSourceMapping.js",
96 "ScriptSnippetModel.js",
97 "SimpleWorkspaceProvider.js",
100 "StylesSourceMapping.js",
101 "TimelineManager.js",
104 "DefaultScriptMapping.js",
105 "ResourceScriptMapping.js",
106 "LiveEditSupport.js",
107 "ResourceTreeModel.js",
114 "UserAgentSupport.js",
116 "protocol-externs.js",
121 "dependencies": ["common"],
125 "DOMSyntaxHighlighter.js",
127 "DefaultTextEditor.js",
134 "KeyboardShortcut.js",
136 "PanelEnablerView.js",
139 "ProgressIndicator.js",
140 "PropertiesSection.js",
141 "SearchController.js",
144 "SidebarTreeElement.js",
145 "ShortcutsScreen.js",
146 "ShowMoreDataGridNode.js",
148 "SoftContextMenu.js",
149 "SourceTokenizer.js",
153 "StatusBarButton.js",
156 "TextEditorHighlighter.js",
157 "TextEditorModel.js",
164 "ViewportControl.js",
169 "name": "components",
170 "dependencies": ["sdk", "ui"],
172 "AdvancedSearchController.js",
173 "HandlerRegistry.js",
176 "DOMBreakpointsSidebarPane.js",
177 "DOMPresentationUtils.js",
178 "ElementsTreeOutline.js",
181 "NativeBreakpointsSidebarPane.js",
182 "ObjectPopoverHelper.js",
183 "ObjectPropertiesSection.js",
190 "dependencies": ["components"],
192 "CSSNamedFlowCollectionsView.js",
193 "CSSNamedFlowView.js",
195 "ElementsPanelDescriptor.js",
196 "EventListenersSidebarPane.js",
197 "MetricsSidebarPane.js",
198 "PropertiesSidebarPane.js",
199 "StylesSidebarPane.js",
204 "dependencies": ["components"],
206 "NetworkItemView.js",
207 "RequestCookiesView.js",
208 "RequestHeadersView.js",
209 "RequestHTMLView.js",
210 "RequestJSONView.js",
211 "RequestPreviewView.js",
212 "RequestResponseView.js",
213 "RequestTimingView.js",
215 "ResourceWebSocketFrameView.js",
217 "NetworkPanelDescriptor.js",
222 "dependencies": ["components"],
224 "ApplicationCacheItemsView.js",
225 "CookieItemsView.js",
226 "DatabaseQueryView.js",
227 "DatabaseTableView.js",
228 "DirectoryContentView.js",
229 "DOMStorageItemsView.js",
230 "FileContentView.js",
238 "dependencies": ["components"],
245 "dependencies": ["components", "workers"],
247 "BreakpointsSidebarPane.js",
248 "CallStackSidebarPane.js",
249 "FilteredItemSelectionDialog.js",
250 "JavaScriptSourceFrame.js",
251 "NavigatorOverlayController.js",
253 "RevisionHistoryView.js",
254 "ScopeChainSidebarPane.js",
255 "ScriptsNavigator.js",
257 "ScriptsPanelDescriptor.js",
258 "ScriptsSearchScope.js",
259 "SnippetJavaScriptSourceFrame.js",
260 "StyleSheetOutlineDialog.js",
261 "TabbedEditorContainer.js",
262 "UISourceCodeFrame.js",
263 "WatchExpressionsSidebarPane.js",
264 "WorkersSidebarPane.js",
269 "dependencies": ["components"],
277 "dependencies": ["components"],
279 "MemoryStatistics.js",
281 "TimelineOverviewPane.js",
283 "TimelinePanelDescriptor.js",
284 "TimelinePresentationModel.js",
285 "TimelineFrameController.js"
290 "dependencies": ["components"],
292 "AuditCategories.js",
293 "AuditFormatters.js",
294 "AuditLauncherView.js",
295 "AuditResultView.js",
301 "name": "extensions",
302 "dependencies": ["components"],
305 "ExtensionAuditCategory.js",
307 "ExtensionRegistryStub.js",
308 "ExtensionServer.js",
314 "dependencies": ["components", "extensions"],
322 "dependencies": ["components"],
329 "dependencies": ["components"],
331 "BottomUpProfileDataGridTree.js",
333 "CSSSelectorProfileView.js",
335 "HeapSnapshotDataGrids.js",
336 "HeapSnapshotGridNodes.js",
337 "HeapSnapshotLoader.js",
338 "HeapSnapshotProxy.js",
339 "HeapSnapshotView.js",
340 "HeapSnapshotWorker.js",
341 "HeapSnapshotWorkerDispatcher.js",
343 "NativeHeapSnapshot.js",
344 "NativeMemorySnapshotView.js",
345 "ProfileDataGridTree.js",
347 "ProfileLauncherView.js",
348 "TopDownProfileDataGridTree.js",
349 "CanvasProfileView.js",
354 "dependencies": ["ui"],
356 "InspectorFrontendAPI.js",
357 "InspectorFrontendHostStub.js",
362 "dependencies": ["components"],
370 for module in modules:
371 modules_by_name[module["name"]] = module
374 def dump_module(name, recursively, processed_modules):
375 if name in processed_modules:
377 processed_modules[name] = True
378 module = modules_by_name[name]
381 for dependency in module["dependencies"]:
382 command += dump_module(dependency, recursively, processed_modules)
383 command += " \\\n --module " + jsmodule_name_prefix + module["name"] + ":"
384 command += str(len(module["sources"]))
385 firstDependency = True
386 for dependency in module["dependencies"]:
391 firstDependency = False
392 command += jsmodule_name_prefix + dependency
393 for script in module["sources"]:
394 command += " \\\n --js " + inspector_frontend_path + "/" + script
397 modules_dir = tempfile.mkdtemp()
398 compiler_command = "java -jar ~/closure/compiler.jar --summary_detail_level 3 --compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECMASCRIPT5 --accept_const_keyword --module_output_path_prefix %s/ \\\n" % modules_dir
400 process_recursively = len(sys.argv) > 1
401 if process_recursively:
402 module_name = sys.argv[1]
403 if module_name != "all":
405 for i in range(1, len(sys.argv)):
406 modules.append(modules_by_name[sys.argv[i]])
407 for module in modules:
408 command = compiler_command
409 command += " --externs " + inspector_frontend_path + "/externs.js"
410 command += dump_module(module["name"], True, {})
411 print "Compiling \"" + module["name"] + "\""
414 command = compiler_command
415 command += " --externs " + inspector_frontend_path + "/externs.js"
416 for module in modules:
417 command += dump_module(module["name"], False, {})
420 if not process_recursively:
421 print "Compiling InjectedScriptSource.js..."
422 os.system("echo \"var injectedScriptValue = \" > " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
423 os.system("cat " + inspector_path + "/" + "InjectedScriptSource.js" + " >> " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
424 command = compiler_command
425 command += " --externs " + inspector_path + "/" + "InjectedScriptExterns.js" + " \\\n"
426 command += " --externs " + protocol_externs_path + " \\\n"
427 command += " --module " + jsmodule_name_prefix + "injected_script" + ":" + "1" + " \\\n"
428 command += " --js " + inspector_path + "/" + "InjectedScriptSourceTmp.js" + " \\\n"
431 os.system("rm " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
433 print "Compiling InjectedScriptCanvasModuleSource.js..."
434 os.system("echo \"var injectedScriptCanvasModuleValue = \" > " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
435 os.system("cat " + inspector_path + "/" + "InjectedScriptCanvasModuleSource.js" + " >> " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
436 command = compiler_command
437 command += " --externs " + inspector_path + "/" + "InjectedScriptExterns.js" + " \\\n"
438 command += " --externs " + protocol_externs_path + " \\\n"
439 command += " --module " + jsmodule_name_prefix + "injected_script" + ":" + "1" + " \\\n"
440 command += " --js " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js" + " \\\n"
443 os.system("rm " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
445 shutil.rmtree(modules_dir)
446 #os.system("rm " + protocol_externs_path)