initial import
[vuplus_webkit] / Tools / Scripts / webkitpy / layout_tests / port / builders.py
1 #!/usr/bin/env python
2 # Copyright (C) 2011 Google Inc. All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
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
13 # distribution.
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.
17 #
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.
29
30 import re
31
32 from webkitpy.common.memoized import memoized
33
34
35 # In this dictionary, each item stores:
36 # * port_name -- a fully qualified port name
37 # * specifiers -- a set of specifiers, representing configurations covered by this builder.
38 _exact_matches = {
39     # These builders are on build.chromium.org.
40     "Webkit Win": {"port_name": "chromium-win-xp", "specifiers": set(["xp", "release", "cpu"])},
41     "Webkit Vista": {"port_name": "chromium-win-vista", "specifiers": set(["vista"])},
42     "Webkit Win7": {"port_name": "chromium-win-win7", "specifiers": set(["win7", "cpu"])},
43     "Webkit Win (dbg)(1)": {"port_name": "chromium-win-xp", "specifiers": set(["win", "debug"])},
44     "Webkit Win (dbg)(2)": {"port_name": "chromium-win-xp", "specifiers": set(["win", "debug"])},
45     "Webkit Linux": {"port_name": "chromium-linux-x86_64", "specifiers": set(["linux", "x86_64", "release"])},
46     "Webkit Linux 32": {"port_name": "chromium-linux-x86", "specifiers": set(["linux", "x86"])},
47     "Webkit Linux (dbg)(1)": {"port_name": "chromium-linux-x86_64", "specifiers": set(["linux", "debug"])},
48     "Webkit Linux (dbg)(2)": {"port_name": "chromium-linux-x86_64", "specifiers": set(["linux", "debug"])},
49     "Webkit Mac10.5": {"port_name": "chromium-mac-leopard", "specifiers": set(["leopard"])},
50     "Webkit Mac10.5 (dbg)(1)": {"port_name": "chromium-mac-leopard", "specifiers": set(["leopard", "debug"])},
51     "Webkit Mac10.5 (dbg)(2)": {"port_name": "chromium-mac-leopard", "specifiers": set(["leopard", "debug"])},
52     "Webkit Mac10.6": {"port_name": "chromium-mac-snowleopard", "specifiers": set(["snowleopard"])},
53     "Webkit Mac10.6 (dbg)": {"port_name": "chromium-mac-snowleopard", "specifiers": set(["snowleopard", "debug"])},
54     "Webkit Mac10.5 (CG)": {"port_name": "chromium-cg-mac-leopard", "specifiers": set(["leopard"])},
55     "Webkit Mac10.5 (CG)(dbg)(1)": {"port_name": "chromium-cg-mac-leopard", "specifiers": set(["leopard", "debug"])},
56     "Webkit Mac10.5 (CG)(dbg)(2)": {"port_name": "chromium-cg-mac-leopard", "specifiers": set(["leopard", "debug"])},
57     "Webkit Mac10.6 (CG)": {"port_name": "chromium-cg-mac-snowleopard", "specifiers": set(["snowleopard"])},
58     "Webkit Mac10.6 (CG)(dbg)": {"port_name": "chromium-cg-mac-snowleopard", "specifiers": set(["snowleopard", "debug"])},
59     "Webkit Win - GPU": {"port_name": "chromium-gpu-win-xp", "specifiers": set(["xp", "release", "gpu"])},
60     "Webkit Win7 - GPU": {"port_name": "chromium-gpu-win-win7", "specifiers": set(["win7", "vista", "release", "gpu"])},
61     # FIXME: For some reason, these port names don't work correctly.
62     # "Webkit Linux - GPU": {"port_name": "chromium-gpu-linux-x86_64", "specifiers": set(["linux", "gpu"])},
63     # "Webkit Linux 32 - GPU": {"port_name": "chromium-gpu-linux-x86", "specifiers": set(["linux", "x86", "gpu"])},
64     "Webkit Mac10.5 (CG) - GPU": {"port_name": "chromium-gpu-cg-mac-leopard", "specifiers": set(["leopard", "gpu"])},
65     "Webkit Mac10.6 (CG) - GPU": {"port_name": "chromium-gpu-cg-mac-snowleopard", "specifiers": set(["mac", "gpu"])},
66
67     # These builders are on build.webkit.org.
68     "GTK Linux 32-bit Debug": {"port_name": "gtk", "specifiers": set(["gtk"])},
69     "Leopard Intel Debug (Tests)": {"port_name": "mac-leopard", "specifiers": set(["leopard"])},
70     "SnowLeopard Intel Release (Tests)": {"port_name": "mac-snowleopard", "specifiers": set(["snowleopard"])},
71     "SnowLeopard Intel Release (WebKit2 Tests)": {"port_name": "mac-wk2", "specifiers": set(["wk2"])},
72     "Qt Linux Release": {"port_name": "qt-linux", "specifiers": set(["win", "linux", "mac"])},
73     "Windows XP Debug (Tests)": {"port_name": "win-xp", "specifiers": set(["win"])},
74     "Windows 7 Release (WebKit2 Tests)": {"port_name": "win-wk2", "specifiers": set(["wk2"])},
75 }
76
77
78 _fuzzy_matches = {
79     # These builders are on build.webkit.org.
80     r"SnowLeopard": "mac-snowleopard",
81     r"Leopard": "mac-leopard",
82     r"Windows": "win",
83     r"GTK": "gtk",
84     r"Qt": "qt",
85     r"Chromium Mac": "chromium-mac",
86     r"Chromium Linux": "chromium-linux",
87     r"Chromium Win": "chromium-win",
88 }
89
90
91 _ports_without_builders = [
92     # FIXME: Including chromium-gpu-linux below is a workaround for
93     # chromium-gpu-linux-x86_64 and chromium-gpu-linux-x86 not working properly.
94     "chromium-gpu-linux",
95     "google-chrome-linux32",
96     "google-chrome-linux64",
97     "qt-mac",
98     "qt-win",
99     "qt-wk2",
100 ]
101
102
103 def builder_path_from_name(builder_name):
104     return re.sub(r'[\s().]', '_', builder_name)
105
106
107 @memoized
108 def all_builder_names():
109     return sorted(set(_exact_matches.keys()))
110
111
112 @memoized
113 def all_port_names():
114     return sorted(set(map(lambda x: x["port_name"], _exact_matches.values()) + _ports_without_builders))
115
116
117 def coverage_specifiers_for_builder_name(builder_name):
118     return _exact_matches[builder_name].get("specifiers", set())
119
120
121 def port_name_for_builder_name(builder_name):
122     if builder_name in _exact_matches:
123         return _exact_matches[builder_name]["port_name"]
124
125     for regexp, port_name in _fuzzy_matches.items():
126         if re.match(regexp, builder_name):
127             return port_name
128
129
130 def builder_name_for_port_name(target_port_name):
131     for builder_name, builder_info in _exact_matches.items():
132         if builder_info['port_name'] == target_port_name and 'debug' not in builder_info['specifiers']:
133             return builder_name
134     return None
135
136
137 def builder_path_for_port_name(port_name):
138     builder_path_from_name(builder_name_for_port_name(port_name))