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 for clang/mac.""" 6*8975f5c5SAndroid Build Coastguard Worker 7*8975f5c5SAndroid Build Coastguard Workerload("@builtin//lib/gn.star", "gn") 8*8975f5c5SAndroid Build Coastguard Workerload("@builtin//path.star", "path") 9*8975f5c5SAndroid Build Coastguard Workerload("@builtin//struct.star", "module") 10*8975f5c5SAndroid Build Coastguard Workerload("./clang_all.star", "clang_all") 11*8975f5c5SAndroid Build Coastguard Workerload("./clang_code_coverage_wrapper.star", "clang_code_coverage_wrapper") 12*8975f5c5SAndroid Build Coastguard Workerload("./config.star", "config") 13*8975f5c5SAndroid Build Coastguard Workerload("./gn_logs.star", "gn_logs") 14*8975f5c5SAndroid Build Coastguard Workerload("./mac_sdk.star", "mac_sdk") 15*8975f5c5SAndroid Build Coastguard Workerload("./rewrapper_cfg.star", "rewrapper_cfg") 16*8975f5c5SAndroid Build Coastguard Worker 17*8975f5c5SAndroid Build Coastguard Workerdef __filegroups(ctx): 18*8975f5c5SAndroid Build Coastguard Worker fg = {} 19*8975f5c5SAndroid Build Coastguard Worker fg.update(mac_sdk.filegroups(ctx)) 20*8975f5c5SAndroid Build Coastguard Worker fg.update(clang_all.filegroups(ctx)) 21*8975f5c5SAndroid Build Coastguard Worker return fg 22*8975f5c5SAndroid Build Coastguard Worker 23*8975f5c5SAndroid Build Coastguard Workerdef __clang_compile_coverage(ctx, cmd): 24*8975f5c5SAndroid Build Coastguard Worker clang_command = clang_code_coverage_wrapper.run(ctx, list(cmd.args)) 25*8975f5c5SAndroid Build Coastguard Worker ctx.actions.fix(args = clang_command) 26*8975f5c5SAndroid Build Coastguard Worker 27*8975f5c5SAndroid Build Coastguard Worker__handlers = { 28*8975f5c5SAndroid Build Coastguard Worker "clang_compile_coverage": __clang_compile_coverage, 29*8975f5c5SAndroid Build Coastguard Worker} 30*8975f5c5SAndroid Build Coastguard Worker 31*8975f5c5SAndroid Build Coastguard Workerdef __step_config(ctx, step_config): 32*8975f5c5SAndroid Build Coastguard Worker cfg = "buildtools/reclient_cfgs/chromium-browser-clang/rewrapper_mac.cfg" 33*8975f5c5SAndroid Build Coastguard Worker if ctx.fs.exists(cfg): 34*8975f5c5SAndroid Build Coastguard Worker reproxy_config = rewrapper_cfg.parse(ctx, cfg) 35*8975f5c5SAndroid Build Coastguard Worker largePlatform = {} 36*8975f5c5SAndroid Build Coastguard Worker for k, v in reproxy_config["platform"].items(): 37*8975f5c5SAndroid Build Coastguard Worker if k.startswith("label:action"): 38*8975f5c5SAndroid Build Coastguard Worker continue 39*8975f5c5SAndroid Build Coastguard Worker largePlatform[k] = v 40*8975f5c5SAndroid Build Coastguard Worker largePlatform["label:action_large"] = "1" 41*8975f5c5SAndroid Build Coastguard Worker step_config["platforms"].update({ 42*8975f5c5SAndroid Build Coastguard Worker "clang": reproxy_config["platform"], 43*8975f5c5SAndroid Build Coastguard Worker "clang_large": largePlatform, 44*8975f5c5SAndroid Build Coastguard Worker }) 45*8975f5c5SAndroid Build Coastguard Worker step_config["input_deps"].update(clang_all.input_deps) 46*8975f5c5SAndroid Build Coastguard Worker 47*8975f5c5SAndroid Build Coastguard Worker gn_logs_data = gn_logs.read(ctx) 48*8975f5c5SAndroid Build Coastguard Worker input_root_absolute_path = gn_logs_data.get("clang_need_input_root_absolute_path") == "true" 49*8975f5c5SAndroid Build Coastguard Worker input_root_absolute_path_for_objc = gn_logs_data.get("clang_need_input_root_absolute_path_for_objc") == "true" 50*8975f5c5SAndroid Build Coastguard Worker 51*8975f5c5SAndroid Build Coastguard Worker canonicalize_dir = not input_root_absolute_path 52*8975f5c5SAndroid Build Coastguard Worker canonicalize_dir_for_objc = not input_root_absolute_path_for_objc 53*8975f5c5SAndroid Build Coastguard Worker 54*8975f5c5SAndroid Build Coastguard Worker step_config["rules"].extend([ 55*8975f5c5SAndroid Build Coastguard Worker { 56*8975f5c5SAndroid Build Coastguard Worker "name": "clang/cxx", 57*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?cxx", 58*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang++", 59*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 60*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang++", 61*8975f5c5SAndroid Build Coastguard Worker ], 62*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 63*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 64*8975f5c5SAndroid Build Coastguard Worker "remote": True, 65*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path, 66*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir, 67*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 68*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 69*8975f5c5SAndroid Build Coastguard Worker }, 70*8975f5c5SAndroid Build Coastguard Worker { 71*8975f5c5SAndroid Build Coastguard Worker "name": "clang/cc", 72*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?cc", 73*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang", 74*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 75*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang", 76*8975f5c5SAndroid Build Coastguard Worker ], 77*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 78*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 79*8975f5c5SAndroid Build Coastguard Worker "remote": True, 80*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path, 81*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir, 82*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 83*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 84*8975f5c5SAndroid Build Coastguard Worker }, 85*8975f5c5SAndroid Build Coastguard Worker { 86*8975f5c5SAndroid Build Coastguard Worker "name": "clang/objcxx", 87*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?objcxx", 88*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang++", 89*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 90*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang++", 91*8975f5c5SAndroid Build Coastguard Worker ], 92*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 93*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 94*8975f5c5SAndroid Build Coastguard Worker "remote": True, 95*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 96*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 97*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path_for_objc, 98*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir_for_objc, 99*8975f5c5SAndroid Build Coastguard Worker }, 100*8975f5c5SAndroid Build Coastguard Worker { 101*8975f5c5SAndroid Build Coastguard Worker "name": "clang/objc", 102*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?objc", 103*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang", 104*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 105*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang", 106*8975f5c5SAndroid Build Coastguard Worker ], 107*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 108*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 109*8975f5c5SAndroid Build Coastguard Worker "remote": True, 110*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 111*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 112*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path_for_objc, 113*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir_for_objc, 114*8975f5c5SAndroid Build Coastguard Worker }, 115*8975f5c5SAndroid Build Coastguard Worker { 116*8975f5c5SAndroid Build Coastguard Worker "name": "clang-coverage/cxx", 117*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?cxx", 118*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 119*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 120*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang++", 121*8975f5c5SAndroid Build Coastguard Worker ], 122*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 123*8975f5c5SAndroid Build Coastguard Worker "handler": "clang_compile_coverage", 124*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 125*8975f5c5SAndroid Build Coastguard Worker "remote": True, 126*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path, 127*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir, 128*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 129*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 130*8975f5c5SAndroid Build Coastguard Worker }, 131*8975f5c5SAndroid Build Coastguard Worker { 132*8975f5c5SAndroid Build Coastguard Worker "name": "clang-coverage/cc", 133*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?cc", 134*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 135*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 136*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang", 137*8975f5c5SAndroid Build Coastguard Worker ], 138*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 139*8975f5c5SAndroid Build Coastguard Worker "handler": "clang_compile_coverage", 140*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 141*8975f5c5SAndroid Build Coastguard Worker "remote": True, 142*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path, 143*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir, 144*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 145*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 146*8975f5c5SAndroid Build Coastguard Worker }, 147*8975f5c5SAndroid Build Coastguard Worker { 148*8975f5c5SAndroid Build Coastguard Worker "name": "clang-coverage/objcxx", 149*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?objcxx", 150*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 151*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 152*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang++", 153*8975f5c5SAndroid Build Coastguard Worker ], 154*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 155*8975f5c5SAndroid Build Coastguard Worker "handler": "clang_compile_coverage", 156*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 157*8975f5c5SAndroid Build Coastguard Worker "remote": True, 158*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 159*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 160*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path_for_objc, 161*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir_for_objc, 162*8975f5c5SAndroid Build Coastguard Worker }, 163*8975f5c5SAndroid Build Coastguard Worker { 164*8975f5c5SAndroid Build Coastguard Worker "name": "clang-coverage/objc", 165*8975f5c5SAndroid Build Coastguard Worker "action": "(.*_)?objc", 166*8975f5c5SAndroid Build Coastguard Worker "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 167*8975f5c5SAndroid Build Coastguard Worker "inputs": [ 168*8975f5c5SAndroid Build Coastguard Worker "third_party/llvm-build/Release+Asserts/bin/clang", 169*8975f5c5SAndroid Build Coastguard Worker ], 170*8975f5c5SAndroid Build Coastguard Worker "exclude_input_patterns": ["*.stamp"], 171*8975f5c5SAndroid Build Coastguard Worker "handler": "clang_compile_coverage", 172*8975f5c5SAndroid Build Coastguard Worker "platform_ref": "clang", 173*8975f5c5SAndroid Build Coastguard Worker "remote": True, 174*8975f5c5SAndroid Build Coastguard Worker "remote_wrapper": reproxy_config["remote_wrapper"], 175*8975f5c5SAndroid Build Coastguard Worker "timeout": "2m", 176*8975f5c5SAndroid Build Coastguard Worker "input_root_absolute_path": input_root_absolute_path_for_objc, 177*8975f5c5SAndroid Build Coastguard Worker "canonicalize_dir": canonicalize_dir_for_objc, 178*8975f5c5SAndroid Build Coastguard Worker }, 179*8975f5c5SAndroid Build Coastguard Worker ]) 180*8975f5c5SAndroid Build Coastguard Worker elif gn.args(ctx).get("use_remoteexec") == "true": 181*8975f5c5SAndroid Build Coastguard Worker fail("remoteexec requires rewrapper config") 182*8975f5c5SAndroid Build Coastguard Worker return step_config 183*8975f5c5SAndroid Build Coastguard Worker 184*8975f5c5SAndroid Build Coastguard Workerclang = module( 185*8975f5c5SAndroid Build Coastguard Worker "clang", 186*8975f5c5SAndroid Build Coastguard Worker step_config = __step_config, 187*8975f5c5SAndroid Build Coastguard Worker filegroups = __filegroups, 188*8975f5c5SAndroid Build Coastguard Worker handlers = __handlers, 189*8975f5c5SAndroid Build Coastguard Worker) 190