fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

Brian SilvermanPropagate rustc_env{,_files} from rust_test.crate (#1443)6ee7c80b

0.11.0
6.6 KiB126 linesraw
1# Copyright 2021 The Bazel Authors. All rights reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#    http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""Module containing definitions of all Rust providers."""
16
17CrateInfo = provider(
18    doc = "A provider containing general Crate information.",
19    fields = {
20        "aliases": "Dict[Label, String]: Renamed and aliased crates",
21        "compile_data": "depset[File]: Compile data required by this crate.",
22        "deps": "depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers.",
23        "edition": "str: The edition of this crate.",
24        "is_test": "bool: If the crate is being compiled in a test context",
25        "metadata": "File: The rmeta file produced for this crate. It is optional.",
26        "name": "str: The name of this crate.",
27        "output": "File: The output File that will be produced, depends on crate type.",
28        "owner": "Label: The label of the target that produced this CrateInfo",
29        "proc_macro_deps": "depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.",
30        "root": "File: The source File entrypoint to this crate, eg. lib.rs",
31        "rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
32        "rustc_env_files": "[File]: Files containing additional environment variables to set for rustc.",
33        "srcs": "depset[File]: All source Files that are part of the crate.",
34        "type": (
35            "str: The type of this crate " +
36            "(see [rustc --crate-type](https://doc.rust-lang.org/rustc/command-line-arguments.html#--crate-type-a-list-of-types-of-crates-for-the-compiler-to-emit))."
37        ),
38        "wrapped_crate_type": (
39            "str, optional: The original crate type for targets generated using a previously defined " +
40            "crate (typically tests using the `rust_test::crate` attribute)"
41        ),
42    },
43)
44
45DepInfo = provider(
46    doc = "A provider containing information about a Crate's dependencies.",
47    fields = {
48        "dep_env": "File: File with environment variables direct dependencies build scripts rely upon.",
49        "direct_crates": "depset[AliasableDepInfo]",
50        "link_search_path_files": "depset[File]: All transitive files containing search paths to pass to the linker",
51        "transitive_build_infos": "depset[BuildInfo]",
52        "transitive_crate_outputs": "depset[File]: All transitive crate outputs.",
53        "transitive_crates": "depset[CrateInfo]",
54        "transitive_metadata_outputs": "depset[File]: All transitive metadata dependencies (.rmeta, for crates that provide them) and all transitive object dependencies (.rlib) for crates that don't provide metadata.",
55        "transitive_noncrates": "depset[LinkerInput]: All transitive dependencies that aren't crates.",
56    },
57)
58
59BuildInfo = provider(
60    doc = "A provider containing `rustc` build settings for a given Crate.",
61    fields = {
62        "dep_env": "File: extra build script environment varibles to be set to direct dependencies.",
63        "flags": "File: file containing additional flags to pass to rustc",
64        "link_flags": "File: file containing flags to pass to the linker",
65        "link_search_paths": "File: file containing search paths to pass to the linker",
66        "out_dir": "File: directory containing the result of a build script",
67        "rustc_env": "File: file containing additional environment variables to set for rustc.",
68    },
69)
70
71DepVariantInfo = provider(
72    doc = "A wrapper provider for a dependency of a crate. The dependency can be a Rust " +
73          "dependency, in which case the `crate_info` and `dep_info` fields will be populated, " +
74          "a Rust build script dependency, in which case `build_info` will be populated, or a " +
75          "C/C++ dependency, in which case `cc_info` will be populated.",
76    fields = {
77        "build_info": "BuildInfo: The BuildInfo of a Rust dependency",
78        "cc_info": "CcInfo: The CcInfo of a C/C++ dependency",
79        "crate_info": "CrateInfo: The CrateInfo of a Rust dependency",
80        "dep_info": "DepInfo: The DepInfo of a Rust dependency",
81    },
82)
83
84StdLibInfo = provider(
85    doc = (
86        "A collection of files either found within the `rust-stdlib` artifact or " +
87        "generated based on existing files."
88    ),
89    fields = {
90        "alloc_files": "List[File]: `.a` files related to the `alloc` module.",
91        "between_alloc_and_core_files": "List[File]: `.a` files related to the `compiler_builtins` module.",
92        "between_core_and_std_files": "List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`.",
93        "core_files": "List[File]: `.a` files related to the `core` and `adler` modules",
94        "dot_a_files": "Depset[File]: Generated `.a` files",
95        "memchr_files": "Depset[File]: `.a` files associated with the `memchr` module.",
96        "self_contained_files": "List[File]: All `.o` files from the `self-contained` directory.",
97        "srcs": "List[Target]: All targets from the original `srcs` attribute.",
98        "std_files": "Depset[File]: `.a` files associated with the `std` module.",
99        "std_rlibs": "List[File]: All `.rlib` files",
100        "test_files": "Depset[File]: `.a` files associated with the `test` module.",
101    },
102)
103
104CaptureClippyOutputInfo = provider(
105    doc = "Value of the `capture_clippy_output` build setting",
106    fields = {"capture_output": "Value of the `capture_clippy_output` build setting"},
107)
108
109ClippyInfo = provider(
110    doc = "Provides information on a clippy run.",
111    fields = {
112        "output": "File with the clippy output.",
113    },
114)
115
116TestCrateInfo = provider(
117    doc = "A wrapper around a CrateInfo. " +
118          "Certain rule types, like rust_static_library and rust_shared_library " +
119          "are not intended for consumption by other Rust targets, and should not " +
120          "provide a CrateInfo. However, one should still be able to write a rust_test " +
121          "for them. Thus, we create a CrateInfo, but do not advertise it as such, " +
122          "but rather through this provider, that rust_test understands.",
123    fields = {
124        "crate": "CrateInfo: The underlying CrateInfo of the dependency",
125    },
126)