Clean up ChunkedUpdateDrawingAreaProxy
[WebKit-https.git] / Tools / Scripts / webkitpy / common / config / ports.py
1 # Copyright (C) 2009, Google Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are
5 # met:
6 #
7 #     * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer.
9 #     * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer
11 # in the documentation and/or other materials provided with the
12 # distribution.
13 #     * Neither the name of Google Inc. nor the names of its
14 # contributors may be used to endorse or promote products derived from
15 # this software without specific prior written permission.
16 #
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #
29 # WebKit's Python module for understanding the various ports
30
31 import os
32 import platform
33
34 from webkitpy.common.system.executive import Executive
35
36
37 class WebKitPort(object):
38
39     # We might need to pass scm into this function for scm.checkout_root
40     @classmethod
41     def script_path(cls, script_name):
42         return os.path.join("Tools", "Scripts", script_name)
43
44     @staticmethod
45     def port(port_name):
46         ports = {
47             "chromium": ChromiumPort,
48             "chromium-xvfb": ChromiumXVFBPort,
49             "gtk": GtkPort,
50             "mac": MacPort,
51             "win": WinPort,
52             "qt": QtPort,
53             "efl": EflPort,
54         }
55         default_port = {
56             "Windows": WinPort,
57             "Darwin": MacPort,
58         }
59         # Do we really need MacPort as the ultimate default?
60         return ports.get(port_name, default_port.get(platform.system(), MacPort))
61
62     @staticmethod
63     def makeArgs():
64         args = '--makeargs="-j%s"' % Executive().cpu_count()
65         if os.environ.has_key('MAKEFLAGS'):
66             args = '--makeargs="%s"' % os.environ['MAKEFLAGS']
67         return args
68
69     @classmethod
70     def name(cls):
71         raise NotImplementedError("subclasses must implement")
72
73     @classmethod
74     def flag(cls):
75         raise NotImplementedError("subclasses must implement")
76
77     @classmethod
78     def update_webkit_command(cls):
79         return [cls.script_path("update-webkit")]
80
81     @classmethod
82     def build_webkit_command(cls, build_style=None):
83         command = [cls.script_path("build-webkit")]
84         if build_style == "debug":
85             command.append("--debug")
86         if build_style == "release":
87             command.append("--release")
88         return command
89
90     @classmethod
91     def run_javascriptcore_tests_command(cls):
92         return [cls.script_path("run-javascriptcore-tests")]
93
94     @classmethod
95     def run_webkit_tests_command(cls):
96         return [cls.script_path("run-webkit-tests")]
97
98     @classmethod
99     def run_python_unittests_command(cls):
100         return [cls.script_path("test-webkitpy")]
101
102     @classmethod
103     def run_perl_unittests_command(cls):
104         return [cls.script_path("test-webkitperl")]
105
106     @classmethod
107     def layout_tests_results_path(cls):
108         return "/tmp/layout-test-results/results.html"
109
110
111 class MacPort(WebKitPort):
112
113     @classmethod
114     def name(cls):
115         return "Mac"
116
117     @classmethod
118     def flag(cls):
119         return "--port=mac"
120
121     @classmethod
122     def _system_version(cls):
123         version_string = platform.mac_ver()[0]  # e.g. "10.5.6"
124         version_tuple = version_string.split('.')
125         return map(int, version_tuple)
126
127     @classmethod
128     def is_leopard(cls):
129         return tuple(cls._system_version()[:2]) == (10, 5)
130
131
132 class WinPort(WebKitPort):
133
134     @classmethod
135     def name(cls):
136         return "Win"
137
138     @classmethod
139     def flag(cls):
140         # FIXME: This is lame.  We should autogenerate this from a codename or something.
141         return "--port=win"
142
143
144 class GtkPort(WebKitPort):
145
146     @classmethod
147     def name(cls):
148         return "Gtk"
149
150     @classmethod
151     def flag(cls):
152         return "--port=gtk"
153
154     @classmethod
155     def build_webkit_command(cls, build_style=None):
156         command = WebKitPort.build_webkit_command(build_style=build_style)
157         command.append("--gtk")
158         command.append(WebKitPort.makeArgs())
159         return command
160
161     @classmethod
162     def run_webkit_tests_command(cls):
163         command = WebKitPort.run_webkit_tests_command()
164         command.append("--gtk")
165         return command
166
167
168 class QtPort(WebKitPort):
169
170     @classmethod
171     def name(cls):
172         return "Qt"
173
174     @classmethod
175     def flag(cls):
176         return "--port=qt"
177
178     @classmethod
179     def build_webkit_command(cls, build_style=None):
180         command = WebKitPort.build_webkit_command(build_style=build_style)
181         command.append("--qt")
182         command.append(WebKitPort.makeArgs())
183         return command
184
185
186 class EflPort(WebKitPort):
187
188     @classmethod
189     def name(cls):
190         return "Efl"
191
192     @classmethod
193     def flag(cls):
194         return "--port=efl"
195
196     @classmethod
197     def build_webkit_command(cls, build_style=None):
198         command = WebKitPort.build_webkit_command(build_style=build_style)
199         command.append("--efl")
200         command.append(WebKitPort.makeArgs())
201         return command
202
203
204 class ChromiumPort(WebKitPort):
205
206     @classmethod
207     def name(cls):
208         return "Chromium"
209
210     @classmethod
211     def flag(cls):
212         return "--port=chromium"
213
214     @classmethod
215     def update_webkit_command(cls):
216         command = WebKitPort.update_webkit_command()
217         command.append("--chromium")
218         return command
219
220     @classmethod
221     def build_webkit_command(cls, build_style=None):
222         command = WebKitPort.build_webkit_command(build_style=build_style)
223         command.append("--chromium")
224         command.append("--update-chromium")
225         return command
226
227     @classmethod
228     def run_webkit_tests_command(cls):
229         return [
230             cls.script_path("new-run-webkit-tests"),
231             "--chromium",
232             "--no-pixel-tests",
233         ]
234
235     @classmethod
236     def run_javascriptcore_tests_command(cls):
237         return None
238
239
240 class ChromiumXVFBPort(ChromiumPort):
241
242     @classmethod
243     def flag(cls):
244         return "--port=chromium-xvfb"
245
246     @classmethod
247     def run_webkit_tests_command(cls):
248         # FIXME: We should find a better way to do this.
249         return ["xvfb-run"] + ChromiumPort.run_webkit_tests_command()