Public API

relative_file

Resolves a relative path between two files, “to_file” and “frm_file”.

If neither of the paths begin with ../ it is assumed that they share the same root. When finding the relative path, the incoming files are treated as actual files (not folders) so the resulting relative path may differ when compared to passing the same arguments to python‘s “os.path.relpath()” or NodeJs’s “path.relative()”.

For example, ‘relative_file(“../foo/foo.txt”, “bar/bar.txt”)’ will return ‘../../foo/foo.txt’

PARAMETERS

NameDescriptionDefault Value
to_filethe path with file name to resolve to, from frmnone
frm_filethe path with file name to resolve fromnone

RETURNS

The relative path from frm_file to to_file, including the file name

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.

PARAMETERS

NameDescriptionDefault Value
ctxstarlark rule execution contextnone
filea File objectnone

RETURNS

The runfiles manifest entry path for a file

to_output_relative_path

The relative path from bazel-out/[arch]/bin to the given File object

PARAMETERS

NameDescriptionDefault Value
f - none

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.

PARAMETERS

NameDescriptionDefault Value
filea File objectnone

RETURNS

The workspace relative path for a file