Skip to content

Commit c8be082

Browse files
committed
Fix target_mapping not working with implementation_deps
1 parent 155fd63 commit c8be082

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/aspect/dwyu.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,14 @@ def _exchange_cc_info(deps, mapping):
135135
def _preprocess_deps(ctx):
136136
"""
137137
Normally this function does nothing and simply stores dependencies and their CcInfo providers in a specific format.
138-
If the user chooses to use the target mapping feature, we exchange here the CcInf provider for some targets with a
138+
If the user chooses to use the target mapping feature, we exchange here the CcInfo provider for some targets with a
139139
different one.
140140
"""
141141
target_impl_deps = []
142142
if ctx.attr._target_mapping:
143143
target_deps = _exchange_cc_info(deps = ctx.rule.attr.deps, mapping = ctx.attr._target_mapping)
144144
if hasattr(ctx.rule.attr, "implementation_deps"):
145-
pass
145+
target_impl_deps = _exchange_cc_info(deps = ctx.rule.attr.implementation_deps, mapping = ctx.attr._target_mapping)
146146
else:
147147
target_deps = [struct(label = dep.label, cc_info = dep[CcInfo]) for dep in ctx.rule.attr.deps]
148148
if hasattr(ctx.rule.attr, "implementation_deps"):

test/aspect/target_mapping/BUILD

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,9 @@ cc_binary(
99
srcs = ["use_lib_c.cpp"],
1010
deps = ["//target_mapping/libs:a"],
1111
)
12+
13+
cc_library(
14+
name = "use_lib_b_privately",
15+
srcs = ["use_lib_b.cpp"],
16+
implementation_deps = ["//target_mapping/libs:a"],
17+
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from result import ExpectedResult, Result
2+
from test_case import TestCaseBase
3+
4+
5+
class TestCase(TestCaseBase):
6+
def execute_test_logic(self) -> Result:
7+
expected = ExpectedResult(success=True)
8+
actual = self._run_dwyu(
9+
target="//target_mapping:use_lib_b_privately",
10+
aspect="//target_mapping:aspect.bzl%map_specific_deps",
11+
extra_args=["--experimental_cc_implementation_deps"],
12+
)
13+
14+
return self._check_result(actual=actual, expected=expected)

0 commit comments

Comments
 (0)