foo_binary
and foo_library
may share many
* attributes in common).
*/
@Immutable
public final class Attribute implements ComparableDo not add to this. Use {@link * com.google.devtools.build.lib.analysis.config.PatchTransition} or {@link SplitTransition} * instead. */ public enum ConfigurationTransition implements Transition { /** No transition, i.e., the same configuration as the current. */ NONE, /** Transition to a null configuration (applies to, e.g., input files). */ NULL, /** Transition from the target configuration to the data configuration. */ // TODO(bazel-team): Move this elsewhere. DATA, /** * Transition to one or more configurations. To obtain the actual child configurations, * invoke {@link Attribute#getSplitTransition(AttributeMap)}. * See {@link SplitTransition}. **/ SPLIT } private enum PropertyFlag { MANDATORY, EXECUTABLE, UNDOCUMENTED, TAGGABLE, /** * Whether the list attribute is order-independent and can be sorted. */ ORDER_INDEPENDENT, /** * Whether the allowedRuleClassesForLabels or allowedFileTypesForLabels are * set to custom values. If so, and the attribute is called "deps", the * legacy deps checking is skipped, and the new stricter checks are used * instead. For non-"deps" attributes, this allows skipping the check if it * would pass anyway, as the default setting allows any rule classes and * file types. */ STRICT_LABEL_CHECKING, /** * Set for things that would cause the a compile or lint-like action to * be executed when the input changes. Used by compile_one_dependency. * Set for attributes like hdrs and srcs on cc_ rules or srcs on java_ * or py_rules. Generally not set on data/resource attributes. */ DIRECT_COMPILE_TIME_INPUT, /** * Whether the value of the list type attribute must not be an empty list. */ NON_EMPTY, /** * Verifies that the referenced rule produces a single artifact. Note that this check happens * on a per label basis, i.e. the check happens separately for every label in a label list. */ SINGLE_ARTIFACT, /** * Whether we perform silent ruleclass filtering of the dependencies of the label type * attribute according to their rule classes. I.e. elements of the list which don't match the * allowedRuleClasses predicate or not rules will be filtered out without throwing any errors. * This flag is introduced to handle plugins, do not use it in other cases. */ SILENT_RULECLASS_FILTER, // TODO(bazel-team): This is a hack introduced because of the bad design of the original rules. // Depot cleanup would be too expensive, but don't migrate this to Skylark. /** * Whether to perform analysis time filetype check on this label-type attribute or not. * If the flag is set, we skip the check that applies the allowedFileTypes filter * to generated files. Do not use this if avoidable. */ SKIP_ANALYSIS_TIME_FILETYPE_CHECK, /** * Whether the value of the attribute should come from a given set of values. */ CHECK_ALLOWED_VALUES, /** * Whether this attribute is opted out of "configurability", i.e. the ability to determine * its value based on properties of the build configuration. */ NONCONFIGURABLE, /** * Whether we should skip dependency validation checks done by * {@link com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider.PrerequisiteValidator} * (for visibility, etc.). */ SKIP_PREREQ_VALIDATOR_CHECKS, /** * Whether we should check constraints on this attribute even if default enforcement policy * would skip it. See * {@link com.google.devtools.build.lib.analysis.constraints.ConstraintSemantics} for more on * constraints. */ CHECK_CONSTRAINTS_OVERRIDE, /** * Whether we should skip constraints checking on this attribute even if default enforcement * policy would check it. */ SKIP_CONSTRAINTS_OVERRIDE, /** * Whether we should use output_licenses to check the licences on this attribute. */ OUTPUT_LICENSES, } // TODO(bazel-team): modify this interface to extend Predicate and have an extra error // message function like AllowedValues does /** * A predicate-like class that determines whether an edge between two rules is valid or not. */ public interface ValidityPredicate { /** * This method should return null if the edge is valid, or a suitable error message * if it is not. Note that warnings are not supported. */ String checkValid(Rule from, Rule to); } public static final ValidityPredicate ANY_EDGE = new ValidityPredicate() { @Override public String checkValid(Rule from, Rule to) { return null; } }; /** * Provides a {@link SplitTransition} given the originating target {@link Rule}. The split * transition may be constant for all instances of the originating rule, or it may differ * based on attributes of that rule. For instance, a split transition on a rule's deps may differ * depending on the 'platform' attribute of the rule. */ public interface SplitTransitionProvider { /** * Returns the {@link SplitTransition} given the attribute mapper of the originating rule. */ SplitTransition apply(AttributeMap attributeMap); } /** * Implementation of {@link SplitTransitionProvider} that returns a single {@link SplitTransition} * regardless of the originating rule. */ private static class BasicSplitTransitionProvider implements SplitTransitionProvider { private final SplitTransition splitTransition; BasicSplitTransitionProvider(SplitTransition splitTransition) { this.splitTransition = splitTransition; } @Override public SplitTransition apply(AttributeMap attributeMap) { return splitTransition; } } /** * A predicate class to check if the value of the attribute comes from a predefined set. */ public static class AllowedValueSet implements PredicateWithMessage