Skip to content

Commit

Permalink
Allow all native rules to use "exec_compatible_with" to specify
Browse files Browse the repository at this point in the history
additional constraints on the execution platform.

Part of work on bazelbuild#8134.
Fixes bazelbuild#8026.
  • Loading branch information
katre committed Apr 24, 2019
1 parent e39e5c9 commit 221fd5f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ public Object getDefault(AttributeMap rule) {
env.getToolsLabel(DEFAULT_COVERAGE_REPORT_GENERATOR_VALUE))))
// The target itself and run_under both run on the same machine.
.add(attr(":run_under", LABEL).value(RUN_UNDER).skipPrereqValidatorCheck())
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET)
.build();
}

Expand Down Expand Up @@ -389,6 +388,7 @@ public RuleClass build(RuleClass.Builder builder, RuleDefinitionEnvironment env)
attr("data", LABEL_LIST)
.allowedFileTypes(FileTypeSet.ANY_FILE)
.dontCheckConstraints())
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import com.google.devtools.build.lib.packages.PredicateWithMessage;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.RuleClass.ExecutionPlatformConstraintsAllowed;
import com.google.devtools.build.lib.util.FileTypeSet;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -72,7 +71,6 @@ All other files required at runtime (whether scripts or data) belong in the
.allowedRuleClasses("sh_library")
.allowedRuleClassesWithWarning(ALLOWED_RULES_IN_DEPS_WITH_WARNING)
.allowedFileTypes())
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,10 @@ public Builder(String name, RuleClassType type, boolean skylark, RuleClass... pa

for (Attribute attribute : parent.getAttributes()) {
String attrName = attribute.getName();
if (attrName.equals(RuleClass.EXEC_COMPATIBLE_WITH_ATTR)) {
// Don't inherit: this will be re-created
continue;
}
Preconditions.checkArgument(
!attributes.containsKey(attrName) || attributes.get(attrName).equals(attribute),
"Attribute %s is inherited multiple times in %s ruleclass",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import com.google.devtools.build.lib.packages.BuildType;
import com.google.devtools.build.lib.packages.RuleClass;
import com.google.devtools.build.lib.packages.RuleClass.Builder.RuleClassType;
import com.google.devtools.build.lib.packages.RuleClass.ExecutionPlatformConstraintsAllowed;
import com.google.devtools.build.lib.util.FileTypeSet;

/**
Expand Down Expand Up @@ -226,7 +225,6 @@ public Object getDefault(AttributeMap rule) {
.add(attr("heuristic_label_expansion", BOOLEAN).value(false))
.removeAttribute("data")
.removeAttribute("deps")
.executionPlatformConstraintsAllowed(ExecutionPlatformConstraintsAllowed.PER_TARGET)
.build();
}

Expand Down

0 comments on commit 221fd5f

Please sign in to comment.