bazel: incompatible_disallow_struct_provider_syntax: disallow rule implementation functions returning struct
Flag: --incompatible_disallow_struct_provider_syntax Available since: 0.23 (February 2019 release)
Motivation The motivation for this change is described in #6241
Migration Rule implementation functions should return a collection of provider instances instead of a struct
# Before
def _rule_impl(ctx):
return struct(
foo_info = struct(foo = ‘foo’),
bar_info = struct(bar = ‘bar’),
)
my_rule = rule(implementation = _rule_impl)
# After
FooInfo = provider()
BarInfo = provider()
def _rule_impl(ctx):
return [FooInfo(foo = ‘foo’), BarInfo(bar = ‘bar’)]
my_rule = rule(implementation = _rule_impl)
One corner case to note is specifying files for coverage. This used
to be done with the hardcoded struct field instrumented_files
, but should
now be done by using coverage_common.instrumented_files_info()
. For example:
# Before
def rule_impl(ctx):
return struct(
instrumented_files = struct(
source_attributes = ["srcs"],
dependency_attributes = ["deps", "image"],
extensions = ["js"],
),
)
my_rule = rule(implementation = _rule_impl)
# After
def rule_impl(ctx):
my_coverage_info = coverage_common.instrumented_files_info(
ctx,
source_attributes = ["srcs"],
dependency_attributes = ["deps", "image"],
extensions = ["js"])
return [my_coverage_info]
my_rule = rule(implementation = _rule_impl)
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 1
- Comments: 26 (24 by maintainers)
Commits related to this issue
- Disallow rule implementation functions to return a struct Such functions should return a list of providers instead. This change represents a deprecation of the "old" syntax. This is an incompatible ... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Migrate to new code coverage provider This fixes an incompatible change detailed here: https://github.com/bazelbuild/bazel/issues/7347 This relies on bazel 0.23.0 — committed to keith/rules_swift by keith 5 years ago
- Migrate to new code coverage provider This fixes an incompatible change detailed here: https://github.com/bazelbuild/bazel/issues/7347 This relies on bazel 0.23.0 — committed to keith/rules_apple by keith 5 years ago
- Release 0.23.0 (2019-02-26) Baseline: 441fd75d0047f8a998d784c557736ab9075db893 Cherry picks: + 6ca7763669728253606578a56a205bca3ea883e9: Fix a typo + 2310b1c2c8b2f32db238f667747e7d567248... — committed to bazelbuild/bazel by a-googler 5 years ago
- Migrate to new code coverage provider This fixes an incompatible change detailed here: https://github.com/bazelbuild/bazel/issues/7347 This relies on bazel 0.23.0 Closes #145. RELNOTES: None. Pipe... — committed to bazelbuild/rules_swift by keith 5 years ago
- Migrate to new code coverage provider This fixes an incompatible change detailed here: https://github.com/bazelbuild/bazel/issues/7347 This relies on bazel 0.23.0 — committed to keith/rules_apple by keith 5 years ago
- Migrate to new code coverage provider This fixes an incompatible change detailed here: https://github.com/bazelbuild/bazel/issues/7347 This relies on bazel 0.23.0 Closes #145. RELNOTES: None. Pipe... — committed to bazelbuild/rules_swift by keith 5 years ago
- Don't return structs from rule implementations https://github.com/bazelbuild/bazel/issues/7347 The `return struct(...)` form will be removed in a future Bazel version. This doesn't completely fix th... — committed to googlecloudrobotics/core by drigz 5 years ago
- Fix simple bazel build_rules cases of rules returning struct This is a migration step toward #7347 , so that Starlark rule implementation functions no longer return struct. Not all usages are migrate... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Remove "return struct" in rule implementation of some Bazel tests This makes the affected tests compatible with --incompatible_disallow_struct_provider_syntax Progress toward #7347. RELNOTES: None.... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Remove "return struct" in rule implementation of some Bazel tests (#2) This makes the affected tests compatible with --incompatible_disallow_struct_provider_syntax Progress toward #7347. RELNOTES: ... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Remove "return struct" in rule implementation of some Bazel tests (#3) This makes the affected tests compatible with --incompatible_disallow_struct_provider_syntax Progress toward #7347. RELNOTES: ... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Make part of @bazel_tools compatible with --incompatible_disallow_struct_provider_syntax Fix xcode_version_flag.bzl without incompatible change. Fix java_rules_skylark with a potentially incompatible... — committed to bazelbuild/bazel by c-parsons 5 years ago
- Fix a number of tests to reflect --incompatible_disallow_struct_provider_syntax Progress toward #7347. RELNOTES: None. PiperOrigin-RevId: 244944878 — committed to bazelbuild/bazel by c-parsons 5 years ago
- Fix a number of tests to reflect --incompatible_disallow_struct_provider_syntax Progress toward #7347. RELNOTES: None. PiperOrigin-RevId: 244944878 — committed to bazelbuild/bazel by c-parsons 5 years ago
- Bazel: Make build tool chain forward compatible Disallow rule implementation functions to return struct, and return a collection of provider instances instead. See this upstream issue for more detail... — committed to qtqa/gerrit by davido 5 years ago
- Bazel: Make build tool chain forward compatible Disallow rule implementation functions to return struct, and return a collection of provider instances instead. See this upstream issue for more detail... — committed to GerritCodeReview/bazlets by davido 5 years ago
- Refactor the files and runfiles fields from strings to the DefaultInfo() provider. This is the beginning of removing the legacy providers, per https://github.com/bazelbuild/bazel/issues/7347 See htt... — committed to bazelbuild/rules_typescript by alexeagle 5 years ago
- Refactor the "output_groups" string to the OutputGroupInfo() provider. This is the beginning of removing the legacy providers, per https://github.com/bazelbuild/bazel/issues/7347 See https://docs.ba... — committed to bazelbuild/rules_typescript by alexeagle 5 years ago
- Provide DeclarationInfo that replaces two fields from "typescript" legacy provider This is the part of removing the legacy providers, per https://github.com/bazelbuild/bazel/issues/7347 Depends on h... — committed to bazelbuild/rules_typescript by alexeagle 5 years ago
Hello,
Apologies that this issue fell off my radar.
Re: Coverage: https://docs.bazel.build/versions/master/skylark/rules.html#code-coverage-instrumentation You should now be able to use this for modern coverage-related provider.
Re: java_toolchain_alias.bzl: I’ll look into getting this fixed.
Re: incompatible flag, and
--all_incompatible_changes
, I would suggest you use the workaround you’ve mentioned,--all_incompatible_changes --incompatible_disallow_struct_provider_syntax=false
, if you are blocked on the latter flag. It’s not ideal, but we generally don’t have infrastructure for removing--incompatible_
flags from theall_incompatible_changes
set. The far better approach here would be to resolve any blockers ofincompatible_disallow_struct_provider_syntax
.We’ve had some debate and discussion on the priority of this particular item. We’ve agreed that we will need to introduce another flag to couple with this one to aid in migration, and we plan on introducing this flag before 1.0