Add Mac WK2 EWS bots
[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 import sys
34
35 from webkitpy.common.system.executive import Executive
36
37
38 class DeprecatedPort(object):
39     results_directory = "/tmp/layout-test-results"
40
41     # Subclasses must override
42     port_flag_name = None
43
44     # FIXME: This is only used by BotInfo.
45     def name(self):
46         return self.__class__
47
48     def flag(self):
49         if self.port_flag_name:
50             return "--port=%s" % self.port_flag_name
51         return None
52
53     # We might need to pass scm into this function for scm.checkout_root
54     def script_path(self, script_name):
55         return os.path.join("Tools", "Scripts", script_name)
56
57     def script_shell_command(self, script_name):
58         script_path = self.script_path(script_name)
59         return Executive.shell_command_for_script(script_path)
60
61     @staticmethod
62     def port(port_name):
63         ports = {
64             "chromium": ChromiumPort,
65             "chromium-android": ChromiumAndroidPort,
66             "chromium-xvfb": ChromiumXVFBPort,
67             "gtk": GtkPort,
68             "mac": MacPort,
69             "mac-wk2": MacWK2Port,
70             "win": WinPort,
71             "qt": QtPort,
72             "efl": EflPort,
73         }
74         default_port = {
75             "Windows": WinPort,
76             "Darwin": MacPort,
77         }
78         # Do we really need MacPort as the ultimate default?
79         return ports.get(port_name, default_port.get(platform.system(), MacPort))()
80
81     def makeArgs(self):
82         # FIXME: This shouldn't use a static Executive().
83         args = '--makeargs="-j%s"' % Executive().cpu_count()
84         if os.environ.has_key('MAKEFLAGS'):
85             args = '--makeargs="%s"' % os.environ['MAKEFLAGS']
86         return args
87
88     def update_webkit_command(self, non_interactive=False):
89         return self.script_shell_command("update-webkit")
90
91     def check_webkit_style_command(self):
92         return self.script_shell_command("check-webkit-style")
93
94     def prepare_changelog_command(self):
95         return self.script_shell_command("prepare-ChangeLog")
96
97     def build_webkit_command(self, build_style=None):
98         command = self.script_shell_command("build-webkit")
99         if build_style == "debug":
100             command.append("--debug")
101         if build_style == "release":
102             command.append("--release")
103         return command
104
105     def run_javascriptcore_tests_command(self):
106         return self.script_shell_command("run-javascriptcore-tests")
107
108     def run_webkit_unit_tests_command(self):
109         return None
110
111     def run_webkit_tests_command(self):
112         return self.script_shell_command("run-webkit-tests")
113
114     def run_python_unittests_command(self):
115         return self.script_shell_command("test-webkitpy")
116
117     def run_perl_unittests_command(self):
118         return self.script_shell_command("test-webkitperl")
119
120
121 class MacPort(DeprecatedPort):
122     port_flag_name = "mac"
123
124
125 class MacWK2Port(DeprecatedPort):
126     port_flag_name = "mac"
127
128     def run_webkit_tests_command(self):
129         command = super(MacWK2Port, self).run_webkit_tests_command()
130         command.append("-2")
131         return command
132
133
134 class WinPort(DeprecatedPort):
135     port_flag_name = "win"
136
137
138 class GtkPort(DeprecatedPort):
139     port_flag_name = "gtk"
140
141     def build_webkit_command(self, build_style=None):
142         command = super(GtkPort, self).build_webkit_command(build_style=build_style)
143         command.append("--gtk")
144         command.append("--update-gtk")
145         command.append(super(GtkPort, self).makeArgs())
146         return command
147
148     def run_webkit_tests_command(self):
149         command = super(GtkPort, self).run_webkit_tests_command()
150         command.append("--gtk")
151         return command
152
153
154 class QtPort(DeprecatedPort):
155     port_flag_name = "qt"
156
157     def build_webkit_command(self, build_style=None):
158         command = super(QtPort, self).build_webkit_command(build_style=build_style)
159         command.append("--qt")
160         command.append(super(QtPort, self).makeArgs())
161         return command
162
163
164 class EflPort(DeprecatedPort):
165     port_flag_name = "efl"
166
167     def build_webkit_command(self, build_style=None):
168         command = super(EflPort, self).build_webkit_command(build_style=build_style)
169         command.append("--efl")
170         command.append("--update-efl")
171         command.append(super(EflPort, self).makeArgs())
172         return command
173
174
175 class ChromiumPort(DeprecatedPort):
176     port_flag_name = "chromium"
177
178     def update_webkit_command(self, non_interactive=False):
179         command = super(ChromiumPort, self).update_webkit_command(non_interactive=non_interactive)
180         command.append("--chromium")
181         if non_interactive:
182             command.append("--force-update")
183         return command
184
185     def build_webkit_command(self, build_style=None):
186         command = super(ChromiumPort, self).build_webkit_command(build_style=build_style)
187         command.append("--chromium")
188         command.append("--update-chromium")
189         return command
190
191     def run_webkit_tests_command(self):
192         # Note: This could be run-webkit-tests now.
193         command = self.script_shell_command("new-run-webkit-tests")
194         command.append("--chromium")
195         command.append("--skip-failing-tests")
196         return command
197
198     def run_webkit_unit_tests_command(self):
199         return self.script_shell_command("run-chromium-webkit-unit-tests")
200
201     def run_javascriptcore_tests_command(self):
202         return None
203
204
205 class ChromiumAndroidPort(ChromiumPort):
206     port_flag_name = "chromium-android"
207
208     def update_webkit_command(self, non_interactive=False):
209         command = super(ChromiumAndroidPort, self).update_webkit_command(non_interactive=non_interactive)
210         command.append("--chromium-android")
211         return command
212
213     def build_webkit_command(self, build_style=None):
214         command = super(ChromiumAndroidPort, self).build_webkit_command(build_style=build_style)
215         command.append("--chromium-android")
216         return command
217
218
219 class ChromiumXVFBPort(ChromiumPort):
220     port_flag_name = "chromium-xvfb"
221
222     def run_webkit_tests_command(self):
223         return ["xvfb-run"] + super(ChromiumXVFBPort, self).run_webkit_tests_command()