diff --git a/WORKSPACE.bazel b/WORKSPACE.bazel index da5117c9c4..d03f6d6d2d 100644 --- a/WORKSPACE.bazel +++ b/WORKSPACE.bazel @@ -2,7 +2,7 @@ workspace(name = "rules_rust") load("@rules_rust//rust:repositories.bzl", "rust_repositories") -rust_repositories(include_rustc_src = True) +rust_repositories(include_rustc_srcs = True) load("@rules_rust//proto:repositories.bzl", "rust_proto_repositories") diff --git a/docs/flatten.md b/docs/flatten.md index ea5766fa90..7761f79d54 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -1067,7 +1067,7 @@ Run the test with `bazel build //hello_lib:hello_lib_test`.
 rust_toolchain(name, allocator_library, binary_ext, cargo, clippy_driver, debug_info,
                default_edition, dylib_ext, exec_triple, opt_level, os, rust_doc, rust_lib, rustc,
-               rustc_lib, rustc_src, rustfmt, staticlib_ext, stdlib_linkflags, target_triple)
+               rustc_lib, rustc_srcs, rustfmt, staticlib_ext, stdlib_linkflags, target_triple)
 
Declares a Rust toolchain for use. @@ -1131,7 +1131,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r | rust_lib | The rust standard library. | Label | optional | None | | rustc | The location of the rustc binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | rustc_lib | The libraries used by rustc during compilation. | Label | optional | None | -| rustc_src | The source code of rustc. | Label | optional | None | +| rustc_srcs | The source code of rustc. | Label | optional | None | | rustfmt | The location of the rustfmt binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | staticlib_ext | The extension for static libraries created from rustc. | String | required | | | stdlib_linkflags | Additional linker libs used when std lib is linked, see https://github.com/rust-lang/rust/blob/master/src/libstd/build.rs | List of strings | required | | @@ -1144,7 +1144,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
 rust_toolchain_repository(name, dev_components, edition, exec_triple, extra_target_triples,
-                          include_rustc_src, iso_date, repo_mapping, rustfmt_version, sha256s,
+                          include_rustc_srcs, iso_date, repo_mapping, rustfmt_version, sha256s,
                           toolchain_name_prefix, urls, version)
 
@@ -1162,7 +1162,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito | edition | The rust edition to be used by default. | String | optional | "2015" | | exec_triple | The Rust-style target that this compiler runs on | String | required | | | extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] | -| include_rustc_src | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. | Boolean | optional | False | +| include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. | Boolean | optional | False | | iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" | | repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | | | rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" | @@ -1533,7 +1533,7 @@ Declare dependencies needed for proto compilation.
 rust_repositories(version, iso_date, rustfmt_version, edition, dev_components, sha256s,
-                  include_rustc_src, urls)
+                  include_rustc_srcs, urls)
 
Emits a default set of toolchains for Linux, MacOS, and Freebsd @@ -1564,7 +1564,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai | edition | The rust edition to be used by default (2015 (default) or 2018) | None | | dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | False | | sha256s | A dict associating tool subdirectories to sha256 hashes. Defaults to None. | None | -| include_rustc_src | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | +| include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | | urls | A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | ["https://static.rust-lang.org/dist/{}.tar.gz"] | @@ -1573,7 +1573,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai ## rust_repository_set
-rust_repository_set(name, version, exec_triple, include_rustc_src, extra_target_triples, iso_date,
+rust_repository_set(name, version, exec_triple, include_rustc_srcs, extra_target_triples, iso_date,
                     rustfmt_version, edition, dev_components, sha256s, urls)
 
@@ -1590,7 +1590,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with | name | The name of the generated repository | none | | version | The version of the tool among "nightly", "beta', or an exact version. | none | | exec_triple | The Rust-style target that this compiler runs on | none | -| include_rustc_src | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | +| include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | | extra_target_triples | Additional rust-style targets that this set of toolchains should support. Defaults to []. | [] | | iso_date | The date of the tool. Defaults to None. | None | | rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | None | diff --git a/docs/rust_repositories.md b/docs/rust_repositories.md index 46adaa3309..8a9f55cca5 100644 --- a/docs/rust_repositories.md +++ b/docs/rust_repositories.md @@ -13,7 +13,7 @@
 rust_toolchain(name, allocator_library, binary_ext, cargo, clippy_driver, debug_info,
                default_edition, dylib_ext, exec_triple, opt_level, os, rust_doc, rust_lib, rustc,
-               rustc_lib, rustc_src, rustfmt, staticlib_ext, stdlib_linkflags, target_triple)
+               rustc_lib, rustc_srcs, rustfmt, staticlib_ext, stdlib_linkflags, target_triple)
 
