1*d4726bddSHONG Yifan# Copyright 2021 The Bazel Authors. All rights reserved. 2*d4726bddSHONG Yifan# 3*d4726bddSHONG Yifan# Licensed under the Apache License, Version 2.0 (the "License"); 4*d4726bddSHONG Yifan# you may not use this file except in compliance with the License. 5*d4726bddSHONG Yifan# You may obtain a copy of the License at 6*d4726bddSHONG Yifan# 7*d4726bddSHONG Yifan# http://www.apache.org/licenses/LICENSE-2.0 8*d4726bddSHONG Yifan# 9*d4726bddSHONG Yifan# Unless required by applicable law or agreed to in writing, software 10*d4726bddSHONG Yifan# distributed under the License is distributed on an "AS IS" BASIS, 11*d4726bddSHONG Yifan# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*d4726bddSHONG Yifan# See the License for the specific language governing permissions and 13*d4726bddSHONG Yifan# limitations under the License. 14*d4726bddSHONG Yifan 15*d4726bddSHONG Yifan"""Module containing definitions of all Rust providers.""" 16*d4726bddSHONG Yifan 17*d4726bddSHONG YifanCrateInfo = provider( 18*d4726bddSHONG Yifan doc = "A provider containing general Crate information.", 19*d4726bddSHONG Yifan fields = { 20*d4726bddSHONG Yifan "aliases": "Dict[Label, String]: Renamed and aliased crates", 21*d4726bddSHONG Yifan "compile_data": "depset[File]: Compile data required by this crate.", 22*d4726bddSHONG Yifan "compile_data_targets": "depset[Label]: Compile data targets required by this crate.", 23*d4726bddSHONG Yifan "data": "depset[File]: Compile data required by crates that use the current crate as a proc-macro.", 24*d4726bddSHONG Yifan "deps": "depset[DepVariantInfo]: This crate's (rust or cc) dependencies' providers.", 25*d4726bddSHONG Yifan "edition": "str: The edition of this crate.", 26*d4726bddSHONG Yifan "is_test": "bool: If the crate is being compiled in a test context", 27*d4726bddSHONG Yifan "metadata": "File: The output from rustc from producing the output file. It is optional.", 28*d4726bddSHONG Yifan "name": "str: The name of this crate.", 29*d4726bddSHONG Yifan "output": "File: The output File that will be produced, depends on crate type.", 30*d4726bddSHONG Yifan "owner": "Label: The label of the target that produced this CrateInfo", 31*d4726bddSHONG Yifan "proc_macro_deps": "depset[DepVariantInfo]: This crate's rust proc_macro dependencies' providers.", 32*d4726bddSHONG Yifan "root": "File: The source File entrypoint to this crate, eg. lib.rs", 33*d4726bddSHONG Yifan "rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.", 34*d4726bddSHONG Yifan "rustc_env_files": "[File]: Files containing additional environment variables to set for rustc.", 35*d4726bddSHONG Yifan "rustc_output": "File: The output from rustc from producing the output file. It is optional.", 36*d4726bddSHONG Yifan "rustc_rmeta_output": "File: The rmeta file produced for this crate. It is optional.", 37*d4726bddSHONG Yifan "srcs": "depset[File]: All source Files that are part of the crate.", 38*d4726bddSHONG Yifan "std_dylib": "File: libstd.so file", 39*d4726bddSHONG Yifan "type": ( 40*d4726bddSHONG Yifan "str: The type of this crate " + 41*d4726bddSHONG Yifan "(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))." 42*d4726bddSHONG Yifan ), 43*d4726bddSHONG Yifan "wrapped_crate_type": ( 44*d4726bddSHONG Yifan "str, optional: The original crate type for targets generated using a previously defined " + 45*d4726bddSHONG Yifan "crate (typically tests using the `rust_test::crate` attribute)" 46*d4726bddSHONG Yifan ), 47*d4726bddSHONG Yifan }, 48*d4726bddSHONG Yifan) 49*d4726bddSHONG Yifan 50*d4726bddSHONG YifanDepInfo = provider( 51*d4726bddSHONG Yifan doc = "A provider containing information about a Crate's dependencies.", 52*d4726bddSHONG Yifan fields = { 53*d4726bddSHONG Yifan "dep_env": "File: File with environment variables direct dependencies build scripts rely upon.", 54*d4726bddSHONG Yifan "direct_crates": "depset[AliasableDepInfo]", 55*d4726bddSHONG Yifan "link_search_path_files": "depset[File]: All transitive files containing search paths to pass to the linker", 56*d4726bddSHONG Yifan "transitive_build_infos": "depset[BuildInfo]", 57*d4726bddSHONG Yifan "transitive_crate_outputs": "depset[File]: All transitive crate outputs.", 58*d4726bddSHONG Yifan "transitive_crates": "depset[CrateInfo]", 59*d4726bddSHONG Yifan "transitive_data": "depset[File]: Data of all transitive non-macro dependencies.", 60*d4726bddSHONG Yifan "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.", 61*d4726bddSHONG Yifan "transitive_noncrates": "depset[LinkerInput]: All transitive dependencies that aren't crates.", 62*d4726bddSHONG Yifan "transitive_proc_macro_data": "depset[File]: Data of all transitive proc-macro dependencies, and non-macro dependencies of those macros.", 63*d4726bddSHONG Yifan }, 64*d4726bddSHONG Yifan) 65*d4726bddSHONG Yifan 66*d4726bddSHONG YifanCrateGroupInfo = provider( 67*d4726bddSHONG Yifan doc = "A provider containing a group of crates.", 68*d4726bddSHONG Yifan fields = { 69*d4726bddSHONG Yifan "dep_variant_infos": "depset[DepVariantInfo]: Dependency information from all crates in the group.", 70*d4726bddSHONG Yifan }, 71*d4726bddSHONG Yifan) 72*d4726bddSHONG Yifan 73*d4726bddSHONG YifanBuildInfo = provider( 74*d4726bddSHONG Yifan doc = "A provider containing `rustc` build settings for a given Crate.", 75*d4726bddSHONG Yifan fields = { 76*d4726bddSHONG Yifan "compile_data": "Depset[File]: Compile data provided by the build script that was not copied into `out_dir`.", 77*d4726bddSHONG Yifan "dep_env": "Optinal[File]: extra build script environment varibles to be set to direct dependencies.", 78*d4726bddSHONG Yifan "flags": "Optional[File]: file containing additional flags to pass to rustc", 79*d4726bddSHONG Yifan "link_search_paths": "Optional[File]: file containing search paths to pass to rustc and linker", 80*d4726bddSHONG Yifan "linker_flags": "Optional[File]: file containing flags to pass to the linker invoked by rustc or cc_common.link", 81*d4726bddSHONG Yifan "out_dir": "Optional[File]: directory containing the result of a build script", 82*d4726bddSHONG Yifan "rustc_env": "Optional[File]: file containing additional environment variables to set for rustc.", 83*d4726bddSHONG Yifan }, 84*d4726bddSHONG Yifan) 85*d4726bddSHONG Yifan 86*d4726bddSHONG YifanDepVariantInfo = provider( 87*d4726bddSHONG Yifan doc = "A wrapper provider for a dependency of a crate. The dependency can be a Rust " + 88*d4726bddSHONG Yifan "dependency, in which case the `crate_info` and `dep_info` fields will be populated, " + 89*d4726bddSHONG Yifan "a Rust build script dependency, in which case `build_info` will be populated, a C/C++" + 90*d4726bddSHONG Yifan "dependency, in which case `cc_info` will be populated, or a Rust crate group, in which" + 91*d4726bddSHONG Yifan "case `crate_group_info` will be populated.", 92*d4726bddSHONG Yifan fields = { 93*d4726bddSHONG Yifan "build_info": "BuildInfo: The BuildInfo of a Rust dependency", 94*d4726bddSHONG Yifan "cc_info": "CcInfo: The CcInfo of a C/C++ dependency", 95*d4726bddSHONG Yifan "crate_group_info": "CrateGroupInfo: The CrateGroupInfo of a Rust crate group dependency", 96*d4726bddSHONG Yifan "crate_info": "CrateInfo: The CrateInfo of a Rust dependency", 97*d4726bddSHONG Yifan "dep_info": "DepInfo: The DepInfo of a Rust dependency", 98*d4726bddSHONG Yifan }, 99*d4726bddSHONG Yifan) 100*d4726bddSHONG Yifan 101*d4726bddSHONG YifanRustcOutputDiagnosticsInfo = provider( 102*d4726bddSHONG Yifan doc = ( 103*d4726bddSHONG Yifan "Save json diagnostics from rustc. Json diagnostics are able to be " + 104*d4726bddSHONG Yifan "consumed by tools such as rust-analyzer to provide IDE integration" 105*d4726bddSHONG Yifan ), 106*d4726bddSHONG Yifan fields = { 107*d4726bddSHONG Yifan "rustc_output_diagnostics": "bool: Whether or not to output diagnostics", 108*d4726bddSHONG Yifan }, 109*d4726bddSHONG Yifan) 110*d4726bddSHONG Yifan 111*d4726bddSHONG YifanStdLibInfo = provider( 112*d4726bddSHONG Yifan doc = ( 113*d4726bddSHONG Yifan "A collection of files either found within the `rust-stdlib` artifact or " + 114*d4726bddSHONG Yifan "generated based on existing files." 115*d4726bddSHONG Yifan ), 116*d4726bddSHONG Yifan fields = { 117*d4726bddSHONG Yifan "alloc_files": "List[File]: `.a` files related to the `alloc` module.", 118*d4726bddSHONG Yifan "between_alloc_and_core_files": "List[File]: `.a` files related to the `compiler_builtins` module.", 119*d4726bddSHONG Yifan "between_core_and_std_files": "List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`.", 120*d4726bddSHONG Yifan "core_files": "List[File]: `.a` files related to the `core` and `adler` modules", 121*d4726bddSHONG Yifan "dot_a_files": "Depset[File]: Generated `.a` files", 122*d4726bddSHONG Yifan "memchr_files": "Depset[File]: `.a` files associated with the `memchr` module.", 123*d4726bddSHONG Yifan "panic_files": "Depset[File]: `.a` files associated with `panic_unwind` and `panic_abort`.", 124*d4726bddSHONG Yifan "self_contained_files": "List[File]: All `.o` files from the `self-contained` directory.", 125*d4726bddSHONG Yifan "srcs": "List[Target]: All targets from the original `srcs` attribute.", 126*d4726bddSHONG Yifan "std_dylib": "File: libstd.so file", 127*d4726bddSHONG Yifan "std_files": "Depset[File]: `.a` files associated with the `std` module.", 128*d4726bddSHONG Yifan "std_rlibs": "List[File]: All `.rlib` files", 129*d4726bddSHONG Yifan "test_files": "Depset[File]: `.a` files associated with the `test` module.", 130*d4726bddSHONG Yifan }, 131*d4726bddSHONG Yifan) 132*d4726bddSHONG Yifan 133*d4726bddSHONG YifanCaptureClippyOutputInfo = provider( 134*d4726bddSHONG Yifan doc = "Value of the `capture_clippy_output` build setting", 135*d4726bddSHONG Yifan fields = {"capture_output": "Value of the `capture_clippy_output` build setting"}, 136*d4726bddSHONG Yifan) 137*d4726bddSHONG Yifan 138*d4726bddSHONG YifanClippyInfo = provider( 139*d4726bddSHONG Yifan doc = "Provides information on a clippy run.", 140*d4726bddSHONG Yifan fields = { 141*d4726bddSHONG Yifan "output": "File with the clippy output.", 142*d4726bddSHONG Yifan }, 143*d4726bddSHONG Yifan) 144*d4726bddSHONG Yifan 145*d4726bddSHONG YifanTestCrateInfo = provider( 146*d4726bddSHONG Yifan doc = "A wrapper around a CrateInfo. " + 147*d4726bddSHONG Yifan "Certain rule types, like rust_static_library and rust_shared_library " + 148*d4726bddSHONG Yifan "are not intended for consumption by other Rust targets, and should not " + 149*d4726bddSHONG Yifan "provide a CrateInfo. However, one should still be able to write a rust_test " + 150*d4726bddSHONG Yifan "for them. Thus, we create a CrateInfo, but do not advertise it as such, " + 151*d4726bddSHONG Yifan "but rather through this provider, that rust_test understands.", 152*d4726bddSHONG Yifan fields = { 153*d4726bddSHONG Yifan "crate": "CrateInfo: The underlying CrateInfo of the dependency", 154*d4726bddSHONG Yifan }, 155*d4726bddSHONG Yifan) 156*d4726bddSHONG Yifan 157*d4726bddSHONG YifanRustAnalyzerInfo = provider( 158*d4726bddSHONG Yifan doc = "RustAnalyzerInfo holds rust crate metadata for targets", 159*d4726bddSHONG Yifan fields = { 160*d4726bddSHONG Yifan "aliases": "Dict[RustAnalyzerInfo, String]: Replacement names these targets should be known as in Rust code", 161*d4726bddSHONG Yifan "build_info": "BuildInfo: build info for this crate if present", 162*d4726bddSHONG Yifan "cfgs": "List[String]: features or other compilation `--cfg` settings", 163*d4726bddSHONG Yifan "crate": "CrateInfo: Crate information.", 164*d4726bddSHONG Yifan "crate_specs": "Depset[File]: transitive closure of OutputGroupInfo files", 165*d4726bddSHONG Yifan "deps": "List[RustAnalyzerInfo]: direct dependencies", 166*d4726bddSHONG Yifan "env": "Dict[String: String]: Environment variables, used for the `env!` macro", 167*d4726bddSHONG Yifan "proc_macro_dylib_path": "File: compiled shared library output of proc-macro rule", 168*d4726bddSHONG Yifan }, 169*d4726bddSHONG Yifan) 170*d4726bddSHONG Yifan 171*d4726bddSHONG YifanRustAnalyzerGroupInfo = provider( 172*d4726bddSHONG Yifan doc = "RustAnalyzerGroupInfo holds multiple RustAnalyzerInfos", 173*d4726bddSHONG Yifan fields = { 174*d4726bddSHONG Yifan "deps": "List[RustAnalyzerInfo]: direct dependencies", 175*d4726bddSHONG Yifan }, 176*d4726bddSHONG Yifan) 177