implementation
function when "
+ "you create a rule.")
public final class SkylarkRuleContext {
public static final String PROVIDER_CLASS_PREFIX = "com.google.devtools.build.lib.";
private static final String DOC_NEW_FILE_TAIL = "Does not actually create a file on the file "
+ "system, just declares that some action will do so. You must create an action that "
+ "generates the file. If the file should be visible to other rules, declare a rule output "
+ "instead when possible. Doing so enables Blaze to associate a label with the file that "
+ "rules can refer to (allowing finer dependency control) instead of referencing the whole "
+ "rule.";
static final LoadingCachestruct
containing executable files defined in label type "
+ "attributes marked as executable=True
. The struct fields correspond "
+ "to the attribute names. Each struct value is always a file
s or "
+ "None
. If an optional attribute is not specified in the rule "
+ "then the corresponding struct value is None
. If a label type is not "
+ "marked as executable=True
, no corresponding struct field is generated.";
public static final String FILES_DOC =
"A struct
containing files defined in label or label list "
+ "type attributes. The struct fields correspond to the attribute names. The struct "
+ "values are list
of file
s. If an optional attribute is "
+ "not specified in the rule, an empty list is generated."
+ "It is a shortcut for:"
+ "[f for t in ctx.attr."; public static final String FILE_DOC = "Afor f in t.files]
struct
containing files defined in label type "
+ "attributes marked as single_file=True
. The struct fields correspond "
+ "to the attribute names. The struct value is always a file
or "
+ "None
. If an optional attribute is not specified in the rule "
+ "then the corresponding struct value is None
. If a label type is not "
+ "marked as single_file=True
, no corresponding struct field is generated. "
+ "It is a shortcut for:"
+ "list(ctx.attr."; public static final String ATTR_DOC = "A struct to access the values of the attributes. The values are provided by " + "the user (if not, a default value is used)."; public static final String OUTPUTS_DOC = "A.files)[0]
struct
containing all the output files."
+ " The struct is generated the following way:executable=True
the struct has an "
+ "\"executable\" field with the rules default executable file
value."
+ "outputs
dict an attr is generated with "
+ "the same name and the corresponding file
value."
+ "file
value or None
, "
+ "if no value is specified in the rule."
+ "list
of file
s value "
+ "(an empty list if no value is specified in the rule).See {@link RuleContext#getExecutablePrerequisite(String, Mode)}.
*/
@SkylarkCallable(name = "executable", structField = true, doc = EXECUTABLE_DOC)
public SkylarkClassObject getExecutable() {
return attributesCollection.getExecutable();
}
/**
* See {@link RuleContext#getPrerequisiteArtifact(String, Mode)}.
*/
@SkylarkCallable(name = "file", structField = true, doc = FILE_DOC)
public SkylarkClassObject getFile() {
return attributesCollection.getFile();
}
/**
* See {@link RuleContext#getPrerequisiteArtifacts(String, Mode)}.
*/
@SkylarkCallable(name = "files", structField = true, doc = FILES_DOC)
public SkylarkClassObject getFiles() {
return attributesCollection.getFiles();
}
@SkylarkCallable(name = "workspace_name", structField = true,
doc = "Returns the workspace name as defined in the WORKSPACE file.")
public String getWorkspaceName() {
return ruleContext.getWorkspaceName();
}
@SkylarkCallable(name = "label", structField = true, doc = "The label of this rule.")
public Label getLabel() {
return ruleContext.getLabel();
}
@SkylarkCallable(name = "fragments", structField = true,
doc =
"Allows access to configuration fragments in target configuration. "
+ "Possible fields are cpp
, "
+ "java
and jvm
. "
+ "However, rules have to declare their required fragments in order to access them "
+ "(see here).")
public FragmentCollection getFragments() {
return fragments;
}
@SkylarkCallable(name = "host_fragments", structField = true,
doc =
"Allows access to configuration fragments in host configuration. "
+ "Possible fields are cpp
, "
+ "java
and jvm
. "
+ "However, rules have to declare their required fragments in order to access them "
+ "(see here).")
public FragmentCollection getHostFragments() {
return hostFragments;
}
@SkylarkCallable(name = "configuration", structField = true,
doc = "Returns the default configuration. See the "
+ "configuration type for more details.")
public BuildConfiguration getConfiguration() {
return ruleContext.getConfiguration();
}
@SkylarkCallable(name = "host_configuration", structField = true,
doc = "Returns the host configuration. See the "
+ "configuration type for more details.")
public BuildConfiguration getHostConfiguration() {
return ruleContext.getHostConfiguration();
}
@SkylarkCallable(structField = true, doc = OUTPUTS_DOC)
public SkylarkClassObject outputs() throws EvalException {
if (outputsObject == null) {
throw new EvalException(Location.BUILTIN, "'outputs' is not defined");
}
return outputsObject;
}
@SkylarkCallable(structField = true, doc = "Returns rule attributes descriptor")
public SkylarkRuleAttributesCollection rule() throws EvalException {
if (ruleAttributesCollection == null) {
throw new EvalException(Location.BUILTIN, "'rule' is not defined");
}
return ruleAttributesCollection;
}
@SkylarkCallable(structField = true,
doc = "Dictionary (String to String) of configuration variables")
public ImmutableMap