Rule and corresponding provider that joins a label pointing to a TreeArtifact with a path nested within that directory

Rules

directory_path

Provide DirectoryPathInfo to reference some path within a directory.

Otherwise there is no way to give a Bazel label for it.

Example usage (generated)

load("@aspect_bazel_lib//lib:directory_path.bzl", "directory_path")

directory_path(
    # A unique name for this target.
    name = "",
    # a TreeArtifact (ctx.actions.declare_directory)
    directory = "",
    # path relative to the directory
    path = "",
)

name

A unique name for this target.

directory

a TreeArtifact (ctx.actions.declare_directory)

path

path relative to the directory


Macros and Functions

make_directory_path

Helper function to generate a directory_path target and return its label.

Example usage (generated)

load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path")

make_directory_path(
    # unique name for the generated `directory_path` target
    name = "",
    # `directory` attribute passed to generated `directory_path` target
    directory = None,
    # `path` attribute passed to generated `directory_path` target
    path = None,
)

name

unique name for the generated directory_path target

directory

directory attribute passed to generated directory_path target

path

path attribute passed to generated directory_path target

kwargs

parameters to pass to generated output_files target


make_directory_paths

Helper function to convert a dict of directory to path mappings to directory_path targets and labels.

For example,

make_directory_paths("my_name", {
    "//directory/artifact:target_1": "file/path",
    "//directory/artifact:target_2": ["file/path1", "file/path2"],
})

generates the targets,

directory_path(
    name = "my_name_0",
    directory = "//directory/artifact:target_1",
    path = "file/path"
)

directory_path(
    name = "my_name_1",
    directory = "//directory/artifact:target_2",
    path = "file/path1"
)

directory_path(
    name = "my_name_2",
    directory = "//directory/artifact:target_2",
    path = "file/path2"
)

and the list of targets is returned,

[
    "my_name_0",
    "my_name_1",
    "my_name_2",
]

Example usage (generated)

load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_paths")

make_directory_paths(
    # The target name to use for the generated targets & labels
    name = "",
    # The dictionary of directory keys to path or path list values.
    dict = None,
)

name

The target name to use for the generated targets & labels.

The names are generated as zero-indexed name + "_" + i

dict

The dictionary of directory keys to path or path list values.

kwargs

additional parameters to pass to each generated target


Providers

DirectoryPathInfo

Joins a label pointing to a TreeArtifact with a path nested within that directory.