diff options
author | 2017-11-21 07:23:28 -0800 | |
---|---|---|
committer | 2017-11-21 07:24:56 -0800 | |
commit | 2d5035685a6180e6abfa7e93d7ee4b7ec0632510 (patch) | |
tree | 8c77eed55891b24c8577f691af9c25f41e2fd32b /src/main/java/com | |
parent | 48c9393a4485bcc8388d27658c6c9452d53abcfb (diff) |
Change Platform.remoteExecutionProperties to be a String, not a dict.
This is needed for the ability to synthesize the correct remote
execution protos from a platform rule.
Part of #4128.
Change-Id: I7fa8acf45642a4df4e2beb1ba9c57c2536670486
PiperOrigin-RevId: 176504885
Diffstat (limited to 'src/main/java/com')
3 files changed, 15 insertions, 32 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java index 6971b63d8f..a5f29fc4f4 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/platform/PlatformInfo.java @@ -38,7 +38,6 @@ import com.google.devtools.build.lib.syntax.SkylarkList; import com.google.devtools.build.lib.syntax.SkylarkType; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; import javax.annotation.Nullable; @@ -98,12 +97,12 @@ public class PlatformInfo extends NativeInfo { private final Label label; private final ImmutableMap<ConstraintSettingInfo, ConstraintValueInfo> constraints; - private final ImmutableMap<String, String> remoteExecutionProperties; + private final String remoteExecutionProperties; private PlatformInfo( Label label, ImmutableList<ConstraintValueInfo> constraints, - ImmutableMap<String, String> remoteExecutionProperties, + String remoteExecutionProperties, Location location) { super( SKYLARK_CONSTRUCTOR, @@ -157,7 +156,7 @@ public class PlatformInfo extends NativeInfo { doc = "Properties that are available for the use of remote execution.", structField = true ) - public ImmutableMap<String, String> remoteExecutionProperties() { + public String remoteExecutionProperties() { return remoteExecutionProperties; } @@ -170,7 +169,7 @@ public class PlatformInfo extends NativeInfo { public static class Builder { private Label label; private final List<ConstraintValueInfo> constraints = new ArrayList<>(); - private final Map<String, String> remoteExecutionProperties = new HashMap<>(); + private String remoteExecutionProperties; private Location location = Location.BUILTIN; /** @@ -210,29 +209,13 @@ public class PlatformInfo extends NativeInfo { } /** - * Adds the given key/value pair to the data being sent to a potential remote executor. If the - * key already exists in the map, the previous value will be overwritten. - * - * @param key the key to be used - * @param value the value to be used - * @return the {@link Builder} instance for method chaining - */ - public Builder addRemoteExecutionProperty(String key, String value) { - this.remoteExecutionProperties.put(key, value); - return this; - } - - /** - * Adds the given properties to the data being sent to a potential remote executor. If any key - * already exists in the map, the previous value will be overwritten. + * Sets the data being sent to a potential remote executor. * * @param properties the properties to be added * @return the {@link Builder} instance for method chaining */ - public Builder addRemoteExecutionProperties(Map<String, String> properties) { - for (Map.Entry<String, String> entry : properties.entrySet()) { - this.addRemoteExecutionProperty(entry.getKey(), entry.getValue()); - } + public Builder setRemoteExecutionProperties(String properties) { + this.remoteExecutionProperties = properties; return this; } @@ -255,8 +238,7 @@ public class PlatformInfo extends NativeInfo { */ public PlatformInfo build() throws DuplicateConstraintException { ImmutableList<ConstraintValueInfo> validatedConstraints = validateConstraints(constraints); - return new PlatformInfo( - label, validatedConstraints, ImmutableMap.copyOf(remoteExecutionProperties), location); + return new PlatformInfo(label, validatedConstraints, remoteExecutionProperties, location); } public static ImmutableList<ConstraintValueInfo> validateConstraints( diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/Platform.java b/src/main/java/com/google/devtools/build/lib/rules/platform/Platform.java index e7a2fa0c40..99cc90b436 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/Platform.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/Platform.java @@ -30,7 +30,6 @@ import com.google.devtools.build.lib.syntax.Type; import com.google.devtools.build.lib.util.CPU; import com.google.devtools.build.lib.util.OS; import com.google.devtools.build.lib.util.Pair; -import java.util.Map; /** Defines a platform for execution contexts. */ public class Platform implements RuleConfiguredTargetFactory { @@ -54,9 +53,9 @@ public class Platform implements RuleConfiguredTargetFactory { ruleContext.getPrerequisites(PlatformRule.CONSTRAINT_VALUES_ATTR, Mode.DONT_CHECK))); } - Map<String, String> remoteExecutionProperties = - ruleContext.attributes().get(PlatformRule.REMOTE_EXECUTION_PROPS_ATTR, Type.STRING_DICT); - platformBuilder.addRemoteExecutionProperties(remoteExecutionProperties); + String remoteExecutionProperties = + ruleContext.attributes().get(PlatformRule.REMOTE_EXECUTION_PROPS_ATTR, Type.STRING); + platformBuilder.setRemoteExecutionProperties(remoteExecutionProperties); PlatformInfo platformInfo; try { diff --git a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java index 74e824f9f6..1abe56accd 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java +++ b/src/main/java/com/google/devtools/build/lib/rules/platform/PlatformRule.java @@ -49,9 +49,11 @@ public class PlatformRule implements RuleDefinition { .mandatoryProviders(ImmutableList.of(ConstraintValueInfo.SKYLARK_CONSTRUCTOR.id()))) /* <!-- #BLAZE_RULE(platform).ATTRIBUTE(remote_execution_properties) --> - A key/value dict of values that will be sent to a remote execution platform. + A text proto (the Platform message from + https://github.com/googleapis/googleapis/blob/master/google/devtools/remoteexecution/v1test/remote_execution.proto) + that will be sent to a remote execution platform. <!-- #END_BLAZE_RULE.ATTRIBUTE --> */ - .add(attr(REMOTE_EXECUTION_PROPS_ATTR, Type.STRING_DICT)) + .add(attr(REMOTE_EXECUTION_PROPS_ATTR, Type.STRING)) // Undocumented. Indicates that this platform should auto-configure the platform constraints // based on the current host OS and CPU settings. |