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