Declares a Rust toolchain for use. @@ -77,7 +77,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r | rust_lib | The rust standard library. | Label | optional | None | | rustc | The location of the rustc binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | rustc_lib | The libraries used by rustc during compilation. | Label | optional | None | -| rustc_src | The source code of rustc. | Label | optional | None | +| rustc_srcs | The source code of rustc. | Label | optional | None | | rustfmt | The location of the rustfmt binary. Can be a direct source or a filegroup containing one item. | Label | optional | None | | staticlib_ext | The extension for static libraries created from rustc. | String | required | | | stdlib_linkflags | Additional linker libs used when std lib is linked, see https://github.com/rust-lang/rust/blob/master/src/libstd/build.rs | List of strings | required | | @@ -90,7 +90,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
 rust_toolchain_repository(name, dev_components, edition, exec_triple, extra_target_triples,
-                          include_rustc_src, iso_date, repo_mapping, rustfmt_version, sha256s,
+                          include_rustc_srcs, iso_date, repo_mapping, rustfmt_version, sha256s,
                           toolchain_name_prefix, urls, version)
 
@@ -108,7 +108,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito | edition | The rust edition to be used by default. | String | optional | "2015" | | exec_triple | The Rust-style target that this compiler runs on | String | required | | | extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] | -| include_rustc_src | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. | Boolean | optional | False | +| include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. | Boolean | optional | False | | iso_date | The date of the tool (or None, if the version is a specific version). | String | optional | "" | | repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry "@foo": "@bar" declares that, for any time this repository depends on @foo (such as a dependency on @foo//some:target, it should actually resolve that dependency within globally-declared @bar (@bar//some:target). | Dictionary: String -> String | required | | | rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | "" | @@ -148,7 +148,7 @@ Generates a toolchain-bearing repository that declares the toolchains from some
 rust_repositories(version, iso_date, rustfmt_version, edition, dev_components, sha256s,
-                  include_rustc_src, urls)
+                  include_rustc_srcs, urls)
 
Emits a default set of toolchains for Linux, MacOS, and Freebsd @@ -179,7 +179,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai | edition | The rust edition to be used by default (2015 (default) or 2018) | None | | dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | False | | sha256s | A dict associating tool subdirectories to sha256 hashes. Defaults to None. | None | -| include_rustc_src | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | +| include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | | urls | A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | ["https://static.rust-lang.org/dist/{}.tar.gz"] | @@ -188,7 +188,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai ## rust_repository_set
-rust_repository_set(name, version, exec_triple, include_rustc_src, extra_target_triples, iso_date,
+rust_repository_set(name, version, exec_triple, include_rustc_srcs, extra_target_triples, iso_date,
                     rustfmt_version, edition, dev_components, sha256s, urls)
 
@@ -205,7 +205,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with | name | The name of the generated repository | none | | version | The version of the tool among "nightly", "beta', or an exact version. | none | | exec_triple | The Rust-style target that this compiler runs on | none | -| include_rustc_src | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | +| include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. | False | | extra_target_triples | Additional rust-style targets that this set of toolchains should support. Defaults to []. | [] | | iso_date | The date of the tool. Defaults to None. | None | | rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | None | diff --git a/examples/examples_deps.bzl b/examples/examples_deps.bzl index ef9b18f471..48a5dc9534 100644 --- a/examples/examples_deps.bzl +++ b/examples/examples_deps.bzl @@ -13,7 +13,7 @@ load("@rules_rust//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_repositori def deps(): """Define dependencies for `rules_rust` examples""" - rust_repositories(include_rustc_src = True) + rust_repositories(include_rustc_srcs = True) rust_bindgen_repositories() diff --git a/rust/private/rust_analyzer.bzl b/rust/private/rust_analyzer.bzl index 350f292dcf..15156f1ae9 100644 --- a/rust/private/rust_analyzer.bzl +++ b/rust/private/rust_analyzer.bzl @@ -174,15 +174,15 @@ def create_crate(ctx, info, crate_mapping): def _rust_analyzer_impl(ctx): rust_toolchain = find_toolchain(ctx) - if not rust_toolchain.rustc_src: + if not rust_toolchain.rustc_srcs: fail( - "Current Rust toolchain doesn't contain rustc sources in `rustc_src` attribute.", + "Current Rust toolchain doesn't contain rustc sources in `rustc_srcs` attribute.", "These are needed by rust analyzer.", - "If you are using the default Rust toolchain, add `rust_repositories(include_rustc_src = True, ...).` to your WORKSPACE file.", + "If you are using the default Rust toolchain, add `rust_repositories(include_rustc_srcs = True, ...).` to your WORKSPACE file.", ) - sysroot_src = rust_toolchain.rustc_src.label.package + "/library" - if rust_toolchain.rustc_src.label.workspace_root: - sysroot_src = _exec_root_tmpl + rust_toolchain.rustc_src.label.workspace_root + "/" + sysroot_src + sysroot_src = rust_toolchain.rustc_srcs.label.package + "/library" + if rust_toolchain.rustc_srcs.label.workspace_root: + sysroot_src = _exec_root_tmpl + rust_toolchain.rustc_srcs.label.workspace_root + "/" + sysroot_src # Gather all crates and their dependencies into an array. # Dependencies are referenced by index, so leaves should come first. diff --git a/rust/repositories.bzl b/rust/repositories.bzl index 1a48e134be..a0b644ed5f 100644 --- a/rust/repositories.bzl +++ b/rust/repositories.bzl @@ -34,7 +34,7 @@ def rust_repositories( edition = None, dev_components = False, sha256s = None, - include_rustc_src = False, + include_rustc_srcs = False, urls = DEFAULT_STATIC_RUST_URL_TEMPLATES): """Emits a default set of toolchains for Linux, MacOS, and Freebsd @@ -61,7 +61,7 @@ def rust_repositories( edition (str, optional): The rust edition to be used by default (2015 (default) or 2018) dev_components (bool, optional): Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. Defaults to None. - include_rustc_src (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. + include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. urls (list, optional): A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] """ @@ -101,7 +101,7 @@ def rust_repositories( edition = edition, dev_components = dev_components, sha256s = sha256s, - include_rustc_src = include_rustc_src, + include_rustc_srcs = include_rustc_srcs, urls = urls, ) @@ -269,7 +269,7 @@ rust_toolchain( cargo = "@{workspace_name}//:cargo", clippy_driver = "@{workspace_name}//:clippy_driver_bin", rustc_lib = "@{workspace_name}//:rustc_lib", - rustc_src = {rustc_src}, + rustc_srcs = {rustc_srcs}, binary_ext = "{binary_ext}", staticlib_ext = "{staticlib_ext}", dylib_ext = "{dylib_ext}", @@ -287,7 +287,7 @@ def BUILD_for_rust_toolchain( name, exec_triple, target_triple, - include_rustc_src, + include_rustc_srcs, stdlib_linkflags = None, default_edition = "2015"): """Emits a toolchain declaration to match an existing compiler and stdlib. @@ -297,7 +297,7 @@ def BUILD_for_rust_toolchain( name (str): The name of the toolchain declaration exec_triple (str): The rust-style target that this compiler runs on target_triple (str): The rust-style target triple of the tool - include_rustc_src (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. + include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. stdlib_linkflags (list, optional): Overriden flags needed for linking to rust stdlib, akin to BAZEL_LINKLIBS. Defaults to None. @@ -310,9 +310,9 @@ def BUILD_for_rust_toolchain( if stdlib_linkflags == None: stdlib_linkflags = ", ".join(['"%s"' % x for x in system_to_stdlib_linkflags(system)]) - rustc_src = "None" - if include_rustc_src: - rustc_src = "\"@{workspace_name}//lib/rustlib/src:rustc_src\"".format(workspace_name = workspace_name) + rustc_srcs = "None" + if include_rustc_srcs: + rustc_srcs = "\"@{workspace_name}//lib/rustlib/src:rustc_srcs\"".format(workspace_name = workspace_name) return _build_file_for_rust_toolchain_template.format( toolchain_name = name, @@ -320,7 +320,7 @@ def BUILD_for_rust_toolchain( binary_ext = system_to_binary_ext(system), staticlib_ext = system_to_staticlib_ext(system), dylib_ext = system_to_dylib_ext(system), - rustc_src = rustc_src, + rustc_srcs = rustc_srcs, stdlib_linkflags = stdlib_linkflags, system = system, default_edition = default_edition, @@ -497,7 +497,7 @@ def _load_rust_src(ctx): "lib/rustlib/src/BUILD.bazel", """\ filegroup( - name = "rustc_src", + name = "rustc_srcs", srcs = glob(["**/*"]), visibility = ["//visibility:public"], )""", @@ -535,7 +535,7 @@ def _load_rust_stdlib(ctx, target_triple): target_triple = target_triple, ), exec_triple = ctx.attr.exec_triple, - include_rustc_src = ctx.attr.include_rustc_src, + include_rustc_srcs = ctx.attr.include_rustc_srcs, target_triple = target_triple, stdlib_linkflags = stdlib_linkflags, workspace_name = ctx.attr.name, @@ -586,7 +586,7 @@ def _rust_toolchain_repository_impl(ctx): _check_version_valid(ctx.attr.version, ctx.attr.iso_date) - if ctx.attr.include_rustc_src: + if ctx.attr.include_rustc_srcs: _load_rust_src(ctx) build_components = [_load_rust_compiler(ctx)] @@ -649,7 +649,7 @@ rust_toolchain_repository = repository_rule( "extra_target_triples": attr.string_list( doc = "Additional rust-style targets that this set of toolchains should support.", ), - "include_rustc_src": attr.bool( + "include_rustc_srcs": attr.bool( doc = "Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer.", default = False, ), @@ -705,7 +705,7 @@ def rust_repository_set( name, version, exec_triple, - include_rustc_src = False, + include_rustc_srcs = False, extra_target_triples = [], iso_date = None, rustfmt_version = None, @@ -723,7 +723,7 @@ def rust_repository_set( name (str): The name of the generated repository version (str): The version of the tool among "nightly", "beta', or an exact version. exec_triple (str): The Rust-style target that this compiler runs on - include_rustc_src (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. + include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support. Defaults to False. extra_target_triples (list, optional): Additional rust-style targets that this set of toolchains should support. Defaults to []. iso_date (str, optional): The date of the tool. Defaults to None. @@ -740,7 +740,7 @@ def rust_repository_set( rust_toolchain_repository( name = name, exec_triple = exec_triple, - include_rustc_src = include_rustc_src, + include_rustc_srcs = include_rustc_srcs, extra_target_triples = extra_target_triples, iso_date = iso_date, toolchain_name_prefix = DEFAULT_TOOLCHAIN_NAME_PREFIX, diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index f1385a3807..15c4792bcf 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -138,7 +138,7 @@ def _rust_toolchain_impl(ctx): cargo = ctx.file.cargo, clippy_driver = ctx.file.clippy_driver, rustc_lib = ctx.attr.rustc_lib, - rustc_src = ctx.attr.rustc_src, + rustc_srcs = ctx.attr.rustc_srcs, rust_lib = ctx.attr.rust_lib, binary_ext = ctx.attr.binary_ext, staticlib_ext = ctx.attr.staticlib_ext, @@ -222,7 +222,7 @@ rust_toolchain = rule( "rustc_lib": attr.label( doc = "The libraries used by rustc during compilation.", ), - "rustc_src": attr.label( + "rustc_srcs": attr.label( doc = "The source code of rustc.", ), "rustfmt": attr.label(