From 1977484e873e90c6a93cfbccee9586cf00d2a839 Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Thu, 26 Aug 2021 07:57:57 -0700 Subject: [PATCH 1/2] Added providers to documentation --- docs/BUILD.bazel | 22 +++++++++++++++------- docs/symbols.bzl | 12 ++++++++++++ rust/private/providers.bzl | 5 ++++- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index 2b36ebaae4..8142a7a091 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -48,13 +48,6 @@ PAGES = dict([ "crate", ], ), - page( - name = "settings", - symbols = [ - "incompatible_flag", - "fail_when_enabled", - ], - ), page( name = "defs", symbols = [ @@ -68,6 +61,14 @@ PAGES = dict([ "rust_test_suite", ], ), + page( + name = "providers", + symbols = [ + "CrateInfo", + "DepInfo", + "StdLibInfo", + ], + ), page( name = "rust_analyzer", header_template = ":rust_analyzer.vm", @@ -139,6 +140,13 @@ PAGES = dict([ "rust_wasm_bindgen", ], ), + page( + name = "settings", + symbols = [ + "incompatible_flag", + "fail_when_enabled", + ], + ), ]) # Generate headers for each page diff --git a/docs/symbols.bzl b/docs/symbols.bzl index e66a07931c..df65877d60 100644 --- a/docs/symbols.bzl +++ b/docs/symbols.bzl @@ -70,6 +70,14 @@ load( _rust_stdlib_filegroup = "rust_stdlib_filegroup", _rust_toolchain = "rust_toolchain", ) + +# buildifier: disable=bzl-visibility +load( + "@rules_rust//rust/private:providers.bzl", + _CrateInfo = "CrateInfo", + _DepInfo = "DepInfo", + _StdLibInfo = "StdLibInfo", +) load( "@rules_rust//rust/settings:incompatible.bzl", _fail_when_enabled = "fail_when_enabled", @@ -135,3 +143,7 @@ rustfmt_test = _rustfmt_test incompatible_flag = _incompatible_flag fail_when_enabled = _fail_when_enabled + +CrateInfo = _CrateInfo +DepInfo = _DepInfo +StdLibInfo = _StdLibInfo diff --git a/rust/private/providers.bzl b/rust/private/providers.bzl index 4879b0f8d7..f9d4cbf0cf 100644 --- a/rust/private/providers.bzl +++ b/rust/private/providers.bzl @@ -28,7 +28,10 @@ CrateInfo = provider( "root": "File: The source File entrypoint to this crate, eg. lib.rs", "rustc_env": "Dict[String, String]: Additional `\"key\": \"value\"` environment variables to set for rustc.", "srcs": "depset[File]: All source Files that are part of the crate.", - "type": "str: The type of this crate. eg. lib or bin", + "type": ( + "str: The type of this crate " + + "(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))." + ), "wrapped_crate_type": ( "str, optional: The original crate type for targets generated using a previously defined " + "crate (typically tests using the `rust_test::crate` attribute)" From 9f40efeb3191c4b28037b544c93b5e32a359083e Mon Sep 17 00:00:00 2001 From: UebelAndre Date: Thu, 26 Aug 2021 08:48:24 -0700 Subject: [PATCH 2/2] Regenerate documentation --- docs/flatten.md | 85 ++++++++++++++++++++++++++++++++++++++++++++ docs/providers.md | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 docs/providers.md diff --git a/docs/flatten.md b/docs/flatten.md index 3a0c334e68..6e729abe8e 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -1,5 +1,8 @@ # Rust rules +* [CrateInfo](#CrateInfo) +* [DepInfo](#DepInfo) +* [StdLibInfo](#StdLibInfo) * [cargo_bootstrap_repository](#cargo_bootstrap_repository) * [cargo_build_script](#cargo_build_script) * [crate](#crate) @@ -1391,6 +1394,88 @@ A test rule for performing `rustfmt --check` on a set of targets | targets | Rust targets to run rustfmt --check on. | List of labels | optional | [] | + + +## CrateInfo + +
+CrateInfo(aliases, compile_data, deps, edition, is_test, name, output, proc_macro_deps, root,
+          rustc_env, srcs, type, wrapped_crate_type)
+
+ +A provider containing general Crate information. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| aliases | Dict[Label, String]: Renamed and aliased crates | +| compile_data | depset[File]: Compile data required by this crate. | +| deps | depset[Provider]: This crate's (rust or cc) dependencies' providers. | +| edition | str: The edition of this crate. | +| is_test | bool: If the crate is being compiled in a test context | +| name | str: The name of this crate. | +| output | File: The output File that will be produced, depends on crate type. | +| proc_macro_deps | depset[CrateInfo]: This crate's rust proc_macro dependencies' providers. | +| root | File: The source File entrypoint to this crate, eg. lib.rs | +| rustc_env | Dict[String, String]: Additional "key": "value" environment variables to set for rustc. | +| srcs | depset[File]: All source Files that are part of the crate. | +| type | str: The type of this crate (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)). | +| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate attribute) | + + + + +## DepInfo + +
+DepInfo(dep_env, direct_crates, transitive_build_infos, transitive_crates, transitive_libs,
+        transitive_noncrates)
+
+ +A provider containing information about a Crate's dependencies. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| dep_env | File: File with environment variables direct dependencies build scripts rely upon. | +| direct_crates | depset[AliasableDepInfo] | +| transitive_build_infos | depset[BuildInfo] | +| transitive_crates | depset[CrateInfo] | +| transitive_libs | List[File]: All transitive dependencies, not filtered by type. | +| transitive_noncrates | depset[LinkerInput]: All transitive dependencies that aren't crates. | + + + + +## StdLibInfo + +
+StdLibInfo(alloc_files, between_alloc_and_core_files, between_core_and_std_files, core_files,
+           dot_a_files, self_contained_files, srcs, std_files, std_rlibs)
+
+ +A collection of files either found within the `rust-stdlib` artifact or generated based on existing files. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| alloc_files | List[File]: .a files related to the alloc module. | +| between_alloc_and_core_files | List[File]: .a files related to the compiler_builtins module. | +| between_core_and_std_files | List[File]: .a files related to all modules except adler, alloc, compiler_builtins, core, and std. | +| core_files | List[File]: .a files related to the core and adler modules | +| dot_a_files | Depset[File]: Generated .a files | +| self_contained_files | List[File]: All .o files from the self-contained directory. | +| srcs | List[Target]: The original src attribute. | +| std_files | Depset[File]: .a files associated with the std module. | +| std_rlibs | List[File]: All .rlib files | + + ## cargo_build_script diff --git a/docs/providers.md b/docs/providers.md new file mode 100644 index 0000000000..de0222d462 --- /dev/null +++ b/docs/providers.md @@ -0,0 +1,89 @@ + +# Providers + +* [CrateInfo](#CrateInfo) +* [DepInfo](#DepInfo) +* [StdLibInfo](#StdLibInfo) + + + +## CrateInfo + +
+CrateInfo(aliases, compile_data, deps, edition, is_test, name, output, proc_macro_deps, root,
+          rustc_env, srcs, type, wrapped_crate_type)
+
+ +A provider containing general Crate information. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| aliases | Dict[Label, String]: Renamed and aliased crates | +| compile_data | depset[File]: Compile data required by this crate. | +| deps | depset[Provider]: This crate's (rust or cc) dependencies' providers. | +| edition | str: The edition of this crate. | +| is_test | bool: If the crate is being compiled in a test context | +| name | str: The name of this crate. | +| output | File: The output File that will be produced, depends on crate type. | +| proc_macro_deps | depset[CrateInfo]: This crate's rust proc_macro dependencies' providers. | +| root | File: The source File entrypoint to this crate, eg. lib.rs | +| rustc_env | Dict[String, String]: Additional "key": "value" environment variables to set for rustc. | +| srcs | depset[File]: All source Files that are part of the crate. | +| type | str: The type of this crate (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)). | +| wrapped_crate_type | str, optional: The original crate type for targets generated using a previously defined crate (typically tests using the rust_test::crate attribute) | + + + + +## DepInfo + +
+DepInfo(dep_env, direct_crates, transitive_build_infos, transitive_crates, transitive_libs,
+        transitive_noncrates)
+
+ +A provider containing information about a Crate's dependencies. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| dep_env | File: File with environment variables direct dependencies build scripts rely upon. | +| direct_crates | depset[AliasableDepInfo] | +| transitive_build_infos | depset[BuildInfo] | +| transitive_crates | depset[CrateInfo] | +| transitive_libs | List[File]: All transitive dependencies, not filtered by type. | +| transitive_noncrates | depset[LinkerInput]: All transitive dependencies that aren't crates. | + + + + +## StdLibInfo + +
+StdLibInfo(alloc_files, between_alloc_and_core_files, between_core_and_std_files, core_files,
+           dot_a_files, self_contained_files, srcs, std_files, std_rlibs)
+
+ +A collection of files either found within the `rust-stdlib` artifact or generated based on existing files. + +**FIELDS** + + +| Name | Description | +| :------------- | :------------- | +| alloc_files | List[File]: .a files related to the alloc module. | +| between_alloc_and_core_files | List[File]: .a files related to the compiler_builtins module. | +| between_core_and_std_files | List[File]: .a files related to all modules except adler, alloc, compiler_builtins, core, and std. | +| core_files | List[File]: .a files related to the core and adler modules | +| dot_a_files | Depset[File]: Generated .a files | +| self_contained_files | List[File]: All .o files from the self-contained directory. | +| srcs | List[Target]: The original src attribute. | +| std_files | Depset[File]: .a files associated with the std module. | +| std_rlibs | List[File]: All .rlib files | + +