File is passed to an Args object without using a map_each function, it is converted to a string by taking the value of its path field.
Members
- basename
- dirname
- extension
- is_directory
- is_source
- is_symlink
- owner
- path
- rlocation_path
- root
- short_path
- tree_relative_path
basename
dirname
extension
is_directory
is_source
is_symlink
owner
None.
path
short_path. The root may be empty, which it usually is for non-generated files. For generated files it usually contains a configuration-specific path fragment that encodes things like the target CPU architecture that was used while building said file.
Note that for files in external repositories, short_path reflects the runfiles tree path (prefixed with ../<repo_name>/) rather than the root-relative execution path (prefixed with external/<repo_name>/), so concatenating File.root.path and File.short_path does not yield File.path.
rlocation_path
Rlocation function of runfiles libraries accepts. This is the path that $(rlocationpath) expands to. It begins with the canonical name of the file’s repository, or with _main for files in the main repository.
The path only refers to the file if the file is in the runfiles at its default location, not only via the symlinks or root_symlinks parameters of ctx.runfiles.
To pass the rlocation paths of many files to an action, prefer args.add_all(files, map_each = _rlocation_path) with a top-level function _rlocation_path that returns f.rlocation_path over building a list of strings during analysis.
root
short_path
../<repo_name>/ (the legacy runfiles path relative to the main repository’s runfiles directory). Note that because it starts with ../, it cannot simply be joined to RUNFILES_DIR, nor used with runfiles libraries or rlocation without stripping the leading ../. Use rlocation_path for that instead.
tree_relative_path
tree_relative_path is only available for expanded files of a directory in an action command, i.e. Args.add_all(). For other types of files, it is an error to access this field.