xref: /aosp_15_r20/external/angle/build/config/siso/main.star (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# -*- bazel-starlark -*-
2# Copyright 2023 The Chromium Authors
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""Siso configuration main entry."""
6
7load("@builtin//encoding.star", "json")
8load("@builtin//lib/gn.star", "gn")
9load("@builtin//runtime.star", "runtime")
10load("@builtin//struct.star", "module")
11load("./blink_all.star", "blink_all")
12load("./clang_exception.star", "clang_exception")
13load("./gn_logs.star", "gn_logs")
14load("./linux.star", chromium_linux = "chromium")
15load("./mac.star", chromium_mac = "chromium")
16load("./mojo.star", "mojo")
17load("./platform.star", "platform")
18load("./reproxy.star", "reproxy")
19load("./simple.star", "simple")
20load("./windows.star", chromium_windows = "chromium")
21
22def __disable_remote(ctx, step_config):
23    if gn.args(ctx).get("use_remoteexec") == "true":
24        return step_config
25    for rule in step_config["rules"]:
26        rule["remote"] = False
27    return step_config
28
29def init(ctx):
30    print("runtime: os:%s arch:%s run:%d" % (
31        runtime.os,
32        runtime.arch,
33        runtime.num_cpu,
34    ))
35    host = {
36        "linux": chromium_linux,
37        "darwin": chromium_mac,
38        "windows": chromium_windows,
39    }[runtime.os]
40    properties = {}
41    for k, v in gn.args(ctx).items():
42        properties["gn_args:" + k] = v
43    for k, v in gn_logs.read(ctx).items():
44        properties["gn_logs:" + k] = v
45    step_config = {
46        "properties": properties,
47        "platforms": {
48            "default": {
49                "OSFamily": "Linux",
50                "container-image": "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:912808c295e578ccde53b0685bcd0d56c15d7a03e819dcce70694bfe3fdab35e",
51                "label:action_default": "1",
52            },
53            # Large workers are usually used for Python actions like generate bindings, mojo generators etc
54            # They can run on Linux workers.
55            "large": {
56                "OSFamily": "Linux",
57                "container-image": "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:912808c295e578ccde53b0685bcd0d56c15d7a03e819dcce70694bfe3fdab35e",
58                # As of Jul 2023, the action_large pool uses n2-highmem-8 with 200GB of pd-ssd.
59                # The pool is intended for the following actions.
60                #  - slow actions that can benefit from multi-cores and/or faster disk I/O. e.g. link, mojo, generate bindings etc.
61                #  - actions that fail for OOM.
62                "label:action_large": "1",
63            },
64        },
65        "input_deps": {},
66        "rules": [],
67    }
68    step_config = blink_all.step_config(ctx, step_config)
69    step_config = host.step_config(ctx, step_config)
70    step_config = mojo.step_config(ctx, step_config)
71    step_config = simple.step_config(ctx, step_config)
72    if reproxy.enabled(ctx):
73        step_config = reproxy.step_config(ctx, step_config)
74
75    #  Python actions may use an absolute path at the first argument.
76    #  e.g. C:/src/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe
77    #  It needs to set `pyhton3` or `python3.exe` to remote_command.
78    for rule in step_config["rules"]:
79        if rule["name"].startswith("clang-coverage"):
80            # clang_code_coverage_wrapper.run() strips the python wrapper.
81            # So it shouldn't set `remote_command: python3`.
82            continue
83
84        # On Linux worker, it needs to be `python3` instead of `python3.exe`.
85        arg0 = rule.get("command_prefix", "").split(" ")[0].strip("\"")
86        if arg0 != platform.python_bin:
87            continue
88        p = rule.get("reproxy_config", {}).get("platform") or step_config["platforms"].get(rule.get("platform_ref", "default"))
89        if not p:
90            continue
91        if p.get("OSFamily") == "Linux":
92            arg0 = arg0.removesuffix(".exe")
93        rule["remote_command"] = arg0
94
95    step_config = clang_exception.step_config(ctx, step_config)
96    step_config = __disable_remote(ctx, step_config)
97
98    filegroups = {}
99    filegroups.update(blink_all.filegroups(ctx))
100    filegroups.update(host.filegroups(ctx))
101    filegroups.update(simple.filegroups(ctx))
102
103    handlers = {}
104    handlers.update(blink_all.handlers)
105    handlers.update(host.handlers)
106    handlers.update(simple.handlers)
107    handlers.update(reproxy.handlers)
108
109    return module(
110        "config",
111        step_config = json.encode(step_config),
112        filegroups = filegroups,
113        handlers = handlers,
114    )
115