File: target_tasks.py

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (92 lines) | stat: -rw-r--r-- 2,968 bytes parent folder | download | duplicates (9)
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from taskgraph.target_tasks import register_target_task, target_tasks_default


def filter_build_type(build_types, task):
    if "o" in build_types and "opt" in task.attributes["build_type"]:
        return True
    if "d" in build_types and "debug" in task.attributes["build_type"]:
        return True


PLATFORM_ALIASES = {
    "aarch64-make": "aarch64",
    "linux": "linux32",
    "linux-fuzz": "linux32",
    "linux64-fips": "linux64",
    "linux64-fuzz": "linux64",
    "linux64-make": "linux64",
    "linux-make": "linux32",
    "win64-make": "windows2022-64",
    "win-make": "windows2022-32",
    "win64": "windows2022-64",
    "win": "windows2022-32",
    "mac": "macosx64",
}


def filter_platform(platform, task):
    if "build_platform" not in task.attributes:
        return False
    if platform == "all":
        return True
    task_platform = task.attributes["build_platform"]
    # Check the platform name.
    keep = task_platform == PLATFORM_ALIASES.get(platform, platform)
    # Additional checks.
    if platform == "linux64-fips":
        keep &= task.attributes["fips"]
    elif (
        platform == "linux64-make"
        or platform == "linux-make"
        or platform == "win64-make"
        or platform == "win-make"
        or platform == "aarch64-make"
    ):
        keep &= task.attributes["make"]
    elif platform == "linux64-fuzz" or platform == "linux-fuzz":
        keep &= task.attributes["fuzz"]
    return keep


def filter_try_syntax(options, task):
    symbol = task.task["extra"]["treeherder"]["symbol"].lower()
    group = task.task["extra"]["treeherder"].get("groupSymbol", "").lower()

    # Filter tools. We can immediately return here as those
    # are not affected by platform or build type selectors.
    if task.kind == "tools":
        return any(t in options["tools"] for t in ["all", symbol])

    # Filter unit tests.
    if task.kind == "test":
        tests = {"all", symbol}
        if group in ("cipher", "ssl"):
            tests.add(group)
        if not any(t in options["unittests"] for t in tests):
            return False

    # Filter extra builds.
    if group == "builds" and not options["extra"]:
        return False

    # Filter by platform.
    if not any(filter_platform(platform, task) for platform in options["platforms"]):
        return False

    # Finally, filter by build type.
    return filter_build_type(options["builds"], task)


@register_target_task("nss_try_tasks")
def target_tasks_try(full_task_graph, parameters, graph_config):
    if not parameters["try_options"]:
        return target_tasks_default(full_task_graph, parameters, graph_config)
    return [
        t.label
        for t in full_task_graph
        if filter_try_syntax(parameters["try_options"], t)
    ]