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-leopard", "mac-lion", "mac-snowleopard", "win"))
43 # Directories that shouldn't trigger builds on any bots.
45 ("PerformanceTests", []),
46 ("Source/WebCore/manual-tests", []),
47 ("Tools/BuildSlaveSupport/build.webkit.org-config/public_html", []),
59 # Directories that should trigger builds on only some bots.
60 ("Source/JavaScriptGlue", ["mac"]),
61 ("Source/WebCore/image-decoders", ["chromium"]),
62 ("LayoutTests/platform/mac", ["mac", "win"]),
63 ("cairo", ["gtk", "wincairo"]),
64 ("cf", ["chromium-mac", "chromium-cg-mac", "mac", "qt", "win"]),
65 ("chromium", ["chromium"]),
66 ("cocoa", ["chromium-mac", "chromium-cg-mac", "mac"]),
67 ("curl", ["gtk", "wincairo"]),
69 ("gpu", ["chromium", "mac"]),
70 ("gstreamer", ["gtk"]),
72 ("mac", ["chromium-mac", "chromium-cg-mac", "mac"]),
73 ("mac-leopard", ["mac-leopard"]),
74 ("mac-lion", ["mac", "win"]),
75 ("mac-snowleopard", ["mac-leopard", "mac-snowleopard"]),
76 ("mac-wk2", ["mac-lion", "mac-snowleopard", "win"]),
79 ("skia", ["chromium"]),
82 ("win", ["chromium-win", "win"]),
85 # Patterns that shouldn't trigger builds on any bots.
86 (r"(?:^|/)ChangeLog.*$", []),
87 (r"(?:^|/)Makefile$", []),
90 (r"/LICENSE[^/]+$", []),
91 (r"ARM(?:v7)?\.(?:cpp|h)$", []),
92 (r"MIPS\.(?:cpp|h)$", []),
93 (r"WinCE\.(?:cpp|h|mm)$", []),
94 (r"\.(?:bkl|mk)$", []),
96 # Patterns that should trigger builds on only some bots.
97 (r"(?:^|/)GNUmakefile\.am$", ["gtk"]),
98 (r"/\w+Chromium\w*\.(?:cpp|h|mm)$", ["chromium"]),
99 (r"Mac\.(?:cpp|h|mm)$", ["mac"]),
100 (r"\.(?:vcproj|vsprops|sln)$", ["win"]),
101 (r"\.exp(?:\.in)?$", ["mac"]),
102 (r"\.gypi?", ["chromium"]),
103 (r"\.order$", ["mac"]),
104 (r"\.pr[io]$", ["qt"]),
105 (r"\.vcproj/", ["win"]),
106 (r"\.xcconfig$", ["mac"]),
107 (r"\.xcodeproj/", ["mac"]),
110 base_platform = target_platform.split("-")[0]
112 # See if the file is in one of the known directories.
113 for directory, platforms in directories:
114 if re.search(r"(?:^|/)%s/" % directory, file):
115 return target_platform in platforms or base_platform in platforms
117 # See if the file matches a known pattern.
118 for pattern, platforms in patterns:
119 if re.search(pattern, file):
120 return target_platform in platforms or base_platform in platforms
122 # See if the file is a platform-specific test result.
123 match = re.match("LayoutTests/platform/(?P<platform>[^/]+)/", file)
125 # See if the file is a test result for this platform, our base
126 # platform, or one of our sub-platforms.
127 return match.group("platform") in (target_platform, base_platform) or match.group("platform").startswith("%s-" % target_platform)
129 # The file isn't one we know about specifically, so we should assume we
134 def should_build(target_platform, changed_files):
135 """Returns true if the changed files affect the given platform, and
136 thus a build should be performed. target_platform should be one of the
137 platforms used in the build.webkit.org master's config.json file."""
138 return any(_should_file_trigger_build(target_platform, file) for file in changed_files)