fork/rules_rust

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

Brian SilvermanEnsure memchr is linked after libobject (#1349)ffb946f4

0.8.0
6.1 KiB122 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        "name": "str: The name of this crate.",
26        "output": "File: The output File that will be produced, depends on crate type.",
27        "owner": "Label: The label of the target that produced this CrateInfo",
28        "proc_macro_deps": "depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.",
29        "root": "File: The source File entrypoint to this crate, eg. lib.rs",
30        "rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.",
31        "srcs": "depset[File]: All source Files that are part of the crate.",
32        "type": (
33            "str: The type of this crate " +
34            "(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))."
35        ),
36        "wrapped_crate_type": (
37            "str, optional: The original crate type for targets generated using a previously defined " +
38            "crate (typically tests using the `rust_test::crate` attribute)"
39        ),
40    },
41)
42
43DepInfo = provider(
44    doc = "A provider containing information about a Crate's dependencies.",
45    fields = {
46        "dep_env": "File: File with environment variables direct dependencies build scripts rely upon.",
47        "direct_crates": "depset[AliasableDepInfo]",
48        "link_search_path_files": "depset[File]: All transitive files containing search paths to pass to the linker",
49        "transitive_build_infos": "depset[BuildInfo]",
50        "transitive_crate_outputs": "depset[File]: All transitive crate outputs.",
51        "transitive_crates": "depset[CrateInfo]",
52        "transitive_noncrates": "depset[LinkerInput]: All transitive dependencies that aren't crates.",
53    },
54)
55
56BuildInfo = provider(
57    doc = "A provider containing `rustc` build settings for a given Crate.",
58    fields = {
59        "dep_env": "File: extra build script environment varibles to be set to direct dependencies.",
60        "flags": "File: file containing additional flags to pass to rustc",
61        "link_flags": "File: file containing flags to pass to the linker",
62        "link_search_paths": "File: file containing search paths to pass to the linker",
63        "out_dir": "File: directory containing the result of a build script",
64        "rustc_env": "File: file containing additional environment variables to set for rustc.",
65    },
66)
67
68DepVariantInfo = provider(
69    doc = "A wrapper provider for a dependency of a crate. The dependency can be a Rust " +
70          "dependency, in which case the `crate_info` and `dep_info` fields will be populated, " +
71          "a Rust build script dependency, in which case `build_info` will be populated, or a " +
72          "C/C++ dependency, in which case `cc_info` will be populated.",
73    fields = {
74        "build_info": "BuildInfo: The BuildInfo of a Rust dependency",
75        "cc_info": "CcInfo: The CcInfo of a C/C++ dependency",
76        "crate_info": "CrateInfo: The CrateInfo of a Rust dependency",
77        "dep_info": "DepInfo: The DepInfo of a Rust dependency",
78    },
79)
80
81StdLibInfo = provider(
82    doc = (
83        "A collection of files either found within the `rust-stdlib` artifact or " +
84        "generated based on existing files."
85    ),
86    fields = {
87        "alloc_files": "List[File]: `.a` files related to the `alloc` module.",
88        "between_alloc_and_core_files": "List[File]: `.a` files related to the `compiler_builtins` module.",
89        "between_core_and_std_files": "List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`.",
90        "core_files": "List[File]: `.a` files related to the `core` and `adler` modules",
91        "dot_a_files": "Depset[File]: Generated `.a` files",
92        "memchr_files": "Depset[File]: `.a` files associated with the `memchr` module.",
93        "self_contained_files": "List[File]: All `.o` files from the `self-contained` directory.",
94        "srcs": "List[Target]: All targets from the original `srcs` attribute.",
95        "std_files": "Depset[File]: `.a` files associated with the `std` module.",
96        "std_rlibs": "List[File]: All `.rlib` files",
97    },
98)
99
100CaptureClippyOutputInfo = provider(
101    doc = "Value of the `capture_clippy_output` build setting",
102    fields = {"capture_output": "Value of the `capture_clippy_output` build setting"},
103)
104
105ClippyInfo = provider(
106    doc = "Provides information on a clippy run.",
107    fields = {
108        "output": "File with the clippy output.",
109    },
110)
111
112TestCrateInfo = provider(
113    doc = "A wrapper around a CrateInfo. " +
114          "Certain rule types, like rust_static_library and rust_shared_library " +
115          "are not intended for consumption by other Rust targets, and should not " +
116          "provide a CrateInfo. However, one should still be able to write a rust_test " +
117          "for them. Thus, we create a CrateInfo, but do not advertise it as such, " +
118          "but rather through this provider, that rust_test understands.",
119    fields = {
120        "crate": "CrateInfo: The underlying CrateInfo of the dependency",
121    },
122)