Search in sources :

Example 1 with SupportedEnvironments

use of com.google.devtools.build.lib.analysis.constraints.SupportedEnvironments in project bazel by bazelbuild.

the class RuleConfiguredTargetBuilder method checkConstraints.

/**
   * Invokes Blaze's constraint enforcement system: checks that this rule's dependencies
   * support its environments and reports appropriate errors if violations are found. Also
   * publishes this rule's supported environments for the rules that depend on it.
   */
private void checkConstraints() {
    if (!ruleContext.getRule().getRuleClassObject().supportsConstraintChecking()) {
        return;
    }
    EnvironmentCollection supportedEnvironments = ConstraintSemantics.getSupportedEnvironments(ruleContext);
    if (supportedEnvironments != null) {
        EnvironmentCollection.Builder refinedEnvironments = new EnvironmentCollection.Builder();
        Map<Label, Target> removedEnvironmentCulprits = new LinkedHashMap<>();
        ConstraintSemantics.checkConstraints(ruleContext, supportedEnvironments, refinedEnvironments, removedEnvironmentCulprits);
        add(SupportedEnvironmentsProvider.class, new SupportedEnvironments(supportedEnvironments, refinedEnvironments.build(), removedEnvironmentCulprits));
    }
}
Also used : Target(com.google.devtools.build.lib.packages.Target) TestActionBuilder(com.google.devtools.build.lib.rules.test.TestActionBuilder) NestedSetBuilder(com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder) Label(com.google.devtools.build.lib.cmdline.Label) EnvironmentCollection(com.google.devtools.build.lib.analysis.constraints.EnvironmentCollection) SupportedEnvironments(com.google.devtools.build.lib.analysis.constraints.SupportedEnvironments) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

EnvironmentCollection (com.google.devtools.build.lib.analysis.constraints.EnvironmentCollection)1 SupportedEnvironments (com.google.devtools.build.lib.analysis.constraints.SupportedEnvironments)1 Label (com.google.devtools.build.lib.cmdline.Label)1 NestedSetBuilder (com.google.devtools.build.lib.collect.nestedset.NestedSetBuilder)1 Target (com.google.devtools.build.lib.packages.Target)1 TestActionBuilder (com.google.devtools.build.lib.rules.test.TestActionBuilder)1 LinkedHashMap (java.util.LinkedHashMap)1