From 94588c2ceebca3328d3b84566306c91a8600fae6 Mon Sep 17 00:00:00 2001 From: Googler Date: Thu, 12 Mar 2015 16:50:49 +0000 Subject: BazelExtraActionRule is documented. -- MOS_MIGRATED_REVID=88449349 --- .../bazel/rules/common/BazelExtraActionRule.java | 102 +++++++++++++++++++++ 1 file changed, 102 insertions(+) (limited to 'src/main/java/com/google/devtools/build') diff --git a/src/main/java/com/google/devtools/build/lib/bazel/rules/common/BazelExtraActionRule.java b/src/main/java/com/google/devtools/build/lib/bazel/rules/common/BazelExtraActionRule.java index fa73f9308e..efc4e4630e 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/rules/common/BazelExtraActionRule.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/rules/common/BazelExtraActionRule.java @@ -37,13 +37,115 @@ import com.google.devtools.build.lib.rules.extra.ExtraActionFactory; public final class BazelExtraActionRule implements RuleDefinition { @Override public RuleClass build(Builder builder, RuleDefinitionEnvironment environment) { + /* + You may refer to this rule by label in the extra_actions argument + of action_listener rules. + */ return builder + /* + A list of tool dependencies for this rule. + ${SYNOPSIS} +

+ See the definition of dependencies for more information. +

+

+ The build system ensures these prerequisites are built before running the + extra_action command; they are built using the + hostconfiguration, since + they must run as a tool during the build itself. The path of an individual + tools target //x:y can be obtained using + $(location //x:y). +

+

+ All tools and their data dependencies are consolidated into a single tree + within which the command can use relative paths. The working directory will + be the root of that unified tree. +

+ */ .add(attr("tools", LABEL_LIST).cfg(HOST).allowedFileTypes().exec()) + /* + A list of templates for files generated by the extra_action command. + ${SYNOPSIS} +

+ The template can use the following variables: +

+

+ */ .add(attr("out_templates", STRING_LIST)) + /* + The command to run. + ${SYNOPSIS} +

+ Like genrule cmd attribute with the following differences: +

+
    +
  1. +

    + No heuristic label expansion. Only labels using $(location ...) are expanded. +

    +
  2. +
  3. +

    + An additional pass is applied to the string to replace all + occurrences of the outputs created from the out_templates + attribute. All occurrences of $(output out_template) + are replaced with the path to the file denoted by label. +

    +

    + E.g. out_template $(ACTION_ID).analysis + can be matched with $(output $(ACTION_ID).analysis). +

    +

    + In effect, this is the same substitution as $(location) + but with a different scope. +

    +
  4. +
+ */ .add(attr("cmd", STRING).mandatory()) + /* + Indicates this extra_action requires the output of the + original action to be present as input to this extra_action. + ${SYNOPSIS} +

+ When true (default false), the extra_action can assume that the + original action outputs are available as part of its inputs. +

+ */ .add(attr("requires_action_output", BOOLEAN)) .removeAttribute("deps") .removeAttribute(":action_listener") .build(); } } + +/* + +${ATTRIBUTE_SIGNATURE} + +

+ An extra_action rule doesn't produce any meaningful output + when specified as a regular build target. Instead, it allows tool developers + to insert additional actions into the build graph that shadow existing actions. +

+ +

+ See action_listener for details + on how to enable extra_actions in Bazel. +

+ +

+ The extra_actions run as a command-line. The command-line tool gets + access to a file containing a protocol buffer as $(EXTRA_ACTION_FILE) + with detailed information on the original action it is shadowing. + It also has access to all the input files the original action has access to. +

+ +${ATTRIBUTE_DEFINITION} + +*/ -- cgit v1.2.3