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("./backend_config/backend.star", "backend") 12load("./blink_all.star", "blink_all") 13load("./clang_exception.star", "clang_exception") 14load("./gn_logs.star", "gn_logs") 15load("./linux.star", chromium_linux = "chromium") 16load("./mac.star", chromium_mac = "chromium") 17load("./mojo.star", "mojo") 18load("./platform.star", "platform") 19load("./reproxy.star", "reproxy") 20load("./rust.star", "rust") 21load("./simple.star", "simple") 22load("./windows.star", chromium_windows = "chromium") 23 24def __disable_remote(ctx, step_config): 25 if gn.args(ctx).get("use_remoteexec") == "true": 26 return step_config 27 for rule in step_config["rules"]: 28 rule["remote"] = False 29 return step_config 30 31def init(ctx): 32 print("runtime: os:%s arch:%s run:%d" % ( 33 runtime.os, 34 runtime.arch, 35 runtime.num_cpu, 36 )) 37 host = { 38 "linux": chromium_linux, 39 "darwin": chromium_mac, 40 "windows": chromium_windows, 41 }[runtime.os] 42 properties = {} 43 for k, v in gn.args(ctx).items(): 44 properties["gn_args:" + k] = v 45 for k, v in gn_logs.read(ctx).items(): 46 properties["gn_logs:" + k] = v 47 48 step_config = { 49 "properties": properties, 50 "platforms": backend.platform_properties(ctx), 51 "input_deps": {}, 52 "rules": [], 53 } 54 step_config = blink_all.step_config(ctx, step_config) 55 step_config = host.step_config(ctx, step_config) 56 step_config = mojo.step_config(ctx, step_config) 57 step_config = rust.step_config(ctx, step_config) 58 step_config = simple.step_config(ctx, step_config) 59 if reproxy.enabled(ctx): 60 step_config = reproxy.step_config(ctx, step_config) 61 62 # Python actions may use an absolute path at the first argument. 63 # e.g. C:/src/depot_tools/bootstrap-2@3_8_10_chromium_26_bin/python3/bin/python3.exe 64 # It needs to set `pyhton3` or `python3.exe` to remote_command. 65 for rule in step_config["rules"]: 66 if rule["name"].startswith("clang-coverage"): 67 # clang_code_coverage_wrapper.run() strips the python wrapper. 68 # So it shouldn't set `remote_command: python3`. 69 continue 70 71 # On Linux worker, it needs to be `python3` instead of `python3.exe`. 72 arg0 = rule.get("command_prefix", "").split(" ")[0].strip("\"") 73 if arg0 != platform.python_bin: 74 continue 75 p = rule.get("reproxy_config", {}).get("platform") or step_config["platforms"].get(rule.get("platform_ref", "default")) 76 if not p: 77 continue 78 if p.get("OSFamily") == "Linux": 79 arg0 = arg0.removesuffix(".exe") 80 rule["remote_command"] = arg0 81 82 step_config = clang_exception.step_config(ctx, step_config) 83 step_config = __disable_remote(ctx, step_config) 84 85 filegroups = {} 86 filegroups.update(blink_all.filegroups(ctx)) 87 filegroups.update(host.filegroups(ctx)) 88 filegroups.update(rust.filegroups(ctx)) 89 filegroups.update(simple.filegroups(ctx)) 90 91 handlers = {} 92 handlers.update(blink_all.handlers) 93 handlers.update(host.handlers) 94 handlers.update(rust.handlers) 95 handlers.update(simple.handlers) 96 handlers.update(reproxy.handlers) 97 98 return module( 99 "config", 100 step_config = json.encode(step_config), 101 filegroups = filegroups, 102 handlers = handlers, 103 ) 104