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