Skip to content

Commit

Permalink
Remove --make_variables_source, it's not needed, used, documented, or…
Browse files Browse the repository at this point in the history
… visible

#6381

RELNOTES: None.
PiperOrigin-RevId: 222393972
  • Loading branch information
hlopko authored and Copybara-Service committed Nov 21, 2018
1 parent 9ca0cab commit ff7b878
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -860,29 +860,6 @@ public static class Options extends FragmentOptions implements Cloneable {
)
public Label autoCpuEnvironmentGroup;

/** The source of make variables for this configuration. */
public enum MakeVariableSource {
CONFIGURATION,
TOOLCHAIN
}

/** Converter for --make_variables_source. */
public static class MakeVariableSourceConverter extends EnumConverter<MakeVariableSource> {
public MakeVariableSourceConverter() {
super(MakeVariableSource.class, "Make variable source");
}
}

@Option(
name = "make_variables_source",
converter = MakeVariableSourceConverter.class,
defaultValue = "configuration",
metadataTags = {OptionMetadataTag.HIDDEN},
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN}
)
public MakeVariableSource makeVariableSource;

/** Values for --experimental_dynamic_configs. */
public enum ConfigsMode {
/** Only include the configuration fragments each rule needs. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ public static class GraveyardOptions extends OptionsBase {
help = "Deprecated no-op.")
public boolean disableMakeVariables;

@Option(
name = "make_variables_source",
defaultValue = "configuration",
metadataTags = {OptionMetadataTag.HIDDEN, OptionMetadataTag.DEPRECATED},
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.UNKNOWN})
public String makeVariableSource;

@Option(
name = "incompatible_disable_legacy_flags_cc_toolchain_api",
defaultValue = "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,12 @@ public static ConfiguredTarget init(CppSemantics semantics, RuleContext ruleCont
CcCommon common = new CcCommon(ruleContext);
CcToolchainProvider ccToolchain = common.getToolchain();

if (CppHelper.shouldUseToolchainForMakeVariables(ruleContext)) {
ImmutableMap.Builder<String, String> toolchainMakeVariables = ImmutableMap.builder();
ccToolchain.addGlobalMakeVariables(toolchainMakeVariables);
ruleContext.initConfigurationMakeVariableContext(
new MapBackedMakeVariableSupplier(toolchainMakeVariables.build()),
new CcFlagsSupplier(ruleContext));
} else {
ruleContext.initConfigurationMakeVariableContext(new CcFlagsSupplier(ruleContext));
}

CppConfiguration cppConfiguration = ruleContext.getFragment(CppConfiguration.class);
PrecompiledFiles precompiledFiles = new PrecompiledFiles(ruleContext);
LinkTargetType linkType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,11 @@ public static void init(

CcToolchainProvider ccToolchain = common.getToolchain();

if (CppHelper.shouldUseToolchainForMakeVariables(ruleContext)) {
ImmutableMap.Builder<String, String> toolchainMakeVariables = ImmutableMap.builder();
ccToolchain.addGlobalMakeVariables(toolchainMakeVariables);
ruleContext.initConfigurationMakeVariableContext(
new MapBackedMakeVariableSupplier(toolchainMakeVariables.build()),
new CcFlagsSupplier(ruleContext));
} else {
ruleContext.initConfigurationMakeVariableContext(new CcFlagsSupplier(ruleContext));
}

FdoProvider fdoProvider = common.getFdoProvider();
FeatureConfiguration featureConfiguration =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.config.AutoCpuConverter;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options.MakeVariableSource;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
Expand Down Expand Up @@ -187,7 +186,6 @@ public String toString() {
// it here so that the output directory doesn't depend on the CToolchain. When we will eventually
// verify that the two are the same, we can remove one of desiredCpu and targetCpu.
private final String desiredCpu;
private final PathFragment crosstoolTopPathFragment;

private final PathFragment fdoPath;
private final Label fdoOptimizeLabel;
Expand All @@ -210,18 +208,14 @@ public String toString() {
private final boolean stripBinaries;
private final CompilationMode compilationMode;

private final boolean shouldProvideMakeVariables;

private final CppToolchainInfo cppToolchainInfo;

static CppConfiguration create(CppConfigurationParameters params)
throws InvalidConfigurationException {
CppOptions cppOptions = params.cppOptions;
PathFragment crosstoolTopPathFragment =
params.crosstoolTop.getPackageIdentifier().getPathUnderExecRoot();
CppToolchainInfo cppToolchainInfo =
CppToolchainInfo.create(
crosstoolTopPathFragment,
params.crosstoolTop.getPackageIdentifier().getPathUnderExecRoot(),
params.ccToolchainLabel,
params.ccToolchainConfigInfo,
cppOptions.disableLegacyCrosstoolFields,
Expand All @@ -242,7 +236,6 @@ static CppConfiguration create(CppConfigurationParameters params)
params.transformedCpu,
params.compiler,
Preconditions.checkNotNull(params.commonOptions.cpu),
crosstoolTopPathFragment,
params.fdoPath,
params.fdoOptimizeLabel,
params.ccToolchainLabel,
Expand All @@ -258,7 +251,6 @@ static CppConfiguration create(CppConfigurationParameters params)
|| (cppOptions.stripBinaries == StripMode.SOMETIMES
&& compilationMode == CompilationMode.FASTBUILD)),
compilationMode,
params.commonOptions.makeVariableSource == MakeVariableSource.CONFIGURATION,
cppToolchainInfo);
}

Expand All @@ -268,7 +260,6 @@ private CppConfiguration(
String transformedCpuFromOptions,
String compilerFromOptions,
String desiredCpu,
PathFragment crosstoolTopPathFragment,
PathFragment fdoPath,
Label fdoOptimizeLabel,
Label ccToolchainLabel,
Expand All @@ -282,14 +273,12 @@ private CppConfiguration(
CppOptions cppOptions,
boolean stripBinaries,
CompilationMode compilationMode,
boolean shouldProvideMakeVariables,
CppToolchainInfo cppToolchainInfo) {
this.crosstoolTop = crosstoolTop;
this.crosstoolFromCcToolchainProtoAttribute = crosstoolFromCcToolchainProtoAttribute;
this.transformedCpuFromOptions = transformedCpuFromOptions;
this.compilerFromOptions = compilerFromOptions;
this.desiredCpu = desiredCpu;
this.crosstoolTopPathFragment = crosstoolTopPathFragment;
this.fdoPath = fdoPath;
this.fdoOptimizeLabel = fdoOptimizeLabel;
this.ccToolchainLabel = ccToolchainLabel;
Expand All @@ -303,7 +292,6 @@ private CppConfiguration(
this.cppOptions = cppOptions;
this.stripBinaries = stripBinaries;
this.compilationMode = compilationMode;
this.shouldProvideMakeVariables = shouldProvideMakeVariables;
this.cppToolchainInfo = cppToolchainInfo;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.actions.SymlinkAction;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options;
import com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options.MakeVariableSource;
import com.google.devtools.build.lib.analysis.config.CompilationMode;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget.Mode;
Expand Down Expand Up @@ -116,11 +114,9 @@ public static TransitiveInfoCollection mallocForTarget(RuleContext ruleContext)
*/
public static boolean shouldUseToolchainForMakeVariables(RuleContext ruleContext) {
Label toolchainType = getToolchainTypeFromRuleClass(ruleContext);
return (ruleContext.getConfiguration().getOptions().get(Options.class).makeVariableSource
== MakeVariableSource.TOOLCHAIN)
&& (ruleContext
.getFragment(PlatformConfiguration.class)
.isToolchainTypeEnabled(toolchainType));
return ruleContext
.getFragment(PlatformConfiguration.class)
.isToolchainTypeEnabled(toolchainType);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ public void testCcTargetsDependOnCcToolchainAutomatically() throws Exception {
+ TestConstants.TOOLS_REPOSITORY
+ "//tools/cpp:toolchain_type",
"--experimental_platforms=//a:mock-platform",
"--extra_toolchains=//a:toolchain_b",
"--make_variables_source=toolchain");
"--extra_toolchains=//a:toolchain_b");

// for cc_library, cc_binary, and cc_test, we check that $(TARGET_CPU) is a valid Make variable
ConfiguredTarget cclibrary =
Expand Down

0 comments on commit ff7b878

Please sign in to comment.