EnsuredArtifact
An artifact that will be materialized to buck-out at the end of the bxl invocation. These artifacts can be printed to bxl's results. Doing so will print the path of the artifact rather than the standard representation.
Ensured artifacts are serializable and hashable.
EnsuredArtifact.abs_path
def EnsuredArtifact.abs_path(
) -> bxl.EnsuredArtifact
Converts this artifact to be printed by its absolute path. Note that this will only print out the absolute path via ctx.output.print()
. Starlark's print()
will print out the display info for an ensured artifact.
Sample usage:
def _impl_abs_path(ctx):
actions = ctx.bxl_actions().actions
output = actions.write("my_output", "my_content")
ensured = ctx.output.ensure(output) # currently defaults to creating an EnsuredArtifact with a relative path
ensured_with_abs_path = ensured.abs_path() # create a new EnsuredArtifact with absolute path to reuse
print(ensured_with_abs_path) # should return something like <ensured artifact ... >
ctx.output.print(ensured_with_abs_path) # should return the absolute path of the artifact
EnsuredArtifact.rel_path
def EnsuredArtifact.rel_path(
) -> bxl.EnsuredArtifact
Converts this artifact to be printed by its path relative to the project root. Note that this will only print out the relative path via ctx.output.print()
. Starlark's print()
will print out the display info for an ensured artifact.
Sample usage:
def _impl_rel_path(ctx):
actions = ctx.bxl_actions().actions
output = actions.write("my_output", "my_content")
ensured = ctx.output.ensure(output) # currently defaults to creating an EnsuredArtifact with a relative path
ensured_with_rel_path = ensured.rel_path() # create a new EnsuredArtifact with relative path to reuse
print(ensured_with_rel_path) # should return something like <ensured artifact ... >
ctx.output.print(ensured_with_rel_path) # should return the relative path of the artifact