Skip to content

Commit

Permalink
Fix runfiles in cc_shared_library
Browse files Browse the repository at this point in the history
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
  • Loading branch information
oquenchil authored and copybara-github committed Mar 8, 2022
1 parent 2ee79b8 commit 426188c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,8 @@ def _cc_shared_library_impl(ctx):
if precompiled_dynamic_library.resolved_symlink_dynamic_library != None:
precompiled_only_dynamic_libraries_runfiles.append(precompiled_dynamic_library.resolved_symlink_dynamic_library)

runfiles = runfiles.merge(ctx.runfiles(files = precompiled_only_dynamic_libraries_runfiles))

for export in ctx.attr.roots:
exports[str(export.label)] = True

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ package(
default_visibility = ["//src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test_cc_shared_library:__subpackages__"],
)

py_test(
name = "python_test",
srcs = ["python_test.py"],
data = ["foo_so"],
)

cc_test(
name = "cc_test",
srcs = ["main.cc"],
Expand Down Expand Up @@ -371,7 +377,7 @@ debug_files_test(

runfiles_test(
name = "runfiles_test",
target_under_test = ":binary",
target_under_test = ":python_test",
is_linux = select({
"//src/conditions:linux": True,
"//conditions:default": False}),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2022 The Bazel Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def _runfiles_test_impl(ctx):
for runfile in target_under_test[DefaultInfo].default_runfiles.files.to_list():
actual_files.append(runfile.basename)
expected = [
"libfoo_so.so",
"libbar_so.so",
"renamed_so_file_copy.so",
"libdirect_so_file.so",
]
for expected_file in expected:
asserts.true(env, expected_file in actual_files, expected_file + " not found in actual files:\n" + "\n".join(actual_files))
Expand Down

0 comments on commit 426188c

Please sign in to comment.