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