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/mac.""" 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("./rewrapper_cfg.star", "rewrapper_cfg") 13 14def __filegroups(ctx): 15 sdk_includes = [ 16 "*.framework", 17 "*.h", 18 "*.json", 19 "*.modulemap", 20 "Current", 21 "Frameworks", 22 "Headers", 23 "Modules", 24 "crt*.o", 25 "usr/include/c++/v1/*", 26 "usr/include/c++/v1/*/*", 27 ] 28 fg = { 29 "build/mac_files/xcode_binaries/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk:headers": { 30 "type": "glob", 31 "includes": sdk_includes, 32 }, 33 } 34 35 # precompute subtree for sysroot/frameworks for siso scandeps, 36 # which is not complex enough to handle C preprocessor tricks 37 # and need system include dirs when using deps log of -MMD. 38 # need to add new entries when new version is used. 39 # TODO: b/323091468 - get sysroot, ios_sdk_path from gn 40 fg[ctx.fs.canonpath("./sdk/xcode_links/MacOSX14.2.sdk") + ":headers"] = { 41 "type": "glob", 42 "includes": sdk_includes, 43 } 44 fg[ctx.fs.canonpath("./sdk/xcode_links/iPhoneSimulator17.2.sdk") + ":headers"] = { 45 "type": "glob", 46 "includes": sdk_includes, 47 } 48 49 # https://b.corp.google.com/issues/332652041#comment2 50 fg[ctx.fs.canonpath("./sdk/xcode_links/MacOSX14.4.sdk") + ":headers"] = { 51 "type": "glob", 52 "includes": sdk_includes, 53 } 54 fg[ctx.fs.canonpath("./sdk/xcode_links/iPhoneSimulator17.4.sdk") + ":headers"] = { 55 "type": "glob", 56 "includes": sdk_includes, 57 } 58 fg[ctx.fs.canonpath("./sdk/xcode_links/iPhoneSimulator.platform/Developer/Library/Frameworks") + ":headers"] = { 59 "type": "glob", 60 "includes": sdk_includes, 61 } 62 fg.update(clang_all.filegroups(ctx)) 63 return fg 64 65def __clang_compile_coverage(ctx, cmd): 66 clang_command = clang_code_coverage_wrapper.run(ctx, list(cmd.args)) 67 ctx.actions.fix(args = clang_command) 68 69__handlers = { 70 "clang_compile_coverage": __clang_compile_coverage, 71} 72 73def __step_config(ctx, step_config): 74 cfg = "buildtools/reclient_cfgs/chromium-browser-clang/rewrapper_mac.cfg" 75 if ctx.fs.exists(cfg): 76 reproxy_config = rewrapper_cfg.parse(ctx, cfg) 77 largePlatform = {} 78 for k, v in reproxy_config["platform"].items(): 79 if k.startswith("label:action"): 80 continue 81 largePlatform[k] = v 82 largePlatform["label:action_large"] = "1" 83 step_config["platforms"].update({ 84 "clang": reproxy_config["platform"], 85 "clang_large": largePlatform, 86 }) 87 step_config["input_deps"].update(clang_all.input_deps) 88 89 # TODO: https://issues.chromium.org/40120210 - remove this 90 # once we can use relative path in hmap. 91 need_input_root_absolute_path_for_objc = False 92 gn_args = gn.args(ctx) 93 if gn_args.get("target_os") == "\"ios\"": 94 # objc/objcxx uses hmap, which contains absolute path 95 # see also b/256536089 96 need_input_root_absolute_path_for_objc = True 97 step_config["rules"].extend([ 98 { 99 "name": "clang/cxx", 100 "action": "(.*_)?cxx", 101 "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang++", 102 "inputs": [ 103 "third_party/llvm-build/Release+Asserts/bin/clang++", 104 ], 105 "exclude_input_patterns": ["*.stamp"], 106 "platform_ref": "clang", 107 "remote": True, 108 "remote_wrapper": reproxy_config["remote_wrapper"], 109 "timeout": "2m", 110 }, 111 { 112 "name": "clang/cc", 113 "action": "(.*_)?cc", 114 "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang", 115 "inputs": [ 116 "third_party/llvm-build/Release+Asserts/bin/clang", 117 ], 118 "exclude_input_patterns": ["*.stamp"], 119 "platform_ref": "clang", 120 "remote": True, 121 "remote_wrapper": reproxy_config["remote_wrapper"], 122 "timeout": "2m", 123 }, 124 { 125 "name": "clang/objcxx", 126 "action": "(.*_)?objcxx", 127 "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang++", 128 "inputs": [ 129 "third_party/llvm-build/Release+Asserts/bin/clang++", 130 ], 131 "exclude_input_patterns": ["*.stamp"], 132 "platform_ref": "clang", 133 "remote": True, 134 "remote_wrapper": reproxy_config["remote_wrapper"], 135 "timeout": "2m", 136 "input_root_absolute_path": need_input_root_absolute_path_for_objc, 137 }, 138 { 139 "name": "clang/objc", 140 "action": "(.*_)?objc", 141 "command_prefix": "../../third_party/llvm-build/Release+Asserts/bin/clang", 142 "inputs": [ 143 "third_party/llvm-build/Release+Asserts/bin/clang", 144 ], 145 "exclude_input_patterns": ["*.stamp"], 146 "platform_ref": "clang", 147 "remote": True, 148 "remote_wrapper": reproxy_config["remote_wrapper"], 149 "timeout": "2m", 150 "input_root_absolute_path": need_input_root_absolute_path_for_objc, 151 }, 152 { 153 "name": "clang-coverage/cxx", 154 "action": "(.*_)?cxx", 155 "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 156 "inputs": [ 157 "third_party/llvm-build/Release+Asserts/bin/clang++", 158 ], 159 "exclude_input_patterns": ["*.stamp"], 160 "handler": "clang_compile_coverage", 161 "platform_ref": "clang", 162 "remote": True, 163 "remote_wrapper": reproxy_config["remote_wrapper"], 164 "timeout": "2m", 165 }, 166 { 167 "name": "clang-coverage/cc", 168 "action": "(.*_)?cc", 169 "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 170 "inputs": [ 171 "third_party/llvm-build/Release+Asserts/bin/clang", 172 ], 173 "exclude_input_patterns": ["*.stamp"], 174 "handler": "clang_compile_coverage", 175 "platform_ref": "clang", 176 "remote": True, 177 "remote_wrapper": reproxy_config["remote_wrapper"], 178 "timeout": "2m", 179 }, 180 { 181 "name": "clang-coverage/objcxx", 182 "action": "(.*_)?objcxx", 183 "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 184 "inputs": [ 185 "third_party/llvm-build/Release+Asserts/bin/clang++", 186 ], 187 "exclude_input_patterns": ["*.stamp"], 188 "handler": "clang_compile_coverage", 189 "platform_ref": "clang", 190 "remote": True, 191 "remote_wrapper": reproxy_config["remote_wrapper"], 192 "timeout": "2m", 193 "input_root_absolute_path": need_input_root_absolute_path_for_objc, 194 }, 195 { 196 "name": "clang-coverage/objc", 197 "action": "(.*_)?objc", 198 "command_prefix": "python3 ../../build/toolchain/clang_code_coverage_wrapper.py", 199 "inputs": [ 200 "third_party/llvm-build/Release+Asserts/bin/clang", 201 ], 202 "exclude_input_patterns": ["*.stamp"], 203 "handler": "clang_compile_coverage", 204 "platform_ref": "clang", 205 "remote": True, 206 "remote_wrapper": reproxy_config["remote_wrapper"], 207 "timeout": "2m", 208 "input_root_absolute_path": need_input_root_absolute_path_for_objc, 209 }, 210 ]) 211 return step_config 212 213clang = module( 214 "clang", 215 step_config = __step_config, 216 filegroups = __filegroups, 217 handlers = __handlers, 218) 219