summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/common/config/build.py
blob: 355fa968b9b55eeedbab7a9aae8c8cbd7145eda6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# Copyright (C) 2010 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

"""Functions relating to building WebKit"""

import re


def _should_file_trigger_build(target_platform, file):
    # The directories and patterns lists below map directory names or
    # regexp patterns to the bot platforms for which they should trigger a
    # build. Mapping to the empty list means that no builds should be
    # triggered on any platforms. Earlier directories/patterns take
    # precendence over later ones.

    # FIXME: The patterns below have only been verified to be correct on
    # Windows. We should implement this for other platforms and start using
    # it for their bots. Someone familiar with each platform will have to
    # figure out what the right set of directories/patterns is for that
    # platform.
    assert(target_platform == "win")

    directories = [
        # Directories that shouldn't trigger builds on any bots.
        ("PerformanceTests", []),
        ("Source/WebCore/manual-tests", []),
        ("Examples", []),
        ("Websites", []),
        ("android", []),
        ("brew", []),
        ("efl", []),
        ("haiku", []),
        ("iphone", []),
        ("opengl", []),
        ("opentype", []),
        ("openvg", []),
        ("wx", []),
        ("wince", []),

        # Directories that should trigger builds on only some bots.
        ("Source/JavaScriptGlue", ["mac"]),
        ("LayoutTests/platform/mac", ["mac", "win"]),
        ("LayoutTests/platform/mac-snowleopard", ["mac-snowleopard", "win"]),
        ("Source/WebCore/image-decoders", ["chromium"]),
        ("cairo", ["gtk", "wincairo"]),
        ("cf", ["chromium-mac", "mac", "qt", "win"]),
        ("chromium", ["chromium"]),
        ("cocoa", ["chromium-mac", "mac"]),
        ("curl", ["gtk", "wincairo"]),
        ("gobject", ["gtk"]),
        ("gpu", ["chromium", "mac"]),
        ("gstreamer", ["gtk"]),
        ("gtk", ["gtk"]),
        ("mac", ["chromium-mac", "mac"]),
        ("mac-leopard", ["mac-leopard"]),
        ("mac-snowleopard", ["mac-snowleopard"]),
        ("mac-wk2", ["mac-snowleopard", "win"]),
        ("objc", ["mac"]),
        ("qt", ["qt"]),
        ("skia", ["chromium"]),
        ("soup", ["gtk"]),
        ("v8", ["chromium"]),
        ("win", ["chromium-win", "win"]),
    ]
    patterns = [
        # Patterns that shouldn't trigger builds on any bots.
        (r"(?:^|/)ChangeLog.*$", []),
        (r"(?:^|/)Makefile$", []),
        (r"/ARM", []),
        (r"/CMake.*", []),
        (r"/LICENSE[^/]+$", []),
        (r"ARM(?:v7)?\.(?:cpp|h)$", []),
        (r"MIPS\.(?:cpp|h)$", []),
        (r"WinCE\.(?:cpp|h|mm)$", []),
        (r"\.(?:bkl|mk)$", []),

        # Patterns that should trigger builds on only some bots.
        (r"(?:^|/)GNUmakefile\.am$", ["gtk"]),
        (r"/\w+Chromium\w*\.(?:cpp|h|mm)$", ["chromium"]),
        (r"Mac\.(?:cpp|h|mm)$", ["mac"]),
        (r"\.exp(?:\.in)?$", ["mac"]),
        (r"\.gypi?", ["chromium"]),
        (r"\.order$", ["mac"]),
        (r"\.pr[io]$", ["qt"]),
        (r"\.xcconfig$", ["mac"]),
        (r"\.xcodeproj/", ["mac"]),
    ]

    base_platform = target_platform.split("-")[0]

    # See if the file is in one of the known directories.
    for directory, platforms in directories:
        if re.search(r"(?:^|/)%s/" % directory, file):
            return target_platform in platforms or base_platform in platforms

    # See if the file matches a known pattern.
    for pattern, platforms in patterns:
        if re.search(pattern, file):
            return target_platform in platforms or base_platform in platforms

    # See if the file is a platform-specific test result.
    match = re.match("LayoutTests/platform/(?P<platform>[^/]+)/", file)
    if match:
        # See if the file is a test result for this platform, our base
        # platform, or one of our sub-platforms.
        return match.group("platform") in (target_platform, base_platform) or match.group("platform").startswith("%s-" % target_platform)

    # The file isn't one we know about specifically, so we should assume we
    # have to build.
    return True


def should_build(target_platform, changed_files):
    """Returns true if the changed files affect the given platform, and
    thus a build should be performed. target_platform should be one of the
    platforms used in the build.webkit.org master's config.json file."""
    return any(_should_file_trigger_build(target_platform, file) for file in changed_files)