blob: d1a947d5bfbcfd89d2a38bff6826ba6a1d334db4 [file] [log] [blame]
Ben Murdoch591b9582013-07-10 11:41:44 +01001# Copyright (C) 2010 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
29import logging
30import re
31
32from webkitpy.common.webkit_finder import WebKitFinder
33from webkitpy.layout_tests.port import chromium
34from webkitpy.layout_tests.port import win
35from webkitpy.layout_tests.port import config
36
37
38_log = logging.getLogger(__name__)
39
40
41class LinuxPort(chromium.ChromiumPort):
42 port_name = 'linux'
43
44 SUPPORTED_VERSIONS = ('x86', 'x86_64')
45
46 FALLBACK_PATHS = { 'x86_64': [ 'linux' ] + win.WinPort.latest_platform_fallback_path() }
47 FALLBACK_PATHS['x86'] = ['linux-x86'] + FALLBACK_PATHS['x86_64']
48
49 DEFAULT_BUILD_DIRECTORIES = ('sconsbuild', 'out')
50
51 @classmethod
52 def _determine_driver_path_statically(cls, host, options):
53 config_object = config.Config(host.executive, host.filesystem)
54 build_directory = getattr(options, 'build_directory', None)
55 webkit_base = WebKitFinder(host.filesystem).webkit_base()
56 chromium_base = cls._chromium_base_dir(host.filesystem)
57 driver_name = getattr(options, 'driver_name', None)
58 if driver_name is None:
59 driver_name = cls.CONTENT_SHELL_NAME
60 if hasattr(options, 'configuration') and options.configuration:
61 configuration = options.configuration
62 else:
63 configuration = config_object.default_configuration()
64 return cls._static_build_path(host.filesystem, build_directory, chromium_base, webkit_base, configuration, [driver_name])
65
66 @staticmethod
67 def _determine_architecture(filesystem, executive, driver_path):
68 file_output = ''
69 if filesystem.exists(driver_path):
70 # The --dereference flag tells file to follow symlinks
71 file_output = executive.run_command(['file', '--brief', '--dereference', driver_path], return_stderr=True)
72
73 if re.match(r'ELF 32-bit LSB\s+executable', file_output):
74 return 'x86'
75 if re.match(r'ELF 64-bit LSB\s+executable', file_output):
76 return 'x86_64'
77 if file_output:
78 _log.warning('Could not determine architecture from "file" output: %s' % file_output)
79
80 # We don't know what the architecture is; default to 'x86' because
81 # maybe we're rebaselining and the binary doesn't actually exist,
82 # or something else weird is going on. It's okay to do this because
83 # if we actually try to use the binary, check_build() should fail.
84 return 'x86_64'
85
86 @classmethod
87 def determine_full_port_name(cls, host, options, port_name):
88 if port_name.endswith('linux'):
89 return port_name + '-' + cls._determine_architecture(host.filesystem, host.executive, cls._determine_driver_path_statically(host, options))
90 return port_name
91
92 def __init__(self, host, port_name, **kwargs):
93 chromium.ChromiumPort.__init__(self, host, port_name, **kwargs)
94 (base, arch) = port_name.rsplit('-', 1)
95 assert base == 'linux'
96 assert arch in self.SUPPORTED_VERSIONS
97 assert port_name in ('linux', 'linux-x86', 'linux-x86_64')
98 self._version = 'lucid' # We only support lucid right now.
99 self._architecture = arch
100
101 def additional_drt_flag(self):
102 flags = super(LinuxPort, self).additional_drt_flag()
103 # FIXME: Temporarily disable the sandbox on Linux until we can get
104 # stacktraces via breakpad. http://crbug.com/247431
105 flags += ['--no-sandbox']
106 return flags
107
108 def default_baseline_search_path(self):
109 port_names = self.FALLBACK_PATHS[self._architecture]
110 return map(self._webkit_baseline_path, port_names)
111
112 def _modules_to_search_for_symbols(self):
113 return [self._build_path('libffmpegsumo.so')]
114
115 def check_build(self, needs_http):
116 result = chromium.ChromiumPort.check_build(self, needs_http)
117 if not result:
118 _log.error('For complete Linux build requirements, please see:')
119 _log.error('')
120 _log.error(' http://code.google.com/p/chromium/wiki/LinuxBuildInstructions')
121 return result
122
123 def operating_system(self):
124 return 'linux'
125
126 #
127 # PROTECTED METHODS
128 #
129
130 def _check_apache_install(self):
131 result = self._check_file_exists(self._path_to_apache(), "apache2")
132 result = self._check_file_exists(self._path_to_apache_config_file(), "apache2 config file") and result
133 if not result:
134 _log.error(' Please install using: "sudo apt-get install apache2 libapache2-mod-php5"')
135 _log.error('')
136 return result
137
138 def _check_lighttpd_install(self):
139 result = self._check_file_exists(
140 self._path_to_lighttpd(), "LigHTTPd executable")
141 result = self._check_file_exists(self._path_to_lighttpd_php(), "PHP CGI executable") and result
142 result = self._check_file_exists(self._path_to_lighttpd_modules(), "LigHTTPd modules") and result
143 if not result:
144 _log.error(' Please install using: "sudo apt-get install lighttpd php5-cgi"')
145 _log.error('')
146 return result
147
148 def _wdiff_missing_message(self):
149 return 'wdiff is not installed; please install using "sudo apt-get install wdiff"'
150
151 def _path_to_apache(self):
152 # The Apache binary path can vary depending on OS and distribution
153 # See http://wiki.apache.org/httpd/DistrosDefaultLayout
154 for path in ["/usr/sbin/httpd", "/usr/sbin/apache2"]:
155 if self._filesystem.exists(path):
156 return path
157 _log.error("Could not find apache. Not installed or unknown path.")
158 return None
159
160 def _path_to_lighttpd(self):
161 return "/usr/sbin/lighttpd"
162
163 def _path_to_lighttpd_modules(self):
164 return "/usr/lib/lighttpd"
165
166 def _path_to_lighttpd_php(self):
167 return "/usr/bin/php-cgi"
168
169 def _path_to_driver(self, configuration=None):
170 binary_name = self.driver_name()
171 return self._build_path_with_configuration(configuration, binary_name)
172
173 def _path_to_helper(self):
174 return None