Make slider tick mark snapping threshold configurable for each platform
[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-xvfb": ChromiumXVFBPort,
63             "gtk": GtkPort,
64             "mac": MacPort,
65             "win": WinPort,
66             "qt": QtPort,
67             "efl": EflPort,
68         }
69         default_port = {
70             "Windows": WinPort,
71             "Darwin": MacPort,
72         }
73         # Do we really need MacPort as the ultimate default?
74         return ports.get(port_name, default_port.get(platform.system(), MacPort))()
75
76     def makeArgs(self):
77         # FIXME: This shouldn't use a static Executive().
78         args = '--makeargs="-j%s"' % Executive().cpu_count()
79         if os.environ.has_key('MAKEFLAGS'):
80             args = '--makeargs="%s"' % os.environ['MAKEFLAGS']
81         return args
82
83     def update_webkit_command(self, non_interactive=False):
84         return self.script_shell_command("update-webkit")
85
86     def check_webkit_style_command(self):
87         return self.script_shell_command("check-webkit-style")
88
89     def prepare_changelog_command(self):
90         return self.script_shell_command("prepare-ChangeLog")
91
92     def build_webkit_command(self, build_style=None):
93         command = self.script_shell_command("build-webkit")
94         if build_style == "debug":
95             command.append("--debug")
96         if build_style == "release":
97             command.append("--release")
98         return command
99
100     def run_javascriptcore_tests_command(self):
101         return self.script_shell_command("run-javascriptcore-tests")
102
103     def run_webkit_unit_tests_command(self):
104         return None
105
106     def run_webkit_tests_command(self):
107         return self.script_shell_command("run-webkit-tests")
108
109     def run_python_unittests_command(self):
110         return self.script_shell_command("test-webkitpy")
111
112     def run_perl_unittests_command(self):
113         return self.script_shell_command("test-webkitperl")
114
115     def layout_tests_results_path(self):
116         return os.path.join(self.results_directory, "full_results.json")
117
118     def unit_tests_results_path(self):
119         return os.path.join(self.results_directory, "webkit_unit_tests_output.xml")
120
121
122 class MacPort(DeprecatedPort):
123     port_flag_name = "mac"
124
125
126 class WinPort(DeprecatedPort):
127     port_flag_name = "win"
128
129
130 class GtkPort(DeprecatedPort):
131     port_flag_name = "gtk"
132
133     def build_webkit_command(self, build_style=None):
134         command = super(GtkPort, self).build_webkit_command(build_style=build_style)
135         command.append("--gtk")
136         command.append("--update-gtk")
137         command.append(super(GtkPort, self).makeArgs())
138         return command
139
140     def run_webkit_tests_command(self):
141         command = super(GtkPort, self).run_webkit_tests_command()
142         command.append("--gtk")
143         return command
144
145
146 class QtPort(DeprecatedPort):
147     port_flag_name = "qt"
148
149     def build_webkit_command(self, build_style=None):
150         command = super(QtPort, self).build_webkit_command(build_style=build_style)
151         command.append("--qt")
152         command.append(super(QtPort, self).makeArgs())
153         return command
154
155
156 class EflPort(DeprecatedPort):
157     port_flag_name = "efl"
158
159     def build_webkit_command(self, build_style=None):
160         command = super(EflPort, self).build_webkit_command(build_style=build_style)
161         command.append("--efl")
162         command.append(super(EflPort, self).makeArgs())
163         return command
164
165
166 class ChromiumPort(DeprecatedPort):
167     port_flag_name = "chromium"
168
169     def update_webkit_command(self, non_interactive=False):
170         command = super(ChromiumPort, self).update_webkit_command(non_interactive=non_interactive)
171         command.append("--chromium")
172         if non_interactive:
173             command.append("--force-update")
174         return command
175
176     def build_webkit_command(self, build_style=None):
177         command = super(ChromiumPort, self).build_webkit_command(build_style=build_style)
178         command.append("--chromium")
179         command.append("--update-chromium")
180         return command
181
182     def run_webkit_tests_command(self):
183         # Note: This could be run-webkit-tests now.
184         command = self.script_shell_command("new-run-webkit-tests")
185         command.append("--chromium")
186         command.append("--skip-failing-tests")
187         return command
188
189     def run_webkit_unit_tests_command(self):
190         return self.script_shell_command("run-chromium-webkit-unit-tests")
191
192     def run_javascriptcore_tests_command(self):
193         return None
194
195
196 class ChromiumXVFBPort(ChromiumPort):
197     port_flag_name = "chromium-xvfb"
198
199     def run_webkit_tests_command(self):
200         return ["xvfb-run"] + super(ChromiumXVFBPort, self).run_webkit_tests_command()