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

Side by Side Diff: Source/WebCore/inspector/compile-front-end.py

Issue 13467026: DevTools: move compilation script to inspector/scripts/compile_frontend.py, add closure library. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/WebCore/inspector/generate_protocol_externs.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
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
13 # distribution.
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.
17 #
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.
29
30 import os
31 import os.path
32 import generate_protocol_externs
33 import shutil
34 import sys
35 import tempfile
36
37 inspector_path = "Source/WebCore/inspector"
38 inspector_frontend_path = inspector_path + "/front-end"
39 protocol_externs_path = inspector_frontend_path + "/protocol-externs.js"
40
41 generate_protocol_externs.generate_protocol_externs(protocol_externs_path, inspe ctor_path + "/Inspector.json")
42
43 jsmodule_name_prefix = "jsmodule_"
44 modules = [
45 {
46 "name": "common",
47 "dependencies": [],
48 "sources": [
49 "Color.js",
50 "DOMExtension.js",
51 "Object.js",
52 "ParsedURL.js",
53 "Progress.js",
54 "Settings.js",
55 "UIString.js",
56 "UserMetrics.js",
57 "utilities.js",
58 ]
59 },
60 {
61 "name": "sdk",
62 "dependencies": ["common"],
63 "sources": [
64 "ApplicationCacheModel.js",
65 "CompilerScriptMapping.js",
66 "ConsoleModel.js",
67 "ContentProvider.js",
68 "ContentProviderBasedProjectDelegate.js",
69 "ContentProviders.js",
70 "CookieParser.js",
71 "CSSMetadata.js",
72 "CSSStyleModel.js",
73 "BreakpointManager.js",
74 "Database.js",
75 "DOMAgent.js",
76 "DOMStorage.js",
77 "DebuggerModel.js",
78 "DebuggerScriptMapping.js",
79 "FileManager.js",
80 "FileMapping.js",
81 "FileSystemMapping.js",
82 "FileSystemModel.js",
83 "FileSystemProjectDelegate.js",
84 "FileUtils.js",
85 "HAREntry.js",
86 "IndexedDBModel.js",
87 "InspectorBackend.js",
88 "IsolatedFileSystemManager.js",
89 "IsolatedFileSystem.js",
90 "Linkifier.js",
91 "NetworkLog.js",
92 "NetworkUISourceCodeProvider.js",
93 "PresentationConsoleMessageHelper.js",
94 "RuntimeModel.js",
95 "SASSSourceMapping.js",
96 "Script.js",
97 "ScriptFormatter.js",
98 "ScriptSnippetModel.js",
99 "SimpleWorkspaceProvider.js",
100 "SnippetStorage.js",
101 "SourceMapping.js",
102 "StylesSourceMapping.js",
103 "TimelineManager.js",
104 "RemoteObject.js",
105 "Resource.js",
106 "DefaultScriptMapping.js",
107 "ResourceScriptMapping.js",
108 "LiveEditSupport.js",
109 "ResourceTreeModel.js",
110 "ResourceType.js",
111 "ResourceUtils.js",
112 "SourceMap.js",
113 "NetworkManager.js",
114 "NetworkRequest.js",
115 "UISourceCode.js",
116 "UserAgentSupport.js",
117 "Workspace.js",
118 "protocol-externs.js",
119 ]
120 },
121 {
122 "name": "ui",
123 "dependencies": ["common"],
124 "sources": [
125 "Checkbox.js",
126 "ContextMenu.js",
127 "CodeMirrorTextEditor.js",
128 "DOMSyntaxHighlighter.js",
129 "DataGrid.js",
130 "DefaultTextEditor.js",
131 "Dialog.js",
132 "DockController.js",
133 "Drawer.js",
134 "EmptyView.js",
135 "GoToLineDialog.js",
136 "HelpScreen.js",
137 "InspectorView.js",
138 "KeyboardShortcut.js",
139 "OverviewGrid.js",
140 "Panel.js",
141 "Placard.js",
142 "Popover.js",
143 "ProgressIndicator.js",
144 "PropertiesSection.js",
145 "SearchController.js",
146 "Section.js",
147 "SidebarPane.js",
148 "SidebarTreeElement.js",
149 "ShortcutsScreen.js",
150 "ShowMoreDataGridNode.js",
151 "SidebarOverlay.js",
152 "SoftContextMenu.js",
153 "SourceTokenizer.js",
154 "Spectrum.js",
155 "SplitView.js",
156 "SidebarView.js",
157 "StatusBarButton.js",
158 "SuggestBox.js",
159 "TabbedPane.js",
160 "TextEditor.js",
161 "TextEditorHighlighter.js",
162 "TextEditorModel.js",
163 "TextPrompt.js",
164 "TextUtils.js",
165 "TimelineGrid.js",
166 "Toolbar.js",
167 "UIUtils.js",
168 "View.js",
169 "ViewportControl.js",
170 "treeoutline.js",
171 ]
172 },
173 {
174 "name": "components",
175 "dependencies": ["sdk", "ui"],
176 "sources": [
177 "AdvancedSearchController.js",
178 "HandlerRegistry.js",
179 "ConsoleMessage.js",
180 "CookiesTable.js",
181 "DOMBreakpointsSidebarPane.js",
182 "DOMPresentationUtils.js",
183 "ElementsTreeOutline.js",
184 "FontView.js",
185 "ImageView.js",
186 "NativeBreakpointsSidebarPane.js",
187 "InspectElementModeController.js",
188 "ObjectPopoverHelper.js",
189 "ObjectPropertiesSection.js",
190 "SourceFrame.js",
191 "ResourceView.js",
192 ]
193 },
194 {
195 "name": "elements",
196 "dependencies": ["components"],
197 "sources": [
198 "CSSNamedFlowCollectionsView.js",
199 "CSSNamedFlowView.js",
200 "ElementsPanel.js",
201 "ElementsPanelDescriptor.js",
202 "EventListenersSidebarPane.js",
203 "MetricsSidebarPane.js",
204 "PropertiesSidebarPane.js",
205 "StylesSidebarPane.js",
206 ]
207 },
208 {
209 "name": "network",
210 "dependencies": ["components"],
211 "sources": [
212 "NetworkItemView.js",
213 "RequestCookiesView.js",
214 "RequestHeadersView.js",
215 "RequestHTMLView.js",
216 "RequestJSONView.js",
217 "RequestPreviewView.js",
218 "RequestResponseView.js",
219 "RequestTimingView.js",
220 "RequestView.js",
221 "ResourceWebSocketFrameView.js",
222 "NetworkPanel.js",
223 "NetworkPanelDescriptor.js",
224 ]
225 },
226 {
227 "name": "resources",
228 "dependencies": ["components"],
229 "sources": [
230 "ApplicationCacheItemsView.js",
231 "CookieItemsView.js",
232 "DatabaseQueryView.js",
233 "DatabaseTableView.js",
234 "DirectoryContentView.js",
235 "DOMStorageItemsView.js",
236 "FileContentView.js",
237 "FileSystemView.js",
238 "IndexedDBViews.js",
239 "ResourcesPanel.js",
240 ]
241 },
242 {
243 "name": "workers",
244 "dependencies": ["components"],
245 "sources": [
246 "WorkerManager.js",
247 ]
248 },
249 {
250 "name": "scripts",
251 "dependencies": ["components", "workers"],
252 "sources": [
253 "BreakpointsSidebarPane.js",
254 "CallStackSidebarPane.js",
255 "FilteredItemSelectionDialog.js",
256 "JavaScriptSourceFrame.js",
257 "NavigatorOverlayController.js",
258 "NavigatorView.js",
259 "RevisionHistoryView.js",
260 "ScopeChainSidebarPane.js",
261 "ScriptsNavigator.js",
262 "ScriptsPanel.js",
263 "ScriptsPanelDescriptor.js",
264 "ScriptsSearchScope.js",
265 "SnippetJavaScriptSourceFrame.js",
266 "StyleSheetOutlineDialog.js",
267 "TabbedEditorContainer.js",
268 "UISourceCodeFrame.js",
269 "WatchExpressionsSidebarPane.js",
270 "WorkersSidebarPane.js",
271 ]
272 },
273 {
274 "name": "console",
275 "dependencies": ["components"],
276 "sources": [
277 "ConsoleView.js",
278 "ConsolePanel.js",
279 ]
280 },
281 {
282 "name": "timeline",
283 "dependencies": ["components"],
284 "sources": [
285 "DOMCountersGraph.js",
286 "MemoryStatistics.js",
287 "NativeMemoryGraph.js",
288 "TimelineModel.js",
289 "TimelineOverviewPane.js",
290 "TimelinePanel.js",
291 "TimelinePanelDescriptor.js",
292 "TimelinePresentationModel.js",
293 "TimelineFrameController.js"
294 ]
295 },
296 {
297 "name": "audits",
298 "dependencies": ["components"],
299 "sources": [
300 "AuditCategories.js",
301 "AuditController.js",
302 "AuditFormatters.js",
303 "AuditLauncherView.js",
304 "AuditResultView.js",
305 "AuditRules.js",
306 "AuditsPanel.js",
307 ]
308 },
309 {
310 "name": "extensions",
311 "dependencies": ["components"],
312 "sources": [
313 "ExtensionAPI.js",
314 "ExtensionAuditCategory.js",
315 "ExtensionPanel.js",
316 "ExtensionRegistryStub.js",
317 "ExtensionServer.js",
318 "ExtensionView.js",
319 ]
320 },
321 {
322 "name": "settings",
323 "dependencies": ["components", "extensions"],
324 "sources": [
325 "SettingsScreen.js",
326 "OverridesView.js",
327 ]
328 },
329 {
330 "name": "tests",
331 "dependencies": ["components"],
332 "sources": [
333 "TestController.js",
334 ]
335 },
336 {
337 "name": "profiler",
338 "dependencies": ["components", "workers"],
339 "sources": [
340 "BottomUpProfileDataGridTree.js",
341 "CPUProfileView.js",
342 "CSSSelectorProfileView.js",
343 "FlameChart.js",
344 "HeapSnapshot.js",
345 "HeapSnapshotDataGrids.js",
346 "HeapSnapshotGridNodes.js",
347 "HeapSnapshotLoader.js",
348 "HeapSnapshotProxy.js",
349 "HeapSnapshotView.js",
350 "HeapSnapshotWorker.js",
351 "HeapSnapshotWorkerDispatcher.js",
352 "JSHeapSnapshot.js",
353 "NativeHeapSnapshot.js",
354 "NativeMemorySnapshotView.js",
355 "ProfileDataGridTree.js",
356 "ProfilesPanel.js",
357 "ProfilesPanelDescriptor.js",
358 "ProfileLauncherView.js",
359 "TopDownProfileDataGridTree.js",
360 "CanvasProfileView.js",
361 ]
362 },
363 {
364 "name": "host_stub",
365 "dependencies": ["components", "profiler", "timeline"],
366 "sources": [
367 "InspectorFrontendAPI.js",
368 "InspectorFrontendHostStub.js",
369 ]
370 }
371 ]
372
373 modules_by_name = {}
374 for module in modules:
375 modules_by_name[module["name"]] = module
376
377
378 def dump_module(name, recursively, processed_modules):
379 if name in processed_modules:
380 return ""
381 processed_modules[name] = True
382 module = modules_by_name[name]
383 command = ""
384 if recursively:
385 for dependency in module["dependencies"]:
386 command += dump_module(dependency, recursively, processed_modules)
387 command += " \\\n --module " + jsmodule_name_prefix + module["name"] + ": "
388 command += str(len(module["sources"]))
389 firstDependency = True
390 for dependency in module["dependencies"]:
391 if firstDependency:
392 command += ":"
393 else:
394 command += ","
395 firstDependency = False
396 command += jsmodule_name_prefix + dependency
397 for script in module["sources"]:
398 command += " \\\n --js " + inspector_frontend_path + "/" + script
399 return command
400
401 modules_dir = tempfile.mkdtemp()
402 compiler_command = "java -jar ~/closure/compiler.jar --summary_detail_level 3 -- compilation_level SIMPLE_OPTIMIZATIONS --warning_level VERBOSE --language_in ECM ASCRIPT5 --accept_const_keyword --module_output_path_prefix %s/ \\\n" % modules_ dir
403
404 process_recursively = len(sys.argv) > 1
405 if process_recursively:
406 module_name = sys.argv[1]
407 if module_name != "all":
408 modules = []
409 for i in range(1, len(sys.argv)):
410 modules.append(modules_by_name[sys.argv[i]])
411 for module in modules:
412 command = compiler_command
413 command += " --externs " + inspector_frontend_path + "/externs.js"
414 command += dump_module(module["name"], True, {})
415 print "Compiling \"" + module["name"] + "\""
416 os.system(command)
417 else:
418 command = compiler_command
419 command += " --externs " + inspector_frontend_path + "/externs.js"
420 for module in modules:
421 command += dump_module(module["name"], False, {})
422 os.system(command)
423
424 if not process_recursively:
425 print "Compiling InjectedScriptSource.js..."
426 os.system("echo \"var injectedScriptValue = \" > " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
427 os.system("cat " + inspector_path + "/" + "InjectedScriptSource.js" + " >> " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
428 command = compiler_command
429 command += " --externs " + inspector_path + "/" + "InjectedScriptExterns. js" + " \\\n"
430 command += " --externs " + protocol_externs_path + " \\\n"
431 command += " --module " + jsmodule_name_prefix + "injected_script" + ":" + "1" + " \\\n"
432 command += " --js " + inspector_path + "/" + "InjectedScriptSourceTmp .js" + " \\\n"
433 command += "\n"
434 os.system(command)
435 os.system("rm " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
436
437 print "Compiling InjectedScriptCanvasModuleSource.js..."
438 os.system("echo \"var injectedScriptCanvasModuleValue = \" > " + inspector_p ath + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
439 os.system("cat " + inspector_path + "/" + "InjectedScriptCanvasModuleSource .js" + " >> " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
440 command = compiler_command
441 command += " --externs " + inspector_path + "/" + "InjectedScriptExterns. js" + " \\\n"
442 command += " --externs " + protocol_externs_path + " \\\n"
443 command += " --module " + jsmodule_name_prefix + "injected_script" + ":" + "1" + " \\\n"
444 command += " --js " + inspector_path + "/" + "InjectedScriptCanvasMod uleSourceTmp.js" + " \\\n"
445 command += "\n"
446 os.system(command)
447 os.system("rm " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTm p.js")
448
449 shutil.rmtree(modules_dir)
450 #os.system("rm " + protocol_externs_path)
OLDNEW
« no previous file with comments | « no previous file | Source/WebCore/inspector/generate_protocol_externs.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698