Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,6 @@ private static ImmutableSet<ConfiguredTargetAndData> getDirectPrerequisites(
.collect(toImmutableSet());
}

public boolean isAllowTagsPropagation() {
return getAnalysisEnvironment()
.getStarlarkSemantics()
.getBool(BuildLanguageOptions.INCOMPATIBLE_ALLOW_TAGS_PROPAGATION);
}

/**
* If this {@code RuleContext} is for rule evaluation, returns the attribute-based prerequisites
* of the rule and if it is for aspect evaluation, it returns the merged prerequisites of the rule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,7 @@ private void registerStarlarkAction(
}

ImmutableMap<String, String> executionInfo =
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked,
ruleContext.getRule(),
getSemantics().getBool(BuildLanguageOptions.INCOMPATIBLE_ALLOW_TAGS_PROPAGATION));
TargetUtils.getFilteredExecutionInfo(executionRequirementsUnchecked, ruleContext.getRule());
builder.setExecutionInfo(executionInfo);

String execGroup = determineExecGroup(ruleContext, execGroupUnchecked, toolchainUnchecked);
Expand Down Expand Up @@ -1061,10 +1058,7 @@ public void mapDirectory(
.getConfiguration()
.modifiedExecutionInfo(
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked,
ruleContext.getRule(),
getSemantics()
.getBool(BuildLanguageOptions.INCOMPATIBLE_ALLOW_TAGS_PROPAGATION)),
executionRequirementsUnchecked, ruleContext.getRule()),
mnemonic);

ActionEnvironment actionEnv =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ public static class BuildGraveyardOptions extends OptionsBase {
help = "This option is deprecated and has no effect.")
public String targetPlatformFallback;

@Option(
name = "incompatible_allow_tags_propagation",
oldName = "experimental_allow_tags_propagation",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.NO_OP},
metadataTags = {OptionMetadataTag.INCOMPATIBLE_CHANGE},
help = "Deprecated. No-op.")
public boolean allowTagsPropagation;

@Option(
name = "incompatible_auto_configure_host_platform",
defaultValue = "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,6 @@ public static Map<String, String> getExecutionInfo(Rule rule) {
return ImmutableMap.copyOf(map);
}

/**
* Returns the execution info from the tags declared on the target. These include only some tags
* {@link #legalExecInfoKeys} as keys with empty values.
*
* @param rule a rule instance to get tags from
* @param allowTagsPropagation if set to true, tags will be propagated from a target to the
* actions' execution requirements, for more details {@see
* BuildLanguageOptions#experimentalAllowTagsPropagation}
*/
public static ImmutableMap<String, String> getExecutionInfo(
Rule rule, boolean allowTagsPropagation) {
if (allowTagsPropagation) {
return ImmutableMap.copyOf(getExecutionInfo(rule));
} else {
return ImmutableMap.of();
}
}

/**
* Returns the execution info, obtained from the rule's tags and the execution requirements
Expand All @@ -278,13 +261,9 @@ public static ImmutableMap<String, String> getExecutionInfo(
* @param executionRequirementsUnchecked execution_requirements of a rule, expected to be of a
* {@code Dict<String, String>} type, null or Starlark None.
* @param rule a rule instance to get tags from
* @param allowTagsPropagation if set to true, tags will be propagated from a target to the
* actions' execution requirements, for more details {@see
* StarlarkSematicOptions#experimentalAllowTagsPropagation}
*/
public static ImmutableSortedMap<String, String> getFilteredExecutionInfo(
@Nullable Object executionRequirementsUnchecked, Rule rule, boolean allowTagsPropagation)
throws EvalException {
@Nullable Object executionRequirementsUnchecked, Rule rule) throws EvalException {
Map<String, String> executionInfo =
executionRequirementsUnchecked == null
? ImmutableMap.of()
Expand All @@ -295,12 +274,10 @@ public static ImmutableSortedMap<String, String> getFilteredExecutionInfo(
String.class,
"execution_requirements"));

if (allowTagsPropagation) {
executionInfo = new HashMap<>(executionInfo); // Make mutable.
Map<String, String> checkedTags = getExecutionInfo(rule);
// merging filtered tags to the execution info map avoiding duplicates
checkedTags.forEach(executionInfo::putIfAbsent);
}
executionInfo = new HashMap<>(executionInfo); // Make mutable.
Map<String, String> checkedTags = getExecutionInfo(rule);
// merging filtered tags to the execution info map avoiding duplicates
checkedTags.forEach(executionInfo::putIfAbsent);

return ImmutableSortedMap.copyOf(executionInfo);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,21 +391,6 @@ public final class BuildLanguageOptions extends OptionsBase {
+ "directory.")
public boolean experimentalSiblingRepositoryLayout;

@Option(
name = "incompatible_allow_tags_propagation",
oldName = "experimental_allow_tags_propagation",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.EXPERIMENTAL,
},
help =
"If set to true, tags will be propagated from a target to the actions' execution"
+ " requirements; otherwise tags are not propagated. See"
+ " https://github.com/bazelbuild/bazel/issues/8830 for details.")
public boolean experimentalAllowTagsPropagation;

@Option(
name = "incompatible_always_check_depset_elements",
defaultValue = "true",
Expand Down Expand Up @@ -876,7 +861,6 @@ private void setFlags(FlagConsumer consumer) {
.setBool(
INCOMPATIBLE_STOP_EXPORTING_LANGUAGE_MODULES,
incompatibleStopExportingLanguageModules)
.setBool(INCOMPATIBLE_ALLOW_TAGS_PROPAGATION, experimentalAllowTagsPropagation)
.set(EXPERIMENTAL_BUILTINS_BZL_PATH, experimentalBuiltinsBzlPath)
.set(INCOMPATIBLE_AUTOLOAD_EXTERNALLY, incompatibleAutoloadExternally)
.set(REPOSITORIES_WITHOUT_AUTOLOAD, repositoriesWithoutAutoloads)
Expand Down Expand Up @@ -1057,8 +1041,6 @@ public FlagConsumer setBool(String key, boolean ignored) {
"-incompatible_stop_exporting_language_modules";
public static final String INCOMPATIBLE_DISABLE_AUTOLOADS_IN_MAIN_REPO =
"+incompatible_disable_autoloads_in_main_repo";
public static final String INCOMPATIBLE_ALLOW_TAGS_PROPAGATION =
"+incompatible_allow_tags_propagation";
public static final String EXPERIMENTAL_BUILTINS_DUMMY = "-experimental_builtins_dummy";
public static final String EXPERIMENTAL_BZL_VISIBILITY = "+experimental_bzl_visibility";
public static final String ALLOW_EXPERIMENTAL_LOADS = "-allow_experimental_loads";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -920,9 +920,7 @@ private static CppCompileActionBuilder createCppCompileActionBuilder(
.setCoptsFilter(coptsFilter)
.setFeatureConfiguration(featureConfigurationForStarlark.getFeatureConfiguration())
.addExecutionInfo(
TargetUtils.getExecutionInfo(
starlarkRuleContext.getRuleContext().getRule(),
starlarkRuleContext.getRuleContext().isAllowTagsPropagation()));
TargetUtils.getExecutionInfo(starlarkRuleContext.getRuleContext().getRule()));
if (additionalCompilationInputs.size() > 0) {
builder.addMandatoryInputs(
Sequence.cast(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,7 @@ private ImmutableMap<String, String> getExecutionInfo() throws RuleErrorExceptio
getConfiguration()
.modifiedExecutionInfo(
modifiableExecutionInfo.buildOrThrow(), JavaCompileActionBuilder.MNEMONIC));
executionInfo.putAll(
TargetUtils.getExecutionInfo(ruleContext.getRule(), ruleContext.isAllowTagsPropagation()));
executionInfo.putAll(TargetUtils.getExecutionInfo(ruleContext.getRule()));

return executionInfo.buildKeepingLast();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,9 +536,7 @@ public void build(JavaToolchainProvider javaToolchain)
.modifiedExecutionInfo(
ImmutableMap.of(ExecutionRequirements.SUPPORTS_PATH_MAPPING, "1"),
JavaCompileActionBuilder.MNEMONIC));
executionInfo.putAll(
TargetUtils.getExecutionInfo(
ruleContext.getRule(), ruleContext.isAllowTagsPropagation()));
executionInfo.putAll(TargetUtils.getExecutionInfo(ruleContext.getRule()));

ActionOwner actionOwner =
ruleContext.useAutoExecGroups()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,10 @@ public void build(JavaSemantics semantics, RuleContext ruleContext, String execG
command.addExecPaths("--classpath_resources", classpathResources);
}

ImmutableMap<String, String> executionInfo = EXECUTION_INFO;
if (ruleContext.isAllowTagsPropagation()) {
ImmutableMap.Builder<String, String> executionInfoBuilder = ImmutableMap.builder();
executionInfoBuilder.putAll(EXECUTION_INFO);
executionInfoBuilder.putAll(
TargetUtils.getExecutionInfo(
ruleContext.getRule(), ruleContext.isAllowTagsPropagation()));
executionInfo = executionInfoBuilder.build();
}
ImmutableMap.Builder<String, String> executionInfoBuilder = ImmutableMap.builder();
executionInfoBuilder.putAll(EXECUTION_INFO);
executionInfoBuilder.putAll(TargetUtils.getExecutionInfo(ruleContext.getRule()));
ImmutableMap<String, String> executionInfo = executionInfoBuilder.build();

ruleContext.registerAction(
builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,7 @@ public void testFilteredExecutionInfo_fromUncheckedExecRequirements() throws Exc

Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
Dict.<String, String>builder().put("supports-worker", "1").buildImmutable(),
noTag, /* allowTagsPropagation */
true);
Dict.<String, String>builder().put("supports-worker", "1").buildImmutable(), noTag);
assertThat(execInfo).containsExactly("supports-worker", "1");

execInfo =
Expand All @@ -258,8 +256,7 @@ public void testFilteredExecutionInfo_fromUncheckedExecRequirements() throws Exc
.put("some-custom-tag", "1")
.put("no-cache", "1")
.buildImmutable(),
noTag,
/* allowTagsPropagation */ true);
noTag);
assertThat(execInfo).containsExactly("no-cache", "1");
}

Expand All @@ -279,8 +276,7 @@ public void testFilteredExecutionInfo_fromUncheckedExecRequirements_withWorkerKe
.put("supports-workers", "1")
.put("worker-key-mnemonic", "MyMnemonic")
.buildImmutable(),
noTag, /* allowTagsPropagation */
true);
noTag);
assertThat(execInfo)
.containsExactly("supports-workers", "1", "worker-key-mnemonic", "MyMnemonic");
}
Expand All @@ -296,8 +292,7 @@ public void testFilteredExecutionInfo() throws Exception {
Dict.<String, String>builder().put("no-remote", "1").buildImmutable();

Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked, tag1, /* allowTagsPropagation */ true);
TargetUtils.getFilteredExecutionInfo(executionRequirementsUnchecked, tag1);

assertThat(execInfo).containsExactly("no-cache", "", "supports-workers", "", "no-remote", "1");
}
Expand All @@ -313,8 +308,7 @@ public void testFilteredExecutionInfo_withDuplicateTags() throws Exception {
Dict.<String, String>builder().put("no-cache", "1").buildImmutable();

Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked, tag1, /* allowTagsPropagation */ true);
TargetUtils.getFilteredExecutionInfo(executionRequirementsUnchecked, tag1);

assertThat(execInfo).containsExactly("no-cache", "1", "supports-workers", "");
}
Expand All @@ -327,33 +321,13 @@ public void testFilteredExecutionInfo_withNullUncheckedExecRequirements() throws
"foo_binary(name = 'tag1', srcs=['sh.sh'], tags=['supports-workers', 'no-cache'])");
Rule tag1 = (Rule) getTarget("//tests:tag1");

Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(null, tag1, /* allowTagsPropagation */ true);
Map<String, String> execInfo = TargetUtils.getFilteredExecutionInfo(null, tag1);
assertThat(execInfo).containsExactly("no-cache", "", "supports-workers", "");

execInfo =
TargetUtils.getFilteredExecutionInfo(Starlark.NONE, tag1, /* allowTagsPropagation */ true);
execInfo = TargetUtils.getFilteredExecutionInfo(Starlark.NONE, tag1);
assertThat(execInfo).containsExactly("no-cache", "", "supports-workers", "");
}

@Test
public void testFilteredExecutionInfo_whenIncompatibleFlagDisabled() throws Exception {
// when --incompatible_allow_tags_propagation=false
scratch.file(
"tests/BUILD",
"load('//test_defs:foo_binary.bzl', 'foo_binary')",
"foo_binary(name = 'tag1', srcs=['sh.sh'], tags=['supports-workers', 'no-cache'])");
Rule tag1 = (Rule) getTarget("//tests:tag1");
Dict<String, String> executionRequirementsUnchecked =
Dict.<String, String>builder().put("no-remote", "1").buildImmutable();

Map<String, String> execInfo =
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked, tag1, /* allowTagsPropagation */ false);

assertThat(execInfo).containsExactly("no-remote", "1");
}

@Test
public void testExecutionInfoMisc() throws Exception {
// Migrated from a removed test class that was focused on top-level build configuration.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ private static BuildLanguageOptions buildRandomOptions(Random rand) throws Excep
"--incompatible_no_implicit_watch_label=" + rand.nextBoolean(),
"--experimental_google_legacy_api=" + rand.nextBoolean(),
"--experimental_platforms_api=" + rand.nextBoolean(),
"--incompatible_allow_tags_propagation=" + rand.nextBoolean(), // flag, Java names differ
"--experimental_cc_shared_library=" + rand.nextBoolean(),
"--experimental_repo_remote_exec=" + rand.nextBoolean(),
"--experimental_dormant_deps=" + rand.nextBoolean(),
Expand Down Expand Up @@ -182,7 +181,6 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.setBool(BuildLanguageOptions.INCOMPATIBLE_NO_IMPLICIT_WATCH_LABEL, rand.nextBoolean())
.setBool(BuildLanguageOptions.EXPERIMENTAL_GOOGLE_LEGACY_API, rand.nextBoolean())
.setBool(BuildLanguageOptions.EXPERIMENTAL_PLATFORMS_API, rand.nextBoolean())
.setBool(BuildLanguageOptions.INCOMPATIBLE_ALLOW_TAGS_PROPAGATION, rand.nextBoolean())
.setBool(BuildLanguageOptions.EXPERIMENTAL_CC_SHARED_LIBRARY, rand.nextBoolean())
.setBool(BuildLanguageOptions.EXPERIMENTAL_REPO_REMOTE_EXEC, rand.nextBoolean())
.setBool(BuildLanguageOptions.EXPERIMENTAL_DORMANT_DEPS, rand.nextBoolean())
Expand Down
Loading