When a directory created dy ctx.actions.declare_directory is referred to in a sandbox, if it is empty, or a subdirectory of it is empty, the empty directory won't be created in the sandbox. These functions resolve the problem by also recording the directory structure in a text file.

directory_with_structure.files

Return the list of declared File objects in a directory_with_structure.

PARAMETERS

NameDescriptionDefault Value
directory_with_structure - none

directory_with_structure.isinstance

PARAMETERS

NameDescriptionDefault Value
obj - none

directory_with_structure.make

The replacement of ctx.actions.declare_directory that also preserves empty directories.

Return a struct with the following fields: - directory: A File object from ctx.actions.declare_directory. - structure_file: A File object that will the directory structure.

PARAMETERS

NameDescriptionDefault Value
ctxctxnone
filenameSee ctx.actions.declare_directory.none

directory_with_structure.record

Return a command that records the directory structure to the structure_file.

It is expected that the shell has properly set up hermetic tools.

PARAMETERS

NameDescriptionDefault Value
directory_with_structurestruct returned by directory_with_structure.declare.none

directory_with_structure.restore

Return a command that restores a directory_with_structure.

It is expected that the shell has properly set up hermetic tools.

PARAMETERS

NameDescriptionDefault Value
directory_with_structurestruct returned by declare_directory_with_structure.none
dsta string containing the path to the destination directory.none
optionsa string containing options to rsync. If None, default to "-a".None