Skip to content

Commit

Permalink
Change rationale for manually looking for CcInfo
Browse files Browse the repository at this point in the history
We have to skip targets not providing CcInfo not just because of
incompatible targets in old Bazel versions, but also due to bug:
bazelbuild/bazel#19609

Given incompatible targets for aspects have been fixed in recent Bazel
versions and the bug above has just been discovered, it makes no sense
to keep mentioning incompatible targets as when above bug is fixed and we
can remove this manual check for CcInfo incompatible targets are no longer
relevant either way.
  • Loading branch information
martis42 committed Sep 25, 2023
1 parent b2b8f50 commit 00ba581
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/aspect/dwyu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,16 @@ def dwyu_aspect_impl(target, ctx):
Returns:
OutputGroup containing the generated report file
"""
if not ctx.rule.kind in ["cc_binary", "cc_library", "cc_test"]:
return []

# Skip incompatible targets
# Ideally we should check for the existence of "IncompatiblePlatformProvider".
# However, this provider is not available in Starlark
# DWYU is only able to work on targets providing CcInfo. Other targets shall be skipped.
# We can't use 'required_providers = [CcInfo],' in the aspect definition due to bug:
# https://github.com/bazelbuild/bazel/issues/19609
if not CcInfo in target:
return []

if not ctx.rule.kind in ["cc_binary", "cc_library", "cc_test"]:
return []

# Skip targets which explicitly opt-out
if "no-dwyu" in ctx.rule.attr.tags:
return []
Expand Down
2 changes: 1 addition & 1 deletion src/aspect/factory.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def dwyu_aspect_factory(
Args:
config: Configuration file for the tool comparing the include statements to the dependencies.
recursive: If true, execute the aspect on all trannsitive dependencies.
recursive: If true, execute the aspect on all transitive dependencies.
If false, analyze only the target the aspect is being executed on.
use_implementation_deps: If true, ensure cc_library dependencies which are used only in private files are
listed in implementation_deps. Only available for Bazel >= 5.0.0 and if flag
Expand Down

0 comments on commit 00ba581

Please sign in to comment.