Documentation Index
Fetch the complete documentation index at: https://docs.aspect.build/llms.txt
Use this file to discover all available pages before exploring further.
Documentation for @bazel_lib@v3.2.0 — View source
Function: expand_locations
Expand location templates.
Expands all $(execpath ...), $(rootpath ...) and deprecated $(location ...) templates in the
given string by replacing with the expanded path. Expansion only works for labels that point to direct dependencies
of this rule or that are explicitly listed in the optional argument targets.
See https://docs.bazel.build/versions/main/be/make-variables.html#predefined_label_variables.
Use $(rootpath) and $(rootpaths) to expand labels to the runfiles path that a built binary can use
to find its dependencies. This path is of the format:
./filepath/to/file../external_repo/path/to/file
$(execpath) and $(execpaths) to expand labels to the execroot (where Bazel runs build actions).
This is of the format:
./filepath/to/fileexternal/external_repo/path/to/file<bin_dir>/path/to/file<bin_dir>/external/external_repo/path/to/file
$(location) and $(locations) expansions returns either the execpath or rootpath depending on the context.
Parameters
context
String to be expanded
List of targets for additional lookup information.
Function: expand_variables
Expand make variables and substitute like genrule does.
Bazel pre-defined variables
are expanded however only $@, $(@D) and $(RULEDIR) of
pre-defined genrule variables
are supported.
This function is the same as ctx.expand_make_variables with the additional
genrule-like substitutions of:
-
$<: The input file if it is a single file. Else triggers a build error. -
$@: The output file if it is a single file. Else triggers a build error. -
$(@D): The output directory. If there is only one file name in outs, this expands to the directory containing that file. If there is only one directory in outs, this expands to the single output directory. If there are multiple files, this instead expands to the package’s root directory in the bin tree, even if all generated files belong to the same subdirectory! -
$(RULEDIR): The output directory of the rule, that is, the directory corresponding to the name of the package containing the rule under the bin tree. -
$(BUILD_FILE_PATH): ctx.build_file_path -
$(VERSION_FILE): ctx.version_file.path -
$(INFO_FILE): ctx.info_file.path -
$(TARGET): ctx.label -
$(WORKSPACE): ctx.workspace_name
Parameters
starlark rule context
expression to expand
declared outputs of the rule, for expanding references to outputs
declared inputs of the rule, for expanding references to inputs
name of the attribute containing the expression. Used for error reporting.
s with the variables expanded
