diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml index 60131d4b11..9a73cbfd9e 100644 --- a/.bazelci/presubmit.yml +++ b/.bazelci/presubmit.yml @@ -149,13 +149,13 @@ tasks: bazel: "rolling" ubuntu1804: name: "Min Bazel Version" - bazel: "4.0.0" + bazel: "5.0.0" platform: ubuntu1804 build_targets: *default_linux_targets test_targets: *default_linux_targets ubuntu1804_with_aspects: name: "Min Bazel Version With Aspects" - bazel: "4.0.0" + bazel: "5.0.0" platform: ubuntu1804 build_targets: *default_linux_targets test_targets: *default_linux_targets diff --git a/BUILD.bazel b/BUILD.bazel index 260db43d26..465de6d196 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -51,7 +51,7 @@ clippy_flags( # to that target. This can be useful for passing build-wide options such as LTO. extra_rustc_flags( name = "extra_rustc_flags", - build_setting_default = [], + build_setting_default = "", visibility = ["//visibility:public"], ) @@ -61,7 +61,7 @@ extra_rustc_flags( # to that target. This can be useful for passing build-wide options such as LTO. extra_exec_rustc_flags( name = "extra_exec_rustc_flags", - build_setting_default = [], + build_setting_default = "", visibility = ["//visibility:public"], ) diff --git a/docs/defs.md b/docs/defs.md index 342aed7b27..0a5bc7ae94 100644 --- a/docs/defs.md +++ b/docs/defs.md @@ -56,7 +56,7 @@ Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-argumen extra_rustc_flags(name) -Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration. +Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration. Accept comma separated strings and multiple uses of this flag are accumulated. **ATTRIBUTES** diff --git a/docs/flatten.md b/docs/flatten.md index 6e19208c22..b43e701aed 100644 --- a/docs/flatten.md +++ b/docs/flatten.md @@ -129,7 +129,7 @@ Change the [--error-format](https://doc.rust-lang.org/rustc/command-line-argumen extra_rustc_flags(name) -Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration. +Add additional rustc_flags from the command line with `--@rules_rust//:extra_rustc_flags`. This flag should only be used for flags that need to be applied across the entire build. For options that apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration. Accept comma separated strings and multiple uses of this flag are accumulated. **ATTRIBUTES** diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index d48adfb27e..8adbd0e0a0 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -1493,7 +1493,10 @@ error_format = rule( ) def _extra_rustc_flags_impl(ctx): - return ExtraRustcFlagsInfo(extra_rustc_flags = ctx.build_setting_value) + extra_rustc_flags = [] + for flags in [flags.split(",") for flags in ctx.build_setting_value if flags != ""]: + extra_rustc_flags.extend(flags) + return ExtraRustcFlagsInfo(extra_rustc_flags = extra_rustc_flags) extra_rustc_flags = rule( doc = ( @@ -1501,21 +1504,26 @@ extra_rustc_flags = rule( "This flag should only be used for flags that need to be applied across the entire build. For options that " + "apply to individual crates, use the rustc_flags attribute on the individual crate's rule instead. NOTE: " + "These flags not applied to the exec configuration (proc-macros, cargo_build_script, etc); " + - "use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration." + "use `--@rules_rust//:extra_exec_rustc_flags` to apply flags to the exec configuration. " + + "Accept comma separated strings and multiple uses of this flag are accumulated." ), implementation = _extra_rustc_flags_impl, - build_setting = config.string_list(flag = True), + build_setting = config.string(flag = True, allow_multiple = True), ) def _extra_exec_rustc_flags_impl(ctx): - return ExtraExecRustcFlagsInfo(extra_exec_rustc_flags = ctx.build_setting_value) + extra_exec_rustc_flags = [] + for flags in [flags.split(",") for flags in ctx.build_setting_value if flags != ""]: + extra_exec_rustc_flags.extend(flags) + return ExtraExecRustcFlagsInfo(extra_exec_rustc_flags = extra_exec_rustc_flags) extra_exec_rustc_flags = rule( doc = ( "Add additional rustc_flags in the exec configuration from the command line with `--@rules_rust//:extra_exec_rustc_flags`. " + "This flag should only be used for flags that need to be applied across the entire build. " + - "These flags only apply to the exec configuration (proc-macros, cargo_build_script, etc)." + "These flags only apply to the exec configuration (proc-macros, cargo_build_script, etc). " + + "Accept comma separated strings and multiple uses of this flag are accumulated." ), implementation = _extra_exec_rustc_flags_impl, - build_setting = config.string_list(flag = True), + build_setting = config.string(flag = True, allow_multiple = True), )