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 for clang-cl/windows.""" 6 7load("@builtin//lib/gn.star", "gn") 8load("@builtin//path.star", "path") 9load("@builtin//struct.star", "module") 10load("./clang_all.star", "clang_all") 11load("./clang_code_coverage_wrapper.star", "clang_code_coverage_wrapper") 12load("./config.star", "config") 13load("./gn_logs.star", "gn_logs") 14load("./reproxy.star", "reproxy") 15load("./rewrapper_cfg.star", "rewrapper_cfg") 16load("./win_sdk.star", "win_sdk") 17 18def __filegroups(ctx): 19 fg = {} 20 fg.update(win_sdk.filegroups(ctx)) 21 fg.update(clang_all.filegroups(ctx)) 22 return fg 23 24def __clang_compile_coverage(ctx, cmd): 25 clang_command = clang_code_coverage_wrapper.run(ctx, list(cmd.args)) 26 ctx.actions.fix(args = clang_command) 27 28__handlers = { 29 "clang_compile_coverage": __clang_compile_coverage, 30} 31 32def __step_config(ctx, step_config): 33 cfg = "buildtools/reclient_cfgs/chromium-browser-clang/rewrapper_windows.cfg" 34 if ctx.fs.exists(cfg): 35 reproxy_config = rewrapper_cfg.parse(ctx, cfg) 36 largePlatform = {} 37 for k, v in reproxy_config["platform"].items(): 38 if k.startswith("label:action"): 39 continue 40 largePlatform[k] = v 41 42 # no "action_large" Windows worker pool 43 windowsWorker = True 44 if reproxy_config["platform"]["OSFamily"] != "Windows": 45 largePlatform["label:action_large"] = "1" 46 windowsWorker = False 47 step_config["platforms"].update({ 48 "clang-cl": reproxy_config["platform"], 49 "clang-cl_large": largePlatform, 50 }) 51 step_config["input_deps"].update(clang_all.input_deps) 52 53 # when win_toolchain_dir is unknown (e.g. 54 # missing build/win_toolchain.json), we can't run 55 # clang-cl remotely as we can find sysroot files 56 # under exec_root, so just run locally. 57 # When building with ToT Clang, we can't run clang-cl 58 # remotely, too. 59 remote = False 60 win_toolchain_dir = win_sdk.toolchain_dir(ctx) 61 if win_toolchain_dir: 62 remote = True 63 if reproxy_config["platform"]["OSFamily"] == "Windows": 64 step_config["input_deps"].update({ 65 win_toolchain_dir + ":headers": [ 66 win_toolchain_dir + ":headers-ci", 67 ], 68 }) 69 else: 70 win_sdk.step_config(ctx, step_config) 71 remote_wrapper = reproxy_config.get("remote_wrapper") 72 input_root_absolute_path = gn_logs.read(ctx).get("clang_need_input_root_absolute_path") == "true" 73 canonicalize_dir = not input_root_absolute_path 74 75 timeout = "2m" 76 if (not reproxy.enabled(ctx)) and windowsWorker: 77 # use longer timeout for siso native 78 # it takes long time for input fetch (many files in sysroot etc) 79 timeout = "4m" 80 81 step_config["rules"].extend([ 82 { 83 "name": "clang-cl/cxx", 84 "action": "(.*_)?cxx", 85 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\clang-cl.exe", 86 "inputs": [ 87 "third_party/llvm-build/Release+Asserts/bin/clang-cl.exe", 88 ], 89 "exclude_input_patterns": ["*.stamp"], 90 "platform_ref": "clang-cl", 91 "remote": remote, 92 "input_root_absolute_path": input_root_absolute_path, 93 "canonicalize_dir": canonicalize_dir, 94 "remote_wrapper": remote_wrapper, 95 "timeout": timeout, 96 }, 97 { 98 "name": "clang-cl/cc", 99 "action": "(.*_)?cc", 100 "command_prefix": "..\\..\\third_party\\llvm-build\\Release+Asserts\\bin\\clang-cl.exe", 101 "inputs": [ 102 "third_party/llvm-build/Release+Asserts/bin/clang-cl.exe", 103 ], 104 "exclude_input_patterns": ["*.stamp"], 105 "platform_ref": "clang-cl", 106 "remote": remote, 107 "input_root_absolute_path": input_root_absolute_path, 108 "canonicalize_dir": canonicalize_dir, 109 "remote_wrapper": remote_wrapper, 110 "timeout": timeout, 111 }, 112 { 113 "name": "clang-coverage/cxx", 114 "action": "(.*_)?cxx", 115 "command_prefix": "python3.exe ../../build/toolchain/clang_code_coverage_wrapper.py", 116 "inputs": [ 117 "third_party/llvm-build/Release+Asserts/bin/clang++", 118 ], 119 "exclude_input_patterns": ["*.stamp"], 120 "handler": "clang_compile_coverage", 121 "platform_ref": "clang-cl", 122 "remote": remote, 123 "input_root_absolute_path": input_root_absolute_path, 124 "canonicalize_dir": canonicalize_dir, 125 "remote_wrapper": remote_wrapper, 126 "timeout": timeout, 127 }, 128 { 129 "name": "clang-coverage/cc", 130 "action": "(.*_)?cc", 131 "command_prefix": "python3.exe ../../build/toolchain/clang_code_coverage_wrapper.py", 132 "inputs": [ 133 "third_party/llvm-build/Release+Asserts/bin/clang", 134 ], 135 "exclude_input_patterns": ["*.stamp"], 136 "handler": "clang_compile_coverage", 137 "platform_ref": "clang-cl", 138 "remote": remote, 139 "input_root_absolute_path": input_root_absolute_path, 140 "canonicalize_dir": canonicalize_dir, 141 "remote_wrapper": remote_wrapper, 142 "timeout": timeout, 143 }, 144 ]) 145 elif gn.args(ctx).get("use_remoteexec") == "true": 146 fail("remoteexec requires rewrapper config") 147 return step_config 148 149clang = module( 150 "clang", 151 step_config = __step_config, 152 filegroups = __filegroups, 153 handlers = __handlers, 154) 155