Public API

Macros and Functions

relative_file

Resolves a relative path between two files, "to_file" and "frm_file", they must share the same root

Example usage (generated)

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

relative_file(
    # the path with file name to resolve to, from frm
    to_file = "",
    # the path with file name to resolve from
    frm_file = "",
)

to_file

the path with file name to resolve to, from frm

frm_file

the path with file name to resolve from


to_manifest_path

The runfiles manifest entry path for a file

This is the full runfiles path of a file including its workspace name as the first segment. We refert to it as the manifest path as it is the path flavor that is used for in the runfiles MANIFEST file.

We must avoid using non-normalized paths (workspace/../other_workspace/path) in order to locate entries by their key.

Example usage (generated)

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

to_manifest_path(
    # starlark rule execution context
    ctx = None,
    # a File object
    file = "",
)

ctx

starlark rule execution context

file

a File object


to_workspace_path

The workspace relative path for a file

This is the full runfiles path of a file excluding its workspace name. This differs from root path and manifest path as it does not include the repository name if the file is from an external repository.

Example usage (generated)

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

to_workspace_path(
    # starlark rule execution context
    ctx = None,
    # a File object
    file = "",
)

ctx

starlark rule execution context

file

a File object