blob: 08aac077fa481c7fc78830ecaf67e9ec49a1d19e [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
29"""Windows implementation of the Port interface."""
30
31import os
32import logging
33
34import chromium
35
36
37_log = logging.getLogger(__name__)
38
39
40class WinPort(chromium.ChromiumPort):
41 port_name = 'win'
42
43 # FIXME: Figure out how to unify this with base.TestConfiguration.all_systems()?
44 SUPPORTED_VERSIONS = ('xp', 'win7')
45
46 FALLBACK_PATHS = { 'win7': [ 'win' ]}
47 FALLBACK_PATHS['xp'] = ['win-xp'] + FALLBACK_PATHS['win7']
48
49 DEFAULT_BUILD_DIRECTORIES = ('build', 'out')
50
51 @classmethod
52 def determine_full_port_name(cls, host, options, port_name):
53 if port_name.endswith('win'):
54 assert host.platform.is_win()
55 # We don't maintain separate baselines for vista, so we pretend it is win7.
56 if host.platform.os_version in ('vista', '7sp0', '7sp1', 'future'):
57 version = 'win7'
58 else:
59 version = host.platform.os_version
60 port_name = port_name + '-' + version
61 return port_name
62
63 def __init__(self, host, port_name, **kwargs):
64 chromium.ChromiumPort.__init__(self, host, port_name, **kwargs)
65 self._version = port_name[port_name.index('win-') + len('win-'):]
66 assert self._version in self.SUPPORTED_VERSIONS, "%s is not in %s" % (self._version, self.SUPPORTED_VERSIONS)
67
68 def setup_environ_for_server(self, server_name=None):
69 env = chromium.ChromiumPort.setup_environ_for_server(self, server_name)
70
71 # FIXME: lighttpd depends on some environment variable we're not whitelisting.
72 # We should add the variable to an explicit whitelist in base.Port.
73 # FIXME: This is a temporary hack to get the cr-win bot online until
74 # someone from the cr-win port can take a look.
75 for key, value in os.environ.items():
76 if key not in env:
77 env[key] = value
78
79 # Put the cygwin directory first in the path to find cygwin1.dll.
80 env["PATH"] = "%s;%s" % (self.path_from_chromium_base("third_party", "cygwin", "bin"), env["PATH"])
81 # Configure the cygwin directory so that pywebsocket finds proper
82 # python executable to run cgi program.
83 env["CYGWIN_PATH"] = self.path_from_chromium_base("third_party", "cygwin", "bin")
84 if self.get_option('register_cygwin'):
85 setup_mount = self.path_from_chromium_base("third_party", "cygwin", "setup_mount.bat")
86 self._executive.run_command([setup_mount]) # Paths are all absolute, so this does not require a cwd.
87 return env
88
89 def _modules_to_search_for_symbols(self):
90 # FIXME: we should return the path to the ffmpeg equivalents to detect if we have the mp3 and aac codecs installed.
91 # See https://bugs.webkit.org/show_bug.cgi?id=89706.
92 return []
93
94 def check_build(self, needs_http):
95 result = chromium.ChromiumPort.check_build(self, needs_http)
96 if not result:
97 _log.error('For complete Windows build requirements, please see:')
98 _log.error('')
99 _log.error(' http://dev.chromium.org/developers/how-tos/build-instructions-windows')
100 return result
101
102 def operating_system(self):
103 return 'win'
104
105 def relative_test_filename(self, filename):
106 path = filename[len(self.layout_tests_dir()) + 1:]
107 return path.replace('\\', '/')
108
109 #
110 # PROTECTED ROUTINES
111 #
112
113 def _uses_apache(self):
114 return False
115
116 def _lighttpd_path(self, *comps):
117 return self.path_from_chromium_base('third_party', 'lighttpd', 'win', *comps)
118
119 def _path_to_apache(self):
120 return self.path_from_chromium_base('third_party', 'cygwin', 'usr', 'sbin', 'httpd')
121
122 def _path_to_apache_config_file(self):
123 return self._filesystem.join(self.layout_tests_dir(), 'http', 'conf', 'cygwin-httpd.conf')
124
125 def _path_to_lighttpd(self):
126 return self._lighttpd_path('LightTPD.exe')
127
128 def _path_to_lighttpd_modules(self):
129 return self._lighttpd_path('lib')
130
131 def _path_to_lighttpd_php(self):
132 return self._lighttpd_path('php5', 'php-cgi.exe')
133
134 def _path_to_driver(self, configuration=None):
135 binary_name = '%s.exe' % self.driver_name()
136 return self._build_path_with_configuration(configuration, binary_name)
137
138 def _path_to_helper(self):
139 binary_name = 'LayoutTestHelper.exe'
140 return self._build_path(binary_name)
141
142 def _path_to_image_diff(self):
Torne (Richard Coles)f5e4ad52013-08-05 13:57:57 +0100143 binary_name = 'image_diff.exe'
Ben Murdoch591b9582013-07-10 11:41:44 +0100144 return self._build_path(binary_name)
145
146 def _path_to_wdiff(self):
147 return self.path_from_chromium_base('third_party', 'cygwin', 'bin', 'wdiff.exe')