Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect implementation_deps in compilation_context #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FBorowiec
Copy link

Hi! First of all thanks for the great tool :)
Combined with martis42/depend_on_what_you_use it's the best solution for removing transitive dependencies.

The depend_on_what_you_use (DWYU) tool does the same thing as IWYU but at a BUILD file level.
However, using the fix-all option of that tool does differentiate between regular deps and implementation_deps (bazel.build/c-cpp#cc_library_arg -> implementation_deps).

To make bazel_iwyu recognize the dependencies under implementation_deps, could you review this PR adding the implementation_deps to the CcInfo context of the target?

References:

compilation_context = target[CcInfo].compilation_context
cc_infos = [target[CcInfo]] + _collect_cc_info(ctx)
merged_cc_info = cc_common.merge_cc_infos(cc_infos = cc_infos)
compilation_context = merged_cc_info.compilation_context
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for dep in ctx.rule.attr.deps:
if CcInfo in dep:
cc_infos.append(dep[CcInfo])
if hasattr(ctx.rule.attr, "implementation_deps"):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

before_each = "-Xiwyu",
)

args.add_all(["--mapping_file={}".format(m.path) for m in iwyu_mappings], before_each = "-Xiwyu")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autoformatted by latest buildifier

@@ -95,7 +104,6 @@ def _toolchain_flags(ctx, is_cpp_target):
unsupported_features = ctx.disabled_features,
)

flags = None
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused assignment of flags

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant