diff options
author | jcater <jcater@google.com> | 2017-12-21 12:53:12 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-21 12:56:20 -0800 |
commit | 3ce42ef3074ee6d3ac7d9968381c8c0a51d9d38d (patch) | |
tree | c3f0b6be61a016375cd02d243c7e2b1db30eb150 /src/main/java/com/google/devtools/build/lib/rules/platform | |
parent | baea3b16ab9ff1b9a1b7a758760d035ae096bfd5 (diff) |
Automated rollback of commit 43f45b58acf10beadbb1221b71dfa06fa1341510.
*** Reason for rollback ***
Breaks some remote execution clients.
*** Original change description ***
Have the RemoteSpawnRunner use the execution platform present in the Spawn to get the remote execution properties.
Fixes #4128.
Change-Id: I7e71caef2465204d2dd8225448d54e52366807e6
PiperOrigin-RevId: 179847553
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/rules/platform')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/rules/platform/Platform.java | 31 |
1 files changed, 6 insertions, 25 deletions
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 07196bb41d..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 @@ -17,7 +17,6 @@ package com.google.devtools.build.lib.rules.platform; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.FileProvider; import com.google.devtools.build.lib.analysis.FilesToRunProvider; -import com.google.devtools.build.lib.analysis.PlatformOptions; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetBuilder; import com.google.devtools.build.lib.analysis.RuleConfiguredTargetFactory; import com.google.devtools.build.lib.analysis.RuleContext; @@ -40,40 +39,22 @@ public class Platform implements RuleConfiguredTargetFactory { PlatformInfo.Builder platformBuilder = PlatformInfo.builder().setLabel(ruleContext.getLabel()); - Boolean isHostPlatform = - ruleContext.attributes().get(PlatformRule.HOST_PLATFORM_ATTR, Type.BOOLEAN); - Boolean isTargetPlatform = - ruleContext.attributes().get(PlatformRule.TARGET_PLATFORM_ATTR, Type.BOOLEAN); - if (isHostPlatform && isTargetPlatform) { - ruleContext.attributeError( - PlatformRule.HOST_PLATFORM_ATTR, - "A single platform cannot have both host_platform and target_platform set."); - return null; - } else if (isHostPlatform) { + if (ruleContext.attributes().get(PlatformRule.HOST_PLATFORM_ATTR, Type.BOOLEAN)) { // Create default constraints based on the current host OS and CPU values. String cpuOption = ruleContext.getConfiguration().getHostCpu(); autodetectConstraints(cpuOption, ruleContext, platformBuilder); - } else if (isTargetPlatform) { + } else if (ruleContext.attributes().get(PlatformRule.TARGET_PLATFORM_ATTR, Type.BOOLEAN)) { // Create default constraints based on the current OS and CPU values. String cpuOption = ruleContext.getConfiguration().getCpu(); autodetectConstraints(cpuOption, ruleContext, platformBuilder); + } else { + platformBuilder.addConstraints( + PlatformProviderUtils.constraintValues( + ruleContext.getPrerequisites(PlatformRule.CONSTRAINT_VALUES_ATTR, Mode.DONT_CHECK))); } - // Add the declared constraints. Because setting the host_platform or target_platform attribute - // to true on a platform automatically includes the detected CPU and OS constraints, if the - // constraint_values attribute tries to add those, this will throw an error. - platformBuilder.addConstraints( - PlatformProviderUtils.constraintValues( - ruleContext.getPrerequisites(PlatformRule.CONSTRAINT_VALUES_ATTR, Mode.DONT_CHECK))); - String remoteExecutionProperties = ruleContext.attributes().get(PlatformRule.REMOTE_EXECUTION_PROPS_ATTR, Type.STRING); - if (platformBuilder.getRemoteExecutionProperties() == null && isHostPlatform) { - // Use the default override. - PlatformOptions platformOptions = - ruleContext.getConfiguration().getOptions().get(PlatformOptions.class); - remoteExecutionProperties = platformOptions.hostPlatformRemotePropertiesOverride; - } platformBuilder.setRemoteExecutionProperties(remoteExecutionProperties); PlatformInfo platformInfo; |