Changed expectations for webrtc/video-rotation.html.
[WebKit-https.git] / Tools / Scripts / webkitpy / common / config / ports.py
1 # Copyright (C) 2009, Google Inc. All rights reserved.
2 # Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies).
3 # Copyright (C) 2015, 2017 Apple Inc. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 #     * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 #     * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 #     * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #
31 # WebKit's Python module for understanding the various ports
32
33 import os
34 import platform
35 import sys
36
37 from webkitpy.common.system.executive import Executive
38
39
40 class DeprecatedPort(object):
41     results_directory = "/tmp/layout-test-results"
42
43     # Subclasses must override
44     port_flag_name = None
45
46     # FIXME: This is only used by BotInfo.
47     def name(self):
48         return self.__class__
49
50     def flag(self):
51         if self.port_flag_name:
52             return "--port=%s" % self.port_flag_name
53         return None
54
55     # We might need to pass scm into this function for scm.checkout_root
56     def script_path(self, script_name):
57         return os.path.join("Tools", "Scripts", script_name)
58
59     def script_shell_command(self, script_name):
60         script_path = self.script_path(script_name)
61         return Executive.shell_command_for_script(script_path)
62
63     @staticmethod
64     def port(port_name):
65         ports = {
66             "gtk-wk2": GtkWK2Port,
67             "ios-device": IOSPort,
68             # FIXME: https://bugs.webkit.org/show_bug.cgi?id=169302
69             "ios": IOSPort,
70             "ios-simulator-wk2": IOSSimulatorWK2Port,
71             "mac": MacPort,
72             "mac-wk2": MacWK2Port,
73             "win": WinPort,
74             "wincairo": WinCairoPort,
75             "wpe": WpePort,
76         }
77         default_port = {
78             "Windows": WinPort,
79             "Darwin": MacPort,
80         }
81         # Do we really need MacPort as the ultimate default?
82         return ports.get(port_name, default_port.get(platform.system(), MacPort))()
83
84     def makeArgs(self):
85         # FIXME: This shouldn't use a static Executive().
86         args = '--makeargs="-j%s"' % Executive().cpu_count()
87         if os.environ.has_key('MAKEFLAGS'):
88             args = '--makeargs="%s"' % os.environ['MAKEFLAGS']
89         return args
90
91     def update_webkit_command(self, non_interactive=False):
92         return self.script_shell_command("update-webkit")
93
94     def check_webkit_style_command(self):
95         return self.script_shell_command("check-webkit-style")
96
97     def prepare_changelog_command(self):
98         return self.script_shell_command("prepare-ChangeLog")
99
100     def _append_build_style_flag(self, command, build_style):
101         if build_style == "debug":
102             command.append("--debug")
103         elif build_style == "release":
104             command.append("--release")
105         return command
106
107     def build_webkit_command(self, build_style=None):
108         command = self.script_shell_command("build-webkit")
109         return self._append_build_style_flag(command, build_style)
110
111     def build_jsc_command(self, build_style=None):
112         command = self.script_shell_command("build-jsc")
113         return self._append_build_style_flag(command, build_style)
114
115     def run_javascriptcore_tests_command(self, build_style=None):
116         command = self.script_shell_command("run-javascriptcore-tests")
117         command.append("--no-fail-fast")
118         return self._append_build_style_flag(command, build_style)
119
120     def run_webkit_tests_command(self, build_style=None):
121         command = self.script_shell_command("run-webkit-tests")
122         return self._append_build_style_flag(command, build_style)
123
124     def run_python_unittests_command(self):
125         return self.script_shell_command("test-webkitpy")
126
127     def run_perl_unittests_command(self):
128         return self.script_shell_command("test-webkitperl")
129
130     def run_bindings_tests_command(self):
131         return self.script_shell_command("run-bindings-tests")
132
133     def run_api_tests_command(self, build_style=None):
134         command = self.script_shell_command("run-api-tests")
135         return self._append_build_style_flag(command, build_style)
136
137
138 class IOSPort(DeprecatedPort):
139     port_flag_name = "ios-device"
140
141     def build_webkit_command(self, build_style=None):
142         command = super(IOSPort, self).build_webkit_command(build_style=build_style)
143         command.append("--sdk=iphoneos")
144         return command
145
146
147 class IOSSimulatorWK2Port(DeprecatedPort):
148     port_flag_name = "ios-simulator-wk2"
149
150     def build_webkit_command(self, build_style=None):
151         command = super(IOSSimulatorWK2Port, self).build_webkit_command(build_style=build_style)
152         command.append("--sdk=iphonesimulator")
153         return command
154
155     def run_webkit_tests_command(self, build_style=None):
156         command = super(IOSSimulatorWK2Port, self).run_webkit_tests_command(build_style)
157         command.append("--ios-simulator")
158         return command
159
160
161 class MacPort(DeprecatedPort):
162     port_flag_name = "mac"
163
164     def run_webkit_tests_command(self, build_style=None):
165         command = super(MacPort, self).run_webkit_tests_command(build_style)
166         command.append("--dump-render-tree")
167         return command
168
169
170 class MacWK2Port(DeprecatedPort):
171     port_flag_name = "mac-wk2"
172
173
174 class WinPort(DeprecatedPort):
175     port_flag_name = "win"
176
177     def run_bindings_tests_command(self):
178         return None
179
180     def run_webkit_tests_command(self, build_style=None):
181         command = super(WinPort, self).run_webkit_tests_command(build_style)
182         command.append("--dump-render-tree")
183         return command
184
185
186 class WinCairoPort(DeprecatedPort):
187     port_flag_name = "wincairo"
188
189
190 class GtkWK2Port(DeprecatedPort):
191     port_flag_name = "gtk-wk2"
192
193     def build_webkit_command(self, build_style=None):
194         command = super(GtkWK2Port, self).build_webkit_command(build_style=build_style)
195         command.append("--gtk")
196         command.append("--update-gtk")
197         command.append(super(GtkWK2Port, self).makeArgs())
198         return command
199
200     def run_webkit_tests_command(self, build_style=None):
201         command = super(GtkWK2Port, self).run_webkit_tests_command(build_style)
202         command.append("--gtk")
203         return command
204
205
206 class WpePort(DeprecatedPort):
207     port_flag_name = "wpe"
208
209     def build_webkit_command(self, build_style=None):
210         command = super(WpePort, self).build_webkit_command(build_style=build_style)
211         command.append("--wpe")
212         command.append("--update-wpe")
213         command.append(super(WpePort, self).makeArgs())
214         return command
215
216     def run_webkit_tests_command(self, build_style=None):
217         command = super(WpePort, self).run_webkit_tests_command(build_style)
218         command.append("--wpe")
219         return command