Skip to content

Commit

Permalink
Create --incompatible_enable_late_bound_option_defaults flag
Browse files Browse the repository at this point in the history
Equivalent to --experimental_use_late_bound_option_defaults, with a name that conforms to the policy for incompatible changes.

RELNOTES: None.
PiperOrigin-RevId: 210714389
scentini authored and Copybara-Service committed Aug 29, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6091588 commit 8253721
Showing 2 changed files with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -855,6 +855,23 @@ public enum ConfigsMode {
+ "removal of late bound option defaults.")
public boolean useLateBoundOptionDefaults;

@Option(
name = "incompatible_enable_late_bound_option_defaults",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.LOADING_AND_ANALYSIS, OptionEffectTag.AFFECTS_OUTPUTS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
},
help =
"When false, Bazel will not allow late bound values read from the CROSSTOOL file "
+ "to be used in config_settings. The CROSSTOOL field used in this manner is "
+ "'compiler'. Instead of config_setting(values = {'compiler': 'x'}), "
+ "config_setting(flag_values = {'@bazel_tools/tools/cpp:compiler': 'x'}) should "
+ "be used.")
public boolean incompatibleEnableLateBoundOptionDefaults;

/**
* Converter for --experimental_dynamic_configs.
*/
@@ -1254,7 +1271,11 @@ public BuildConfiguration(
this.testTimeout = ImmutableMap.copyOf(options.testTimeout);

this.transitiveOptionDetails =
computeOptionsMap(buildOptions, fragments.values(), options.useLateBoundOptionDefaults);
computeOptionsMap(
buildOptions,
fragments.values(),
(options.useLateBoundOptionDefaults
&& options.incompatibleEnableLateBoundOptionDefaults));

ImmutableMap.Builder<String, String> globalMakeEnvBuilder = ImmutableMap.builder();
for (Fragment fragment : fragments.values()) {
Original file line number Diff line number Diff line change
@@ -273,6 +273,18 @@ public void disallowLateBoundOptionDefaults() throws Exception {
assertThat(getConfigMatchingProvider("//test:match").matches()).isFalse();
}

/** Tests disallowing {@link BuildConfiguration.Fragment#lateBoundOptionDefaults} */
@Test
public void disallowLateBoundOptionDefaultsIncompatible() throws Exception {
useConfiguration("--incompatible_enable_late_bound_option_defaults=false");
scratch.file(
"test/BUILD",
"config_setting(",
" name = 'match',",
" values = { 'opt_with_default': 'overridden' }",
")");
assertThat(getConfigMatchingProvider("//test:match").matches()).isFalse();
}
/**
* Tests matching on multi-value attributes with key=value entries (e.g. --define).
*/

0 comments on commit 8253721

Please sign in to comment.