xref: /aosp_15_r20/external/cronet/build/config/siso/proto_linux.star (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
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 proto/linux."""
6
7load("@builtin//path.star", "path")
8load("@builtin//struct.star", "module")
9load("./config.star", "config")
10load("./protoc_wrapper.star", "protoc_wrapper")
11
12def __filegroups(ctx):
13    return {
14        "third_party/protobuf/python/google:pyprotolib": {
15            "type": "glob",
16            "includes": ["*.py"],
17        },
18    }
19
20def __protoc_wrapper(ctx, cmd):
21    inputs = protoc_wrapper.scandeps(ctx, cmd.args)
22    ctx.actions.fix(inputs = cmd.expanded_inputs() + inputs)
23
24__handlers = {
25    "protoc_wrapper": __protoc_wrapper,
26}
27
28def __step_config(ctx, step_config):
29    remote_run = True  # Turn this to False when you do file access trace.
30    step_config["input_deps"].update({
31        "third_party/dom_distiller_js/protoc_plugins/util/plugin_protos.py": [
32            "third_party/protobuf/python/google:pyprotolib",
33        ],
34    })
35    step_config["rules"].extend([
36        {
37            "name": "proto/protoc_wrapper",
38            "command_prefix": "python3 ../../tools/protoc_wrapper/protoc_wrapper.py",
39            "indirect_inputs": {
40                "includes": ["*.proto"],
41            },
42            "exclude_input_patterns": [
43                "*.o",
44                "*.a",
45                "*.h",
46                "*.cc",
47                # "*_pb2.py",
48            ],
49            "handler": "protoc_wrapper",
50            "remote": remote_run,
51            # chromeos generates default.profraw?
52            "ignore_extra_output_pattern": ".*default.profraw",
53            # "deps": "depfile",
54            "output_local": True,
55        },
56    ])
57    return step_config
58
59proto = module(
60    "proto",
61    step_config = __step_config,
62    filegroups = __filegroups,
63    handlers = __handlers,
64)
65