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 Linux implementation of the Port interface."""
37 _log = logging.getLogger(__name__)
40 class ChromiumLinuxPort(chromium.ChromiumPort):
41 SUPPORTED_ARCHITECTURES = ('x86', 'x86_64')
61 def __init__(self, port_name=None, **kwargs):
62 port_name = port_name or 'chromium-linux'
63 chromium.ChromiumPort.__init__(self, port_name=port_name, **kwargs)
64 # We re-set the port name once the base object is fully initialized
65 # in order to be able to find the DRT binary properly.
66 if port_name.endswith('-linux'):
67 self._architecture = self._determine_architecture()
68 # FIXME: This is an ugly hack to avoid renaming the GPU port.
69 if port_name == 'chromium-linux':
70 port_name = port_name + '-' + self._architecture
72 base, arch = port_name.rsplit('-', 1)
73 assert base in ('chromium-linux', 'chromium-gpu-linux')
74 self._architecture = arch
75 assert self._architecture in self.SUPPORTED_ARCHITECTURES
76 assert port_name in ('chromium-linux', 'chromium-gpu-linux',
77 'chromium-linux-x86', 'chromium-linux-x86_64',
78 'chromium-gpu-linux-x86_64')
79 self._name = port_name
80 self._operating_system = 'linux'
81 self._version = 'lucid' # We only support lucid right now.
83 def _determine_architecture(self):
84 driver_path = self._path_to_driver()
86 if self._filesystem.exists(driver_path):
87 # The --dereference flag tells file to follow symlinks
88 file_output = self._executive.run_command(['file', '--dereference', driver_path], return_stderr=True)
90 if 'ELF 32-bit LSB executable' in file_output:
92 if 'ELF 64-bit LSB executable' in file_output:
95 _log.warning('Could not determine architecture from "file" output: %s' % file_output)
97 # We don't know what the architecture is; default to 'x86' because
98 # maybe we're rebaselining and the binary doesn't actually exist,
99 # or something else weird is going on. It's okay to do this because
100 # if we actually try to use the binary, check_build() should fail.
103 def baseline_search_path(self):
104 port_names = self.FALLBACK_PATHS[self._architecture]
105 return map(self._webkit_baseline_path, port_names)
107 def check_build(self, needs_http):
108 result = chromium.ChromiumPort.check_build(self, needs_http)
109 result = self.check_wdiff() and result
112 _log.error('For complete Linux build requirements, please see:')
114 _log.error(' http://code.google.com/p/chromium/wiki/LinuxBuildInstructions')
121 def _build_path(self, *comps):
122 if self.get_option('build_directory'):
123 return self._filesystem.join(self.get_option('build_directory'), *comps)
125 base = self.path_from_chromium_base()
126 if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
127 return self._filesystem.join(base, 'sconsbuild', *comps)
128 if self._filesystem.exists(self._filesystem.join(base, 'out', *comps)):
129 return self._filesystem.join(base, 'out', *comps)
130 base = self.path_from_webkit_base()
131 if self._filesystem.exists(self._filesystem.join(base, 'sconsbuild')):
132 return self._filesystem.join(base, 'sconsbuild', *comps)
133 return self._filesystem.join(base, 'out', *comps)
135 def _check_apache_install(self):
136 result = self._check_file_exists(self._path_to_apache(), "apache2")
137 result = self._check_file_exists(self._path_to_apache_config_file(), "apache2 config file") and result
139 _log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"')
143 def _check_lighttpd_install(self):
144 result = self._check_file_exists(
145 self._path_to_lighttpd(), "LigHTTPd executable")
146 result = self._check_file_exists(self._path_to_lighttpd_php(), "PHP CGI executable") and result
147 result = self._check_file_exists(self._path_to_lighttpd_modules(), "LigHTTPd modules") and result
149 _log.error(' Please install using: "sudo apt-get install lighttpd php5-cgi"')
153 def check_wdiff(self, logging=True):
154 result = self._check_file_exists(self._path_to_wdiff(), 'wdiff')
155 if not result and logging:
156 _log.error(' Please install using: "sudo apt-get install wdiff"')
158 # FIXME: The ChromiumMac port always returns True.
161 def _path_to_apache(self):
162 if self._is_redhat_based():
163 return '/usr/sbin/httpd'
165 return '/usr/sbin/apache2'
167 def _path_to_apache_config_file(self):
168 if self._is_redhat_based():
169 config_name = 'fedora-httpd.conf'
171 config_name = 'apache2-debian-httpd.conf'
173 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', config_name)
175 def _path_to_lighttpd(self):
176 return "/usr/sbin/lighttpd"
178 def _path_to_lighttpd_modules(self):
179 return "/usr/lib/lighttpd"
181 def _path_to_lighttpd_php(self):
182 return "/usr/bin/php-cgi"
184 def _path_to_driver(self, configuration=None):
185 if not configuration:
186 configuration = self.get_option('configuration')
187 binary_name = 'DumpRenderTree'
188 return self._build_path(configuration, binary_name)
190 def _path_to_helper(self):
193 def _path_to_wdiff(self):
194 if self._is_redhat_based():
195 return '/usr/bin/dwdiff'
197 return '/usr/bin/wdiff'
199 def _is_redhat_based(self):
200 return self._filesystem.exists(self._filesystem.join('/etc', 'redhat-release'))