1 # Copyright (C) 2010 Apple Inc. All rights reserved.
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 # 2. Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
12 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
13 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15 # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
16 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 """Functions relating to building WebKit"""
28 def _should_file_trigger_build(target_platform, file):
29 # The directories and patterns lists below map directory names or
30 # regexp patterns to the bot platforms for which they should trigger a
31 # build. Mapping to the empty list means that no builds should be
32 # triggered on any platforms. Earlier directories/patterns take
33 # precendence over later ones.
35 # FIXME: The patterns below have only been verified to be correct on
36 # the platforms listed below. We should implement this for other platforms
37 # and start using it for their bots. Someone familiar with each platform
38 # will have to figure out what the right set of directories/patterns is for
40 assert(target_platform in ("mac-mavericks", "mac-yosemite", "win"))
43 # Directories that shouldn't trigger builds on any bots.
45 ("PerformanceTests", []),
47 ("Tools/BuildSlaveSupport/build.webkit.org-config/public_html", []),
56 # Directories that should trigger builds on only some bots.
57 ("LayoutTests/platform/mac", ["mac", "win"]),
58 ("cairo", ["gtk", "wincairo"]),
59 ("cf", ["mac", "qt", "win"]),
61 ("curl", ["gtk", "wincairo"]),
64 ("gstreamer", ["gtk"]),
67 ("mac-leopard", ["mac-leopard"]),
68 ("mac-lion", ["mac-leopard", "mac-lion", "mac-snowleopard", "win"]),
69 ("mac-mountainlion", ["mac-leopard", "mac-lion", "mac-mountainlion", "mac-snowleopard", "win"]),
70 ("mac-snowleopard", ["mac-leopard", "mac-snowleopard"]),
71 ("mac-wk2", ["mac-lion", "mac-snowleopard", "mac-mavericks", "mac-mountainlion", "win"]),
78 # Patterns that shouldn't trigger builds on any bots.
79 (r"(?:^|/)ChangeLog.*$", []),
80 (r"(?:^|/)Makefile$", []),
83 (r"/LICENSE[^/]+$", []),
84 (r"ARM(?:v7)?\.(?:cpp|h)$", []),
85 (r"MIPS\.(?:cpp|h)$", []),
86 (r"\.(?:bkl|mk)$", []),
88 # Patterns that should trigger builds on only some bots.
89 (r"(?:^|/)PlatformGTK\.cmake$", ["gtk"]),
90 (r"Mac\.(?:cpp|h|mm)$", ["mac"]),
91 (r"\.(?:vcproj|vsprops|sln|vcxproj|props|filters)$", ["win"]),
92 (r"\.exp(?:\.in)?$", ["mac"]),
93 (r"\.order$", ["mac"]),
94 (r"\.pr[io]$", ["qt"]),
95 (r"\.(?:vcproj|vcxproj)/", ["win"]),
96 (r"\.xcconfig$", ["mac"]),
97 (r"\.xcodeproj/", ["mac"]),
100 base_platform = target_platform.split("-")[0]
102 # See if the file is in one of the known directories.
103 for directory, platforms in directories:
104 if re.search(r"(?:^|/)%s/" % directory, file):
105 return target_platform in platforms or base_platform in platforms
107 # See if the file matches a known pattern.
108 for pattern, platforms in patterns:
109 if re.search(pattern, file):
110 return target_platform in platforms or base_platform in platforms
112 # See if the file is a platform-specific test result.
113 match = re.match("LayoutTests/platform/(?P<platform>[^/]+)/", file)
115 # See if the file is a test result for this platform, our base
116 # platform, or one of our sub-platforms.
117 return match.group("platform") in (target_platform, base_platform) or match.group("platform").startswith("%s-" % target_platform)
119 # The file isn't one we know about specifically, so we should assume we
124 def should_build(target_platform, changed_files):
125 """Returns true if the changed files affect the given platform, and
126 thus a build should be performed. target_platform should be one of the
127 platforms used in the build.webkit.org master's config.json file."""
128 return any(_should_file_trigger_build(target_platform, file) for file in changed_files)