Skip to content

Commit

Permalink
[6.4.0] cc_library: propagate data dependencies via implementation_de…
Browse files Browse the repository at this point in the history
…ps. (#19590)

Cherry pick 56e9020 from #18416

Commit 56e9020
Co-authored-by: Yuval Kaplan <yuval@engflow.com>
  • Loading branch information
jlaxson authored Sep 25, 2023
1 parent 65e5c37 commit 8776b3d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/starlark/builtins_bzl/common/cc/cc_library.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def _cc_library_impl(ctx):
for dep in ctx.attr.deps:
runfiles_list.append(dep[DefaultInfo].default_runfiles)

for dep in ctx.attr.implementation_deps:
runfiles_list.append(dep[DefaultInfo].default_runfiles)

runfiles = ctx.runfiles().merge_all(runfiles_list)

default_runfiles = ctx.runfiles(files = cc_helper.get_dynamic_libraries_for_runtime(linking_context_for_runfiles, True))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2004,6 +2004,44 @@ public void testImplementationDepsLinkingContextIsPropagated() throws Exception
.contains("bin foo/libimplementation_dep.a");
}

@Test
public void testImplementationDepsRunfilesArePropagated() throws Exception {
useConfiguration("--experimental_cc_implementation_deps");
scratch.file(
"foo/BUILD",
"cc_binary(",
" name = 'bin',",
" srcs = ['bin.cc'],",
" deps = ['lib'],",
")",
"cc_library(",
" name = 'lib',",
" srcs = ['lib.cc'],",
" deps = ['public_dep'],",
")",
"cc_library(",
" name = 'public_dep',",
" srcs = ['public_dep.cc'],",
" hdrs = ['public_dep.h'],",
" implementation_deps = ['implementation_dep'],",
" deps = ['interface_dep'],",
")",
"cc_library(",
" name = 'interface_dep',",
" data = ['data/interface.txt'],",
")",
"cc_library(",
" name = 'implementation_dep',",
" data = ['data/implementation.txt'],",
")");

ConfiguredTarget lib = getConfiguredTarget("//foo:bin");
assertThat(
artifactsToStrings(
lib.get(DefaultInfo.PROVIDER).getDefaultRunfiles().getAllArtifacts()))
.containsAtLeast("src foo/data/interface.txt", "src foo/data/implementation.txt");
}

@Test
public void testImplementationDepsConfigurationHostSucceeds() throws Exception {
useConfiguration("--experimental_cc_implementation_deps");
Expand Down

0 comments on commit 8776b3d

Please sign in to comment.