2 # Copyright (C) 2010 Google Inc. All rights reserved.
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 """Chromium Mac implementation of the Port interface."""
36 from webkitpy.layout_tests.port import mac
37 from webkitpy.layout_tests.port import chromium
39 from webkitpy.common.system.executive import Executive
42 _log = logging.getLogger(__name__)
45 class ChromiumMacPort(chromium.ChromiumPort):
46 SUPPORTED_OS_VERSIONS = ('leopard', 'snowleopard', 'lion', 'future')
50 'chromium-mac-leopard',
51 'chromium-mac-snowleopard',
60 'chromium-mac-snowleopard',
82 'chromium-cg-mac-leopard',
83 'chromium-cg-mac-snowleopard',
92 'chromium-cg-mac-snowleopard',
112 def __init__(self, host, port_name=None, os_version_string=None, **kwargs):
113 # We're a little generic here because this code is reused by the
114 # 'google-chrome' port as well as the 'mock-' and 'dryrun-' ports.
115 port_name = port_name or 'chromium-cg-mac'
116 chromium.ChromiumPort.__init__(self, host, port_name=port_name, **kwargs)
117 if port_name.endswith('-mac'):
118 self._version = mac.os_version(os_version_string, self.SUPPORTED_OS_VERSIONS)
119 self._name = port_name + '-' + self._version
121 self._version = port_name[port_name.index('-mac-') + len('-mac-'):]
122 assert self._version in self.SUPPORTED_OS_VERSIONS
123 self._using_core_graphics = port_name.find('-cg-') != -1
124 if self._using_core_graphics:
125 self._graphics_type = 'cpu-cg'
127 self._graphics_type = 'cpu'
128 self._operating_system = 'mac'
130 def baseline_search_path(self):
131 fallback_paths = self.FALLBACK_PATHS
132 if self._using_core_graphics:
133 fallback_paths = self.FALLBACK_PATHS_CG
134 return map(self._webkit_baseline_path, fallback_paths[self._version])
136 def check_build(self, needs_http):
137 result = chromium.ChromiumPort.check_build(self, needs_http)
138 result = self.check_wdiff() and result
140 _log.error('For complete Mac build requirements, please see:')
142 _log.error(' http://code.google.com/p/chromium/wiki/MacBuildInstructions')
146 def default_child_processes(self):
147 if not self._multiprocessing_is_available:
148 # Running multiple threads in Mac Python is unstable (See
149 # https://bugs.webkit.org/show_bug.cgi?id=38553 for more info).
151 return chromium.ChromiumPort.default_child_processes(self)
157 def _build_path(self, *comps):
158 if self.get_option('build_directory'):
159 return self._filesystem.join(self.get_option('build_directory'),
161 base = self.path_from_chromium_base()
162 if self._filesystem.exists(self._filesystem.join(base, 'out')):
163 return self._filesystem.join(base, 'out', *comps)
164 if self._filesystem.exists(self._filesystem.join(base, 'xcodebuild', *comps)):
165 return self._filesystem.join(base, 'xcodebuild', *comps)
166 base = self.path_from_webkit_base()
167 if self._filesystem.exists(self._filesystem.join(base, 'out')):
168 return self._filesystem.join(base, 'out', *comps)
169 return self._filesystem.join(base, 'xcodebuild', *comps)
171 def check_wdiff(self, logging=True):
173 # We're ignoring the return and always returning True
174 self._executive.run_command([self._path_to_wdiff()], error_handler=Executive.ignore_error)
177 _log.warning('wdiff not found. Install using MacPorts or some other means')
180 def _lighttpd_path(self, *comps):
181 return self.path_from_chromium_base('third_party', 'lighttpd', 'mac', *comps)
183 def _path_to_apache(self):
184 return '/usr/sbin/httpd'
186 def _path_to_apache_config_file(self):
187 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'apache2-httpd.conf')
189 def _path_to_lighttpd(self):
190 return self._lighttpd_path('bin', 'lighttpd')
192 def _path_to_lighttpd_modules(self):
193 return self._lighttpd_path('lib')
195 def _path_to_lighttpd_php(self):
196 return self._lighttpd_path('bin', 'php-cgi')
198 def _path_to_driver(self, configuration=None):
199 # FIXME: make |configuration| happy with case-sensitive file systems.
200 if not configuration:
201 configuration = self.get_option('configuration')
202 return self._build_path(configuration, self.driver_name() + '.app',
203 'Contents', 'MacOS', self.driver_name())
205 def _path_to_helper(self):
206 binary_name = 'LayoutTestHelper'
207 return self._build_path(self.get_option('configuration'), binary_name)
209 def _path_to_wdiff(self):