Skip to content

Commit

Permalink
Fix target_mapping not working with implementation_deps
Browse files Browse the repository at this point in the history
  • Loading branch information
martis42 committed May 25, 2024
1 parent 155fd63 commit 8296640
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
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,13 @@
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",
)

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

0 comments on commit 8296640

Please sign in to comment.