Skip to content
Open
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
2 changes: 2 additions & 0 deletions cc/private/rules_impl/cc_shared_library_impl.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ def _cc_shared_library_impl(ctx):
runfiles = ctx.runfiles(
files = runfiles_files,
)
for dep in ctx.attr.deps:
runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles)
for dep in ctx.attr.dynamic_deps:
runfiles = runfiles.merge(dep[DefaultInfo].data_runfiles)

Expand Down
3 changes: 3 additions & 0 deletions tests/cc/common/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
load(":cc_binary_configured_target_tests.bzl", "cc_binary_configured_target_tests")
load(":cc_common_test.bzl", "cc_common_tests")
load(":cc_shared_library_configured_target_tests.bzl", "cc_shared_library_configured_target_tests")

cc_binary_configured_target_tests(name = "cc_binary_configured_target_tests")

cc_common_tests(name = "cc_common_tests")

cc_shared_library_configured_target_tests(name = "cc_shared_library_configured_target_tests")
44 changes: 44 additions & 0 deletions tests/cc/common/cc_shared_library_configured_target_tests.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"""Tests for cc_shared_library."""

load("@bazel_features//:features.bzl", "bazel_features")
load("@rules_testing//lib:analysis_test.bzl", "test_suite")
load("@rules_testing//lib:truth.bzl", "matching")
load("@rules_testing//lib:util.bzl", "util")
load("//cc:cc_library.bzl", "cc_library")
load("//cc:cc_shared_library.bzl", "cc_shared_library")
load("//tests/cc/testutil:cc_analysis_test.bzl", "cc_analysis_test")

def _test_runfiles(name, **kwargs):
util.helper_target(
cc_shared_library,
name = name + "/runfiles/0",
deps = [name + "/runfiles/1"],
)
file1 = util.empty_file(name = name + "/runfiles/file1")
util.helper_target(
cc_library,
name = name + "/runfiles/1",
data = [file1],
)
cc_analysis_test(
name = name,
impl = _test_runfiles_impl,
target = name + "/runfiles/0",
**kwargs
)

def _test_runfiles_impl(env, target):
env.expect.that_target(target).data_runfiles().contains_predicate(
matching.str_endswith("lib0.so"),
)
env.expect.that_target(target).data_runfiles().contains_predicate(
matching.str_endswith("file1"),
)

def cc_shared_library_configured_target_tests(name):
test_suite(
name = name,
tests = [
_test_runfiles,
] if bazel_features.cc.cc_common_is_in_rules_cc else [],
)