[GTK] Enable CSS Variables feature in development builds
[WebKit-https.git] / Source / WebCore / inspector / compile-front-end.py
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, inspector_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             "ContentProviders.js",
69             "CookieParser.js",
70             "CSSMetadata.js",
71             "CSSStyleModel.js",
72             "BreakpointManager.js",
73             "Database.js",
74             "DOMAgent.js",
75             "DOMStorage.js",
76             "DebuggerModel.js",
77             "DebuggerScriptMapping.js",
78             "FileManager.js",
79             "FileMapping.js",
80             "FileSystemMapping.js",
81             "FileSystemModel.js",
82             "FileSystemProjectDelegate.js",
83             "FileUtils.js",
84             "HAREntry.js",
85             "IndexedDBModel.js",
86             "InspectorBackend.js",
87             "IsolatedFileSystemModel.js",
88             "Linkifier.js",
89             "NetworkLog.js",
90             "NetworkUISourceCodeProvider.js",
91             "PresentationConsoleMessageHelper.js",
92             "RuntimeModel.js",
93             "SASSSourceMapping.js",
94             "Script.js",
95             "ScriptFormatter.js",
96             "ScriptSnippetModel.js",
97             "SimpleWorkspaceProvider.js",
98             "SnippetStorage.js",
99             "SourceMapping.js",
100             "StylesSourceMapping.js",
101             "TimelineManager.js",
102             "RemoteObject.js",
103             "Resource.js",
104             "DefaultScriptMapping.js",
105             "ResourceScriptMapping.js",
106             "LiveEditSupport.js",
107             "ResourceTreeModel.js",
108             "ResourceType.js",
109             "ResourceUtils.js",
110             "SourceMap.js",
111             "NetworkManager.js",
112             "NetworkRequest.js",
113             "UISourceCode.js",
114             "UserAgentSupport.js",
115             "Workspace.js",
116             "protocol-externs.js",
117         ]
118     },
119     {
120         "name": "ui",
121         "dependencies": ["common"],
122         "sources": [
123             "Checkbox.js",
124             "ContextMenu.js",
125             "DOMSyntaxHighlighter.js",
126             "DataGrid.js",
127             "DefaultTextEditor.js",
128             "Dialog.js",
129             "Drawer.js",
130             "EmptyView.js",
131             "GoToLineDialog.js",
132             "HelpScreen.js",
133             "InspectorView.js",
134             "KeyboardShortcut.js",
135             "Panel.js",
136             "PanelEnablerView.js",
137             "Placard.js",
138             "Popover.js",
139             "ProgressIndicator.js",
140             "PropertiesSection.js",
141             "SearchController.js",
142             "Section.js",
143             "SidebarPane.js",
144             "SidebarTreeElement.js",
145             "ShortcutsScreen.js",
146             "ShowMoreDataGridNode.js",
147             "SidebarOverlay.js",
148             "SoftContextMenu.js",
149             "SourceTokenizer.js",
150             "Spectrum.js",
151             "SplitView.js",
152             "SidebarView.js",
153             "StatusBarButton.js",
154             "TabbedPane.js",
155             "TextEditor.js",
156             "TextEditorHighlighter.js",
157             "TextEditorModel.js",
158             "TextPrompt.js",
159             "TextUtils.js",
160             "TimelineGrid.js",
161             "Toolbar.js",
162             "UIUtils.js",
163             "View.js",
164             "ViewportControl.js",
165             "treeoutline.js",
166         ]
167     },
168     {
169         "name": "components",
170         "dependencies": ["sdk", "ui"],
171         "sources": [
172             "AdvancedSearchController.js",
173             "HandlerRegistry.js",
174             "ConsoleMessage.js",
175             "CookiesTable.js",
176             "DOMBreakpointsSidebarPane.js",
177             "DOMPresentationUtils.js",
178             "ElementsTreeOutline.js",
179             "FontView.js",
180             "ImageView.js",
181             "NativeBreakpointsSidebarPane.js",
182             "ObjectPopoverHelper.js",
183             "ObjectPropertiesSection.js",
184             "SourceFrame.js",
185             "ResourceView.js",
186         ]
187     },
188     {
189         "name": "elements",
190         "dependencies": ["components"],
191         "sources": [
192             "CSSNamedFlowCollectionsView.js",
193             "CSSNamedFlowView.js",
194             "ElementsPanel.js",
195             "ElementsPanelDescriptor.js",
196             "EventListenersSidebarPane.js",
197             "MetricsSidebarPane.js",
198             "PropertiesSidebarPane.js",
199             "StylesSidebarPane.js",
200         ]
201     },
202     {
203         "name": "network",
204         "dependencies": ["components"],
205         "sources": [
206             "NetworkItemView.js",
207             "RequestCookiesView.js",
208             "RequestHeadersView.js",
209             "RequestHTMLView.js",
210             "RequestJSONView.js",
211             "RequestPreviewView.js",
212             "RequestResponseView.js",
213             "RequestTimingView.js",
214             "RequestView.js",
215             "ResourceWebSocketFrameView.js",
216             "NetworkPanel.js",
217             "NetworkPanelDescriptor.js",
218         ]
219     },
220     {
221         "name": "resources",
222         "dependencies": ["components"],
223         "sources": [
224             "ApplicationCacheItemsView.js",
225             "CookieItemsView.js",
226             "DatabaseQueryView.js",
227             "DatabaseTableView.js",
228             "DirectoryContentView.js",
229             "DOMStorageItemsView.js",
230             "FileContentView.js",
231             "FileSystemView.js",
232             "IndexedDBViews.js",
233             "ResourcesPanel.js",
234         ]
235     },
236     {
237         "name": "workers",
238         "dependencies": ["components"],
239         "sources": [
240             "WorkerManager.js",
241         ]
242     },
243     {
244         "name": "scripts",
245         "dependencies": ["components", "workers"],
246         "sources": [
247             "BreakpointsSidebarPane.js",
248             "CallStackSidebarPane.js",
249             "FilteredItemSelectionDialog.js",
250             "JavaScriptSourceFrame.js",
251             "NavigatorOverlayController.js",
252             "NavigatorView.js",
253             "RevisionHistoryView.js",
254             "ScopeChainSidebarPane.js",
255             "ScriptsNavigator.js",
256             "ScriptsPanel.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",
265         ]
266     },
267     {
268         "name": "console",
269         "dependencies": ["components"],
270         "sources": [
271             "ConsoleView.js",
272             "ConsolePanel.js",
273         ]
274     },
275     {
276         "name": "timeline",
277         "dependencies": ["components"],
278         "sources": [
279             "MemoryStatistics.js",
280             "TimelineModel.js",
281             "TimelineOverviewPane.js",
282             "TimelinePanel.js",
283             "TimelinePanelDescriptor.js",
284             "TimelinePresentationModel.js",
285             "TimelineFrameController.js"
286         ]
287     },
288     {
289         "name": "audits",
290         "dependencies": ["components"],
291         "sources": [
292             "AuditCategories.js",
293             "AuditFormatters.js",
294             "AuditLauncherView.js",
295             "AuditResultView.js",
296             "AuditRules.js",
297             "AuditsPanel.js",
298         ]
299     },
300     {
301         "name": "extensions",
302         "dependencies": ["components"],
303         "sources": [
304             "ExtensionAPI.js",
305             "ExtensionAuditCategory.js",
306             "ExtensionPanel.js",
307             "ExtensionRegistryStub.js",
308             "ExtensionServer.js",
309             "ExtensionView.js",
310         ]
311     },
312     {
313         "name": "settings",
314         "dependencies": ["components", "extensions"],
315         "sources": [
316             "SettingsScreen.js",
317             "OverridesView.js",
318         ]
319     },
320     {
321         "name": "tests",
322         "dependencies": ["components"],
323         "sources": [
324             "TestController.js",
325         ]
326     },
327     {
328         "name": "profiler",
329         "dependencies": ["components"],
330         "sources": [
331             "BottomUpProfileDataGridTree.js",
332             "CPUProfileView.js",
333             "CSSSelectorProfileView.js",
334             "HeapSnapshot.js",
335             "HeapSnapshotDataGrids.js",
336             "HeapSnapshotGridNodes.js",
337             "HeapSnapshotLoader.js",
338             "HeapSnapshotProxy.js",
339             "HeapSnapshotView.js",
340             "HeapSnapshotWorker.js",
341             "HeapSnapshotWorkerDispatcher.js",
342             "JSHeapSnapshot.js",
343             "NativeHeapSnapshot.js",
344             "NativeMemorySnapshotView.js",
345             "ProfileDataGridTree.js",
346             "ProfilesPanel.js",
347             "ProfileLauncherView.js",
348             "TopDownProfileDataGridTree.js",
349             "CanvasProfileView.js",
350         ]
351     },
352     {
353         "name": "host_stub",
354         "dependencies": ["ui"],
355         "sources": [
356             "InspectorFrontendAPI.js",
357             "InspectorFrontendHostStub.js",
358         ]
359     },
360     {
361         "name": "inspector",
362         "dependencies": ["components"],
363         "sources": [
364             "DockController.js",
365         ]
366     },
367 ]
368
369 modules_by_name = {}
370 for module in modules:
371     modules_by_name[module["name"]] = module
372
373
374 def dump_module(name, recursively, processed_modules):
375     if name in processed_modules:
376         return ""
377     processed_modules[name] = True
378     module = modules_by_name[name]
379     command = ""
380     if recursively:
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"]:
387         if firstDependency:
388             command += ":"
389         else:
390             command += ","
391         firstDependency = False
392         command += jsmodule_name_prefix + dependency
393     for script in module["sources"]:
394         command += " \\\n        --js " + inspector_frontend_path + "/" + script
395     return command
396
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
399
400 process_recursively = len(sys.argv) > 1
401 if process_recursively:
402     module_name = sys.argv[1]
403     if module_name != "all":
404         modules = []
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"] + "\""
412         os.system(command)
413 else:
414     command = compiler_command
415     command += "    --externs " + inspector_frontend_path + "/externs.js"
416     for module in modules:
417         command += dump_module(module["name"], False, {})
418     os.system(command)
419
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"
429     command += "\n"
430     os.system(command)
431     os.system("rm " + inspector_path + "/" + "InjectedScriptSourceTmp.js")
432
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"
441     command += "\n"
442     os.system(command)
443     os.system("rm " + inspector_path + "/" + "InjectedScriptCanvasModuleSourceTmp.js")
444
445 shutil.rmtree(modules_dir)
446 #os.system("rm " + protocol_externs_path)