• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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//runtime.star", "runtime")
9load("@builtin//struct.star", "module")
10load("./blink_all.star", "blink_all")
11load("./linux.star", chromium_linux = "chromium")
12load("./mac.star", chromium_mac = "chromium")
13load("./mojo.star", "mojo")
14load("./platform.star", "platform")
15load("./reproxy.star", "reproxy")
16load("./simple.star", "simple")
17load("./windows.star", chromium_windows = "chromium")
18
19def __use_large_b289968566(ctx, step_config):
20    # TODO(b/289968566): they often faile with exit=137 (OOM?).
21    # They need to run on a machine has more memory than the default machine type n2-custom-2-3840
22    exit137_list = [
23        "./android_clang_arm/obj/third_party/distributed_point_functions/distributed_point_functions/evaluate_prg_hwy.o",
24        "./ash_clang_x64/obj/chrome/browser/ash/ash/autotest_private_api.o",
25        "./ash_clang_x64/obj/chrome/browser/ash/ash/chrome_browser_main_parts_ash.o",
26        "./ash_clang_x64/obj/chrome/browser/browser/browser_prefs.o",
27        "./ash_clang_x64/obj/chrome/browser/browser/chrome_browser_interface_binders.o",
28        "./obj/chrome/browser/ash/ash/autotest_private_api.o",
29        "./obj/chrome/browser/ash/ash/chrome_browser_main_parts_ash.o",
30        "./obj/chrome/browser/ash/system_web_apps/browser_tests/system_web_app_manager_browsertest.o",
31        "./obj/chrome/browser/browser/browser_prefs.o",
32        "./obj/chrome/browser/browser/chrome_browser_interface_binders.o",
33        "./obj/chrome/browser/ui/ash/holding_space/browser_tests/holding_space_ui_browsertest.o",
34        "./obj/chrome/test/browser_tests/browser_non_client_frame_view_chromeos_browsertest.o",
35        "./obj/chrome/test/browser_tests/chrome_shelf_controller_browsertest.o",
36        "./obj/chrome/test/browser_tests/device_local_account_browsertest.o",
37        "./obj/chrome/test/browser_tests/file_manager_browsertest_base.o",
38        "./obj/chrome/test/browser_tests/remote_apps_manager_browsertest.o",
39        "./obj/chrome/test/browser_tests/spoken_feedback_browsertest.o",
40        "./obj/chrome/test/unit_tests/chrome_browsing_data_remover_delegate_unittest.o",
41        "./obj/chrome/test/unit_tests/site_settings_handler_unittest.o",
42        "./obj/content/browser/browser/browser_interface_binders.o",
43        "./obj/fuchsia_web/runners/cast_runner_integration_tests__exec/cast_runner_integration_test.o",
44        "./obj/fuchsia_web/webengine/web_engine_core/frame_impl.o",
45    ]
46    if runtime.os == "windows":
47        exit137_list = [obj.removesuffix(".o") + ".obj" for obj in exit137_list if obj.startswith("./obj/")]
48
49    new_rules = []
50    for rule in step_config["rules"]:
51        if not rule["name"].endswith("/cxx"):
52            new_rules.append(rule)
53            continue
54        if "action_outs" in rule:
55            fail("unexpeced \"action_outs\" in cxx rule %s" % rule["name"])
56        r = {}
57        r.update(rule)
58        r["name"] += "/b289968566/exit-137"
59        r["action_outs"] = exit137_list
60        r["platform_ref"] = "large"
61        new_rules.append(r)
62        new_rules.append(rule)
63    step_config["rules"] = new_rules
64    return step_config
65
66def init(ctx):
67    print("runtime: os:%s arch:%s run:%d" % (
68        runtime.os,
69        runtime.arch,
70        runtime.num_cpu,
71    ))
72    host = {
73        "linux": chromium_linux,
74        "darwin": chromium_mac,
75        "windows": chromium_windows,
76    }[runtime.os]
77    step_config = {
78        "platforms": {
79            "default": {
80                "OSFamily": "Linux",
81                "container-image": "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:912808c295e578ccde53b0685bcd0d56c15d7a03e819dcce70694bfe3fdab35e",
82                "label:action_default": "1",
83            },
84            # Large workers are usually used for Python actions like generate bindings, mojo generators etc
85            # They can run on Linux workers.
86            "large": {
87                "OSFamily": "Linux",
88                "container-image": "docker://gcr.io/chops-public-images-prod/rbe/siso-chromium/linux@sha256:912808c295e578ccde53b0685bcd0d56c15d7a03e819dcce70694bfe3fdab35e",
89                # As of Jul 2023, the action_large pool uses n2-highmem-8 with 200GB of pd-ssd.
90                # The pool is intended for the following actions.
91                #  - slow actions that can benefit from multi-cores and/or faster disk I/O. e.g. link, mojo, generate bindings etc.
92                #  - actions that fail for OOM.
93                "label:action_large": "1",
94            },
95        },
96        "input_deps": {},
97        "rules": [],
98    }
99    step_config = blink_all.step_config(ctx, step_config)
100    step_config = host.step_config(ctx, step_config)
101    step_config = mojo.step_config(ctx, step_config)
102    step_config = simple.step_config(ctx, step_config)
103    if reproxy.enabled(ctx):
104        step_config = reproxy.step_config(ctx, step_config)
105
106    #  Python actions may use an absolute path at the first argument.
107    #  e.g. C:/src/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe
108    #  It needs to set `pyhton3` or `python3.exe` to remote_command.
109    for rule in step_config["rules"]:
110        if rule["name"].startswith("clang-coverage"):
111            # clang_code_coverage_wrapper.run() strips the python wrapper.
112            # So it shouldn't set `remote_command: python3`.
113            continue
114
115        # On Linux worker, it needs to be `python3` instead of `python3.exe`.
116        arg0 = rule.get("command_prefix", "").split(" ")[0].strip("\"")
117        if arg0 != platform.python_bin:
118            continue
119        p = rule.get("reproxy_config", {}).get("platform") or step_config["platforms"].get(rule.get("platform_ref", "default"))
120        if not p:
121            continue
122        if p.get("OSFamily") == "Linux":
123            arg0 = arg0.removesuffix(".exe")
124        rule["remote_command"] = arg0
125
126    step_config = __use_large_b289968566(ctx, step_config)
127
128    filegroups = {}
129    filegroups.update(blink_all.filegroups(ctx))
130    filegroups.update(host.filegroups(ctx))
131    filegroups.update(simple.filegroups(ctx))
132
133    handlers = {}
134    handlers.update(blink_all.handlers)
135    handlers.update(host.handlers)
136    handlers.update(simple.handlers)
137    handlers.update(reproxy.handlers)
138
139    return module(
140        "config",
141        step_config = json.encode(step_config),
142        filegroups = filegroups,
143        handlers = handlers,
144    )
145