• 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 rust/linux."""
6
7load("@builtin//struct.star", "module")
8
9def __filegroups(ctx):
10    return {
11        "third_party/rust-toolchain:toolchain": {
12            "type": "glob",
13            "includes": [
14                "bin/rustc",
15                "lib/*.so",
16            ],
17        },
18        "build/linux/debian_bullseye_amd64-sysroot:rustlink": {
19            "type": "glob",
20            "includes": [
21                "*.so",
22                "*.so.*",
23                "*.o",
24                "*.a",
25            ],
26        },
27        "third_party/llvm-build/Release+Asserts:rustlink": {
28            "type": "glob",
29            "includes": [
30                "bin/clang",
31                "bin/clang++",
32                "bin/*lld",
33                "libclang*.a",
34            ],
35        },
36        "third_party/fuchsia-sdk/sdk/arch/x64/lib:rustlink": {
37            "type": "glob",
38            "includes": [
39                "*",
40            ],
41        },
42        "third_party/fuchsia-sdk/sdk/arch/x64/sysroot:rustlink": {
43            "type": "glob",
44            "includes": [
45                "lib/*",
46            ],
47        },
48    }
49
50def __rust_bin_handler(ctx, cmd):
51    inputs = []
52    for i, arg in enumerate(cmd.args):
53        if arg.startswith("--sysroot=../../third_party/fuchsia-sdk/sdk/arch/x64/sysroot"):
54            inputs.extend([
55                "third_party/fuchsia-sdk/sdk/arch/x64/lib:rustlink",
56                "third_party/fuchsia-sdk/sdk/arch/x64/sysroot:rustlink",
57            ])
58    ctx.actions.fix(inputs = cmd.inputs + inputs)
59
60__handlers = {
61    "rust_bin_handler": __rust_bin_handler,
62}
63
64def __step_config(ctx, step_config):
65    remote_run = True  # Turn this to False when you do file access trace.
66    platform_ref = "large"  # Rust actions run faster on large workers.
67    clang_inputs = [
68        "build/linux/debian_bullseye_amd64-sysroot:rustlink",
69        "third_party/llvm-build/Release+Asserts:rustlink",
70    ]
71    rust_inputs = [
72        "build/action_helpers.py",
73        "build/gn_helpers.py",
74        "build/rust/rustc_wrapper.py",
75        # TODO(b/285225184): use precomputed subtree
76        "third_party/rust-toolchain:toolchain",
77    ]
78    rust_indirect_inputs = {
79        "includes": [
80            "*.h",
81            "*.o",
82            "*.rlib",
83            "*.rs",
84            "*.so",
85        ],
86    }
87    step_config["rules"].extend([
88        {
89            "name": "rust_bin",
90            "action": "(.*_)?rust_bin",
91            "inputs": rust_inputs + clang_inputs,
92            "indirect_inputs": rust_indirect_inputs,
93            "handler": "rust_bin_handler",
94            "deps": "none",  # disable gcc scandeps
95            "remote": remote_run,
96            # "canonicalize_dir": True,  # TODO(b/300352286)
97            "timeout": "2m",
98            "platform_ref": platform_ref,
99        },
100        {
101            "name": "rust_cdylib",
102            "action": "(.*_)?rust_cdylib",
103            "inputs": rust_inputs + clang_inputs,
104            "indirect_inputs": rust_indirect_inputs,
105            "deps": "none",  # disable gcc scandeps
106            "remote": remote_run,
107            "canonicalize_dir": True,
108            "timeout": "2m",
109            "platform_ref": platform_ref,
110        },
111        {
112            "name": "rust_macro",
113            "action": "(.*_)?rust_macro",
114            "inputs": rust_inputs + clang_inputs,
115            "indirect_inputs": rust_indirect_inputs,
116            "deps": "none",  # disable gcc scandeps
117            "remote": remote_run,
118            "canonicalize_dir": True,
119            "timeout": "2m",
120            "platform_ref": platform_ref,
121        },
122        {
123            "name": "rust_rlib",
124            "action": "(.*_)?rust_rlib",
125            "inputs": rust_inputs,
126            "indirect_inputs": rust_indirect_inputs,
127            "deps": "none",  # disable gcc scandeps
128            "remote": remote_run,
129            # "canonicalize_dir": True,  # TODO(b/300352286)
130            "timeout": "2m",
131            "platform_ref": platform_ref,
132        },
133        {
134            "name": "rust_staticlib",
135            "action": "(.*_)?rust_staticlib",
136            "inputs": rust_inputs,
137            "indirect_inputs": rust_indirect_inputs,
138            "deps": "none",  # disable gcc scandeps
139            "remote": remote_run,
140            "canonicalize_dir": True,
141            "timeout": "2m",
142            "platform_ref": platform_ref,
143        },
144    ])
145    return step_config
146
147rust = module(
148    "rust",
149    filegroups = __filegroups,
150    handlers = __handlers,
151    step_config = __step_config,
152)
153