Skip to content

Commit 426188c

Browse files
oquenchilcopybara-github
authored andcommitted
Fix runfiles in cc_shared_library
5ad403b fixed a key part which was to actually add the precompiled libraries to the runfiles provider. There was a test but this used a cc_binary which gave the false sense of things working correctly since the cc_binary is able to get the runfiles from the CcInfo and add it itself. Changed test to use a py_test instead. RELNOTES:none PiperOrigin-RevId: 433179855
1 parent 2ee79b8 commit 426188c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

src/main/starlark/builtins_bzl/common/cc/experimental_cc_shared_library.bzl

+2
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ def _cc_shared_library_impl(ctx):
505505
if precompiled_dynamic_library.resolved_symlink_dynamic_library != None:
506506
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.resolved_symlink_dynamic_library)
507507

508+
runfiles = runfiles.merge(ctx.runfiles(files = precompiled_only_dynamic_libraries_runfiles))
509+
508510
for export in ctx.attr.roots:
509511
exports[str(export.label)] = True
510512

src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/BUILD.builtin_test

+7-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ package(
88
default_visibility = ["//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:__subpackages__"],
99
)
1010

11+
py_test(
12+
name = "python_test",
13+
srcs = ["python_test.py"],
14+
data = ["foo_so"],
15+
)
16+
1117
cc_test(
1218
name = "cc_test",
1319
srcs = ["main.cc"],
@@ -371,7 +377,7 @@ debug_files_test(
371377

372378
runfiles_test(
373379
name = "runfiles_test",
374-
target_under_test = ":binary",
380+
target_under_test = ":python_test",
375381
is_linux = select({
376382
"//src/conditions:linux": True,
377383
"//conditions:default": False}),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2022 The Bazel Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.

src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library/starlark_tests.bzl

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def _runfiles_test_impl(ctx):
157157
for runfile in target_under_test[DefaultInfo].default_runfiles.files.to_list():
158158
actual_files.append(runfile.basename)
159159
expected = [
160-
"libfoo_so.so",
161-
"libbar_so.so",
160+
"renamed_so_file_copy.so",
161+
"libdirect_so_file.so",
162162
]
163163
for expected_file in expected:
164164
asserts.true(env, expected_file in actual_files, expected_file + " not found in actual files:\n" + "\n".join(actual_files))

0 commit comments

Comments
 (0)