• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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//struct.star", "module")
9load("./clang_all.star", "clang_all")
10load("./clang_unix.star", "clang_unix")
11load("./mac_sdk.star", "mac_sdk")
12load("./rewrapper_cfg.star", "rewrapper_cfg")
13
14def __filegroups(ctx):
15    fg = {}
16    fg.update(mac_sdk.filegroups(ctx))
17    fg.update(clang_all.filegroups(ctx))
18    return fg
19
20__handlers = {}
21__handlers.update(clang_unix.handlers)
22__handlers.update(clang_all.handlers)
23
24def __step_config(ctx, step_config):
25    cfg = "buildtools/reclient_cfgs/chromium-browser-clang/rewrapper_mac.cfg"
26    if ctx.fs.exists(cfg):
27        reproxy_config = rewrapper_cfg.parse(ctx, cfg)
28        largePlatform = {}
29        for k, v in reproxy_config["platform"].items():
30            if k.startswith("label:action"):
31                continue
32            largePlatform[k] = v
33        largePlatform["label:action_large"] = "1"
34        step_config["platforms"].update({
35            "clang": reproxy_config["platform"],
36            "clang_large": largePlatform,
37        })
38        step_config["input_deps"].update(clang_all.input_deps)
39
40        clang_rules = clang_unix.rules(ctx)
41
42        for rule in clang_rules:
43            if "remote" in rule and rule["remote"]:
44                rule["remote_wrapper"] = reproxy_config["remote_wrapper"]
45                if "platform_ref" not in rule:
46                    rule["platform_ref"] = "clang"
47                elif rule["platform_ref"] == "large":
48                    rule["platform_ref"] = "clang_large"
49            step_config["rules"].append(rule)
50    elif gn.args(ctx).get("use_remoteexec") == "true":
51        fail("remoteexec requires rewrapper config")
52    return step_config
53
54clang = module(
55    "clang",
56    step_config = __step_config,
57    filegroups = __filegroups,
58    handlers = __handlers,
59)
60