diff --git a/src/aspect/dwyu.bzl b/src/aspect/dwyu.bzl index 32db0681..63a5bbbe 100644 --- a/src/aspect/dwyu.bzl +++ b/src/aspect/dwyu.bzl @@ -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 [] diff --git a/src/aspect/factory.bzl b/src/aspect/factory.bzl index 7952de04..fe669f0b 100644 --- a/src/aspect/factory.bzl +++ b/src/aspect/factory.bzl @@ -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