Skip to content
Merged
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
9 changes: 7 additions & 2 deletions pkg/private/pkg_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,13 @@ def add_from_default_info(
# Computing the runfiles root is subtle. It should be based off of
# the executable, but that is not always obvious. When in doubt,
# the first file of DefaultInfo.files should be the right target.
base_file = the_executable or all_files[0]
base_file_path = dest_path(base_file, data_path, data_path_without_prefix)
# If there are no files, these are just runfiles / data dependencies,
# just package them in ".runfiles".
base_file_path = ""
if the_executable != None:
base_file_path = dest_path(the_executable, data_path, data_path_without_prefix)
elif len(all_files) > 0:
base_file_path = dest_path(all_files[0], data_path, data_path_without_prefix)
base_root_path = base_file_path + ".runfiles"
base_path = base_root_path + "/" + workspace_name

Expand Down
9 changes: 9 additions & 0 deletions tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ filegroup(
srcs = glob(["**/*.txt"]),
)

filegroup(
name = "data_filegroup",
data = [
"testdata/hello.txt",
"testdata/loremipsum.txt",
],
visibility = ["//visibility:public"],
)

#
# Data source for Unicode handling tests
#
Expand Down
17 changes: 17 additions & 0 deletions tests/tar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,23 @@ verify_archive_test(
target = ":test-tar-with-runfiles",
)

pkg_tar(
name = "test-tar-with-only-runfiles",
srcs = [
"//tests:data_filegroup",
],
include_runfiles = True,
)

verify_archive_test(
name = "runfiles_only_test",
must_contain = [
".runfiles/_main/tests/testdata/loremipsum.txt",
".runfiles/_main/tests/testdata/hello.txt",
],
target = ":test-tar-with-only-runfiles",
)

pkg_tar(
name = "test-tar-remap-runfiles-base-path",
srcs = [
Expand Down
Loading