diff options
author | John Cater <jcater@google.com> | 2018-02-06 07:25:19 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2018-02-06 07:27:13 -0800 |
commit | 93b329417bba4ac4860628ebefc9fc64faec8cdf (patch) | |
tree | 3afd94e49c71cb899c41ad7dc0b332eaf07a78f6 /src/main/java/com/google | |
parent | 873f343fefbb08048e7e75c482843b9e68954de6 (diff) |
Rename the host platform information in the configuration.
Part of #4442.
Change-Id: I21baffe59431ccd3d76754596ec2a605dbbe4354
PiperOrigin-RevId: 184678470
Diffstat (limited to 'src/main/java/com/google')
3 files changed, 28 insertions, 29 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java index 97c7f4fc29..fb051b542a 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java @@ -37,7 +37,7 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment { public static final ObjectCodec<PlatformConfiguration> CODEC = new PlatformConfiguration_AutoCodec(); - private final Label executionPlatform; + private final Label hostPlatform; private final ImmutableList<Label> extraExecutionPlatforms; private final ImmutableList<Label> targetPlatforms; private final ImmutableList<Label> extraToolchains; @@ -45,25 +45,21 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment { @AutoCodec.Instantiator PlatformConfiguration( - Label executionPlatform, + Label hostPlatform, ImmutableList<Label> extraExecutionPlatforms, ImmutableList<Label> targetPlatforms, ImmutableList<Label> extraToolchains, ImmutableList<Label> enabledToolchainTypes) { - this.executionPlatform = executionPlatform; + this.hostPlatform = hostPlatform; this.extraExecutionPlatforms = extraExecutionPlatforms; this.targetPlatforms = targetPlatforms; this.extraToolchains = extraToolchains; this.enabledToolchainTypes = enabledToolchainTypes; } - @SkylarkCallable( - name = "execution_platform", - structField = true, - doc = "The current execution platform" - ) - public Label getExecutionPlatform() { - return executionPlatform; + @SkylarkCallable(name = "host_platform", structField = true, doc = "The current host platform") + public Label getHostPlatform() { + return hostPlatform; } /** Additional platforms that are available for action execution. */ diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java index cdc4893850..6239aca9c7 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java @@ -22,7 +22,6 @@ import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment; import com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory; import com.google.devtools.build.lib.analysis.config.FragmentOptions; import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException; -import com.google.devtools.build.lib.cmdline.Label; /** A loader that creates {@link PlatformConfiguration} instances based on command-line options. */ public class PlatformConfigurationLoader implements ConfigurationFragmentFactory { @@ -45,10 +44,8 @@ public class PlatformConfigurationLoader implements ConfigurationFragmentFactory private PlatformConfiguration create(PlatformOptions options) throws InvalidConfigurationException { - // TODO(katre): This will change with remote execution. - Label executionPlatform = options.hostPlatform; return new PlatformConfiguration( - executionPlatform, + options.hostPlatform, ImmutableList.copyOf(options.extraExecutionPlatforms), ImmutableList.copyOf(options.platforms), ImmutableList.copyOf(options.extraToolchains), diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java index acea616d80..cbfcbd4514 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainUtil.java @@ -67,14 +67,19 @@ public class ToolchainUtil { // TODO(katre): Load several possible execution platforms, and select one based on available // toolchains. - // Load the execution and target platforms for the current configuration. + // Load the host and target platforms for the current configuration. PlatformDescriptors platforms = loadPlatformDescriptors(env, configuration); if (platforms == null) { return null; } + // TODO(katre): This will change with remote execution. + PlatformInfo executionPlatform = platforms.hostPlatform(); + PlatformInfo targetPlatform = platforms.targetPlatform(); + ImmutableBiMap<Label, Label> resolvedLabels = - resolveToolchainLabels(env, requiredToolchains, configuration, platforms); + resolveToolchainLabels( + env, requiredToolchains, configuration, executionPlatform, targetPlatform); if (resolvedLabels == null) { return null; } @@ -82,8 +87,8 @@ public class ToolchainUtil { ToolchainContext toolchainContext = ToolchainContext.create( targetDescription, - platforms.execPlatform(), - platforms.targetPlatform(), + executionPlatform, + targetPlatform, requiredToolchains, resolvedLabels); return toolchainContext; @@ -94,13 +99,13 @@ public class ToolchainUtil { */ @AutoValue protected abstract static class PlatformDescriptors { - abstract PlatformInfo execPlatform(); + abstract PlatformInfo hostPlatform(); abstract PlatformInfo targetPlatform(); protected static PlatformDescriptors create( - PlatformInfo execPlatform, PlatformInfo targetPlatform) { - return new AutoValue_ToolchainUtil_PlatformDescriptors(execPlatform, targetPlatform); + PlatformInfo hostPlatform, PlatformInfo targetPlatform) { + return new AutoValue_ToolchainUtil_PlatformDescriptors(hostPlatform, targetPlatform); } } @@ -151,20 +156,20 @@ public class ToolchainUtil { if (platformConfiguration == null) { return null; } - Label executionPlatformLabel = platformConfiguration.getExecutionPlatform(); + Label hostPlatformLabel = platformConfiguration.getHostPlatform(); Label targetPlatformLabel = platformConfiguration.getTargetPlatforms().get(0); - SkyKey executionPlatformKey = ConfiguredTargetKey.of(executionPlatformLabel, configuration); + SkyKey hostPlatformKey = ConfiguredTargetKey.of(hostPlatformLabel, configuration); SkyKey targetPlatformKey = ConfiguredTargetKey.of(targetPlatformLabel, configuration); Map<SkyKey, ValueOrException<ConfiguredValueCreationException>> values = env.getValuesOrThrow( - ImmutableList.of(executionPlatformKey, targetPlatformKey), + ImmutableList.of(hostPlatformKey, targetPlatformKey), ConfiguredValueCreationException.class); boolean valuesMissing = env.valuesMissing(); try { - PlatformInfo execPlatform = - findPlatformInfo(values.get(executionPlatformKey), "execution platform", env); + PlatformInfo hostPlatform = + findPlatformInfo(values.get(hostPlatformKey), "host platform", env); PlatformInfo targetPlatform = findPlatformInfo(values.get(targetPlatformKey), "target platform", env); @@ -172,7 +177,7 @@ public class ToolchainUtil { return null; } - return PlatformDescriptors.create(execPlatform, targetPlatform); + return PlatformDescriptors.create(hostPlatform, targetPlatform); } catch (ConfiguredValueCreationException e) { throw new ToolchainContextException(e); } @@ -183,7 +188,8 @@ public class ToolchainUtil { Environment env, Set<Label> requiredToolchains, BuildConfiguration configuration, - PlatformDescriptors platforms) + PlatformInfo executionPlatform, + PlatformInfo targetPlatform) throws InterruptedException, ToolchainContextException { // If there are no required toolchains, bail out early. @@ -196,7 +202,7 @@ public class ToolchainUtil { for (Label toolchainType : requiredToolchains) { registeredToolchainKeys.add( ToolchainResolutionValue.key( - configuration, toolchainType, platforms.targetPlatform(), platforms.execPlatform())); + configuration, toolchainType, targetPlatform, executionPlatform)); } Map< |