Skip to content

Commit

Permalink
fix: Not all runfiles are single files
Browse files Browse the repository at this point in the history
Handle cases where the defaultInfo file is a directory
  • Loading branch information
ewianda committed Apr 22, 2024
1 parent e604010 commit 76eee63
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions pkg/private/pkg_files.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ _MappingContext = provider(
"allow_duplicates_with_different_content": "bool: don't fail when you double mapped files",
"include_runfiles": "bool: include runfiles",
"strip_prefix": "strip_prefix",

"path_mapper": "function to map destination paths",

# Defaults
Expand All @@ -94,8 +93,7 @@ def create_mapping_context_from_ctx(
strip_prefix = None,
include_runfiles = None,
default_mode = None,
path_mapper = None
):
path_mapper = None):
"""Construct a MappingContext.
Args: See the provider definition.
Expand Down Expand Up @@ -396,7 +394,8 @@ def add_from_default_info(
all_files = src[DefaultInfo].files.to_list()
for f in all_files:
d_path = mapping_context.path_mapper(
dest_path(f, data_path, data_path_without_prefix))
dest_path(f, data_path, data_path_without_prefix),
)
if f.is_directory:
add_tree_artifact(
mapping_context.content_map,
Expand Down Expand Up @@ -436,7 +435,7 @@ def add_from_default_info(
_check_dest(mapping_context.content_map, d_path, rf, src.label, mapping_context.allow_duplicates_with_different_content)
mapping_context.content_map[d_path] = _DestFile(
src = rf,
entry_type = ENTRY_IS_FILE,
entry_type = ENTRY_IS_DIR if rf.is_directory else ENTRY_IS_FILE,
origin = src.label,
mode = fmode,
user = mapping_context.default_user,
Expand Down

0 comments on commit 76eee63

Please sign in to comment.