Rename the host platform information in the configuration.

Part of #4442.

Change-Id: I21baffe59431ccd3d76754596ec2a605dbbe4354
PiperOrigin-RevId: 184678470
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 97c7f4f..fb051b5 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 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 @@
 
   @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 cdc4893..6239aca 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.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 @@
 
   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 acea616..cbfcbd4 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 @@
     // 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 @@
     ToolchainContext toolchainContext =
         ToolchainContext.create(
             targetDescription,
-            platforms.execPlatform(),
-            platforms.targetPlatform(),
+            executionPlatform,
+            targetPlatform,
             requiredToolchains,
             resolvedLabels);
     return toolchainContext;
@@ -94,13 +99,13 @@
    */
   @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 @@
     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 @@
         return null;
       }
 
-      return PlatformDescriptors.create(execPlatform, targetPlatform);
+      return PlatformDescriptors.create(hostPlatform, targetPlatform);
     } catch (ConfiguredValueCreationException e) {
       throw new ToolchainContextException(e);
     }
@@ -183,7 +188,8 @@
       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 @@
     for (Label toolchainType : requiredToolchains) {
       registeredToolchainKeys.add(
           ToolchainResolutionValue.key(
-              configuration, toolchainType, platforms.targetPlatform(), platforms.execPlatform()));
+              configuration, toolchainType, targetPlatform, executionPlatform));
     }
 
     Map<
diff --git a/src/test/shell/bazel/toolchain_test.sh b/src/test/shell/bazel/toolchain_test.sh
index 7d9e79c..2bfa840 100755
--- a/src/test/shell/bazel/toolchain_test.sh
+++ b/src/test/shell/bazel/toolchain_test.sh
@@ -651,7 +651,7 @@
   expect_log "While resolving toolchains for target //demo:use: Target filegroup rule //platform:not_a_platform was found as the target platform, but does not provide PlatformInfo"
 
   bazel build --host_platform=//platform:not_a_platform //demo:use &> $TEST_log && fail "Build failure expected"
-  expect_log "While resolving toolchains for target //demo:use: Target filegroup rule //platform:not_a_platform was found as the execution platform, but does not provide PlatformInfo"
+  expect_log "While resolving toolchains for target //demo:use: Target filegroup rule //platform:not_a_platform was found as the host platform, but does not provide PlatformInfo"
 }
 
 run_suite "toolchain tests"