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

Fix target_mapping not working with implementation_deps #254

Merged
merged 1 commit into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/aspect/dwyu.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,14 @@ def _exchange_cc_info(deps, mapping):
def _preprocess_deps(ctx):
"""
Normally this function does nothing and simply stores dependencies and their CcInfo providers in a specific format.
If the user chooses to use the target mapping feature, we exchange here the CcInf provider for some targets with a
If the user chooses to use the target mapping feature, we exchange here the CcInfo provider for some targets with a
different one.
"""
target_impl_deps = []
if ctx.attr._target_mapping:
target_deps = _exchange_cc_info(deps = ctx.rule.attr.deps, mapping = ctx.attr._target_mapping)
if hasattr(ctx.rule.attr, "implementation_deps"):
pass
target_impl_deps = _exchange_cc_info(deps = ctx.rule.attr.implementation_deps, mapping = ctx.attr._target_mapping)
else:
target_deps = [struct(label = dep.label, cc_info = dep[CcInfo]) for dep in ctx.rule.attr.deps]
if hasattr(ctx.rule.attr, "implementation_deps"):
Expand Down
6 changes: 6 additions & 0 deletions test/aspect/target_mapping/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,9 @@ cc_binary(
srcs = ["use_lib_c.cpp"],
deps = ["//target_mapping/libs:a"],
)

cc_library(
name = "use_lib_b_privately",
srcs = ["use_lib_b.cpp"],
implementation_deps = ["//target_mapping/libs:a"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from result import ExpectedResult, Result
from test_case import TestCaseBase


class TestCase(TestCaseBase):
def execute_test_logic(self) -> Result:
expected = ExpectedResult(success=True)
actual = self._run_dwyu(
target="//target_mapping:use_lib_b_privately",
aspect="//target_mapping:aspect.bzl%map_specific_deps",
extra_args=["--experimental_cc_implementation_deps"],
)

return self._check_result(actual=actual, expected=expected)