diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl index d82642cd9cf3e0..304b4baac8282b 100755 --- a/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_library.bzl @@ -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)) diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java index 050f3a8e0f0ac1..1aed4e8659c122 100644 --- a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibraryConfiguredTargetTest.java @@ -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");