aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar John Cater <jcater@google.com>2018-01-30 10:44:55 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-30 10:46:36 -0800
commit34c9b65a873dd9b79bafe3202571e6de81af1b50 (patch)
treeac5ac06d325d7b980fc12007da691aaae7eeaa92 /src
parent3958b71573c7ae3ff0a025e8635b0c21a4e43f45 (diff)
Obsolete and begin removing the toolchain_resolution_override flag.
It is not compatible with multiple execution platforms. Part of #4442. Change-Id: I683beaae1624130352a6f02bae3f4dfff263ea00 PiperOrigin-RevId: 183855561
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/PlatformConfiguration.java14
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/PlatformConfigurationLoader.java13
-rw-r--r--src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java82
-rw-r--r--src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunction.java6
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunctionTest.java24
5 files changed, 5 insertions, 134 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 021c673010..97c7f4fc29 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
@@ -15,7 +15,6 @@
package com.google.devtools.build.lib.analysis;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.concurrent.ThreadSafety;
@@ -42,7 +41,6 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment {
private final ImmutableList<Label> extraExecutionPlatforms;
private final ImmutableList<Label> targetPlatforms;
private final ImmutableList<Label> extraToolchains;
- private final ImmutableMap<Label, Label> toolchainResolutionOverrides;
private final ImmutableList<Label> enabledToolchainTypes;
@AutoCodec.Instantiator
@@ -51,13 +49,11 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment {
ImmutableList<Label> extraExecutionPlatforms,
ImmutableList<Label> targetPlatforms,
ImmutableList<Label> extraToolchains,
- ImmutableMap<Label, Label> toolchainResolutionOverrides,
ImmutableList<Label> enabledToolchainTypes) {
this.executionPlatform = executionPlatform;
this.extraExecutionPlatforms = extraExecutionPlatforms;
this.targetPlatforms = targetPlatforms;
this.extraToolchains = extraToolchains;
- this.toolchainResolutionOverrides = toolchainResolutionOverrides;
this.enabledToolchainTypes = enabledToolchainTypes;
}
@@ -85,16 +81,6 @@ public class PlatformConfiguration extends BuildConfiguration.Fragment {
return extraToolchains;
}
- /** Returns {@code true} if the given toolchain type has a manual override set. */
- public boolean hasToolchainOverride(Label toolchainType) {
- return toolchainResolutionOverrides.containsKey(toolchainType);
- }
-
- /** Returns the {@link Label} of the toolchain to use for the given toolchain type. */
- public Label getToolchainOverride(Label toolchainType) {
- return toolchainResolutionOverrides.get(toolchainType);
- }
-
@SkylarkCallable(
name = "enabled_toolchain_types",
structField = true,
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 c4f9c8b61d..cdc4893850 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
@@ -15,9 +15,7 @@
package com.google.devtools.build.lib.analysis;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.analysis.PlatformOptions.ToolchainResolutionOverride;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment;
@@ -25,7 +23,6 @@ import com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactor
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;
-import java.util.List;
/** A loader that creates {@link PlatformConfiguration} instances based on command-line options. */
public class PlatformConfigurationLoader implements ConfigurationFragmentFactory {
@@ -55,16 +52,6 @@ public class PlatformConfigurationLoader implements ConfigurationFragmentFactory
ImmutableList.copyOf(options.extraExecutionPlatforms),
ImmutableList.copyOf(options.platforms),
ImmutableList.copyOf(options.extraToolchains),
- convertOverrides(options.toolchainResolutionOverrides),
ImmutableList.copyOf(options.enabledToolchainTypes));
}
-
- private static ImmutableMap<Label, Label> convertOverrides(
- List<ToolchainResolutionOverride> overrides) {
- ImmutableMap.Builder<Label, Label> builder = new ImmutableMap.Builder<>();
- for (ToolchainResolutionOverride override : overrides) {
- builder.put(override.toolchainType(), override.toolchainLabel());
- }
- return builder.build();
- }
}
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
index bfd84ee776..51bfd8a15d 100644
--- a/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
+++ b/src/main/java/com/google/devtools/build/lib/analysis/PlatformOptions.java
@@ -14,25 +14,16 @@
package com.google.devtools.build.lib.analysis;
-import static com.google.devtools.build.lib.analysis.config.BuildConfiguration.convertOptionsLabel;
-
-import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.LabelListConverter;
import com.google.devtools.build.lib.analysis.config.FragmentOptions;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.skyframe.serialization.ObjectCodec;
-import com.google.devtools.build.lib.skyframe.serialization.SerializationException;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
-import com.google.devtools.common.options.Converter;
import com.google.devtools.common.options.Option;
import com.google.devtools.common.options.OptionDocumentationCategory;
import com.google.devtools.common.options.OptionEffectTag;
-import com.google.devtools.common.options.OptionsParsingException;
-import com.google.protobuf.CodedInputStream;
-import com.google.protobuf.CodedOutputStream;
-import java.io.IOException;
import java.util.List;
/** Command-line options for platform-related configuration. */
@@ -116,21 +107,23 @@ public class PlatformOptions extends FragmentOptions {
@Option(
name = "toolchain_resolution_override",
- converter = ToolchainResolutionOverrideConverter.class,
allowMultiple = true,
defaultValue = "",
- documentationCategory = OptionDocumentationCategory.TOOLCHAIN,
+ documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {
OptionEffectTag.AFFECTS_OUTPUTS,
OptionEffectTag.CHANGES_INPUTS,
OptionEffectTag.LOADING_AND_ANALYSIS
},
+ deprecationWarning =
+ "toolchain_resolution_override is now a no-op and will be removed in"
+ + " an upcoming release",
help =
"Override toolchain resolution for a toolchain type with a specific toolchain. "
+ "Example: --toolchain_resolution_override=@io_bazel_rules_go//:toolchain="
+ "@io_bazel_rules_go//:linux-arm64-toolchain"
)
- public List<ToolchainResolutionOverride> toolchainResolutionOverrides;
+ public List<String> toolchainResolutionOverrides;
@Option(
name = "toolchain_resolution_debug",
@@ -168,69 +161,4 @@ public class PlatformOptions extends FragmentOptions {
host.toolchainResolutionOverrides = this.toolchainResolutionOverrides;
return host;
}
-
- /** Data about which toolchain instance should be used for a given toolchain type. */
- @AutoValue
- public abstract static class ToolchainResolutionOverride {
- public static final ObjectCodec<ToolchainResolutionOverride> CODEC =
- new ToolchainResolutionOverrideCodec();
-
- public abstract Label toolchainType();
-
- public abstract Label toolchainLabel();
-
- private static ToolchainResolutionOverride create(Label toolchainType, Label toolchainLabel) {
- return new AutoValue_PlatformOptions_ToolchainResolutionOverride(
- toolchainType, toolchainLabel);
- }
-
- private static class ToolchainResolutionOverrideCodec
- implements ObjectCodec<ToolchainResolutionOverride> {
- @Override
- public Class<ToolchainResolutionOverride> getEncodedClass() {
- return ToolchainResolutionOverride.class;
- }
-
- @Override
- public void serialize(ToolchainResolutionOverride obj, CodedOutputStream codedOut)
- throws SerializationException, IOException {
- Label.CODEC.serialize(obj.toolchainType(), codedOut);
- Label.CODEC.serialize(obj.toolchainLabel(), codedOut);
- }
-
- @Override
- public ToolchainResolutionOverride deserialize(CodedInputStream codedIn)
- throws SerializationException, IOException {
- return ToolchainResolutionOverride.create(
- Label.CODEC.deserialize(codedIn), Label.CODEC.deserialize(codedIn));
- }
- }
- }
-
- /**
- * {@link Converter} implementation to create {@link ToolchainResolutionOverride} instances from
- * the value set in the flag.
- */
- public static class ToolchainResolutionOverrideConverter
- implements Converter<ToolchainResolutionOverride> {
-
- @Override
- public ToolchainResolutionOverride convert(String input) throws OptionsParsingException {
- int index = input.indexOf('=');
- if (index == -1) {
- throw new OptionsParsingException(
- "Toolchain resolution override not in the type=toolchain format");
- }
- Label toolchainType = convertOptionsLabel(input.substring(0, index));
- Label toolchain = convertOptionsLabel(input.substring(index + 1));
-
- return ToolchainResolutionOverride.create(toolchainType, toolchain);
- }
-
- @Override
- public String getTypeDescription() {
- return "a hard-coded override for toolchain resolution, "
- + "in the format toolchainTypeLabel=toolchainLabel";
- }
- }
}
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunction.java
index f222b3855a..0711230f24 100644
--- a/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunction.java
+++ b/src/main/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunction.java
@@ -49,12 +49,6 @@ public class ToolchainResolutionFunction implements SkyFunction {
PlatformConfiguration platformConfiguration =
configuration.getFragment(PlatformConfiguration.class);
- if (platformConfiguration.hasToolchainOverride(key.toolchainType())) {
- // Short circuit everything and just return the override.
- return ToolchainResolutionValue.create(
- platformConfiguration.getToolchainOverride(key.toolchainType()));
- }
-
// Get all toolchains.
RegisteredToolchainsValue toolchains;
try {
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunctionTest.java
index 128c59adc3..9d44e05848 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ToolchainResolutionFunctionTest.java
@@ -64,30 +64,6 @@ public class ToolchainResolutionFunctionTest extends ToolchainTestCase {
}
@Test
- public void testResolution_flagOverride() throws Exception {
- // Add extra toolchain.
- scratch.file(
- "extra/BUILD",
- "load('//toolchain:toolchain_def.bzl', 'test_toolchain')",
- "test_toolchain(",
- " name='extra_toolchain_impl',",
- " data = 'extra')");
-
- useConfiguration(
- "--toolchain_resolution_override=" + testToolchainType + "=//extra:extra_toolchain_impl");
-
- SkyKey key =
- ToolchainResolutionValue.key(targetConfig, testToolchainType, linuxPlatform, macPlatform);
- EvaluationResult<ToolchainResolutionValue> result = invokeToolchainResolution(key);
-
- assertThatEvaluationResult(result).hasNoError();
-
- ToolchainResolutionValue toolchainResolutionValue = result.get(key);
- assertThat(toolchainResolutionValue.toolchainLabel())
- .isEqualTo(makeLabel("//extra:extra_toolchain_impl"));
- }
-
- @Test
public void testResolution_noneFound() throws Exception {
// Clear the toolchains.
rewriteWorkspace();