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