Skip to content

Commit

Permalink
renamed 'incompatible_allow_tags_propagation' to 'experimental_..'
Browse files Browse the repository at this point in the history
renamed `--incompatible_allow_tags_propagation` to `--experimental_allow_tags_propagation`

RELNOTES[NEW]: tags: use `--experimental_allow_tags_propagation` flag to propagate tags to the action's execution requirements from targets. Such tags should start with: `no-`, `requires-`, `supports-`, `block-`, `disable-`, `cpu:`. See #8830 for details.

Note: this is only 'starlark' rules part. Native rules change will come as a seperate change under the same flag.

Closes #9197.

PiperOrigin-RevId: 264573625
  • Loading branch information
ishikhman authored and copybara-github committed Aug 21, 2019
1 parent 12ebb84 commit 7e83721
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ private void registerStarlarkAction(
TargetUtils.getFilteredExecutionInfo(
executionRequirementsUnchecked,
ruleContext.getRule(),
starlarkSemantics.incompatibleAllowTagsPropagation());
starlarkSemantics.experimentalAllowTagsPropagation());
builder.setExecutionInfo(executionInfo);

if (inputManifestsUnchecked != Runtime.NONE) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,19 +161,19 @@ public class StarlarkSemanticsOptions extends OptionsBase implements Serializabl
public boolean incompatibleBzlDisallowLoadAfterStatement;

@Option(
name = "incompatible_allow_tags_propagation",
name = "experimental_allow_tags_propagation",
oldName = "incompatible_allow_tags_propagation",
defaultValue = "false",
documentationCategory = OptionDocumentationCategory.STARLARK_SEMANTICS,
effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS},
metadataTags = {
OptionMetadataTag.INCOMPATIBLE_CHANGE,
OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES
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 incompatibleAllowTagsPropagation;
public boolean experimentalAllowTagsPropagation;

@Option(
name = "incompatible_depset_union",
Expand Down Expand Up @@ -656,6 +656,7 @@ public StarlarkSemantics toSkylarkSemantics() {
// <== Add new options here in alphabetic order ==>
.experimentalAllowIncrementalRepositoryUpdates(
experimentalAllowIncrementalRepositoryUpdates)
.experimentalAllowTagsPropagation(experimentalAllowTagsPropagation)
.experimentalBuildSettingApi(experimentalBuildSettingApi)
.experimentalCcSkylarkApiEnabledPackages(experimentalCcSkylarkApiEnabledPackages)
.experimentalEnableAndroidMigrationApis(experimentalEnableAndroidMigrationApis)
Expand Down Expand Up @@ -700,7 +701,6 @@ public StarlarkSemantics toSkylarkSemantics() {
.incompatibleRestrictStringEscapes(incompatibleRestrictStringEscapes)
.incompatibleDisallowDictLookupUnhashableKeys(
incompatibleDisallowDictLookupUnhashableKeys)
.incompatibleAllowTagsPropagation(incompatibleAllowTagsPropagation)
.incompatibleDisallowHashingFrozenMutables(incompatibleDisallowHashingFrozenMutables)
.build();
return INTERNER.intern(semantics);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ public static Map<String, String> getExecutionInfo(Rule rule) {
* {@code SkylarkDict<String, String>} type, null or {@link
* com.google.devtools.build.lib.syntax.Runtime#NONE}
* @param rule a rule instance to get tags from
* @param incompatibleAllowTagsPropagation if set to true, tags will be propagated from a target
* to the actions' execution requirements, for more details {@see
* SkylarkSematicOptions#incompatibleAllowTagsPropagation}
* @param allowTagsPropagation if set to true, tags will be propagated from a target to the
* actions' execution requirements, for more details {@see
* SkylarkSematicOptions#experimentalAllowTagsPropagation}
*/
public static ImmutableMap<String, String> getFilteredExecutionInfo(
Object executionRequirementsUnchecked, Rule rule, boolean incompatibleAllowTagsPropagation)
Object executionRequirementsUnchecked, Rule rule, boolean allowTagsPropagation)
throws EvalException {
Map<String, String> checkedExecutionRequirements =
TargetUtils.filter(
Expand All @@ -262,7 +262,7 @@ public static ImmutableMap<String, String> getFilteredExecutionInfo(
// adding filtered execution requirements to the execution info map
executionInfoBuilder.putAll(checkedExecutionRequirements);

if (incompatibleAllowTagsPropagation) {
if (allowTagsPropagation) {
Map<String, String> checkedTags = getExecutionInfo(rule);
// merging filtered tags to the execution info map avoiding duplicates
checkedTags.forEach(executionInfoBuilder::putIfAbsent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public enum FlagIdentifier {
INCOMPATIBLE_OBJC_FRAMEWORK_CLEANUP(StarlarkSemantics::incompatibleObjcFrameworkCleanup),
INCOMPATIBLE_DISALLOW_RULE_EXECUTION_PLATFORM_CONSTRAINTS_ALLOWED(
StarlarkSemantics::incompatibleDisallowRuleExecutionPlatformConstraintsAllowed),
INCOMPATIBLE_ALLOW_TAGS_PROPAGATION(StarlarkSemantics::incompatibleAllowTagsPropagation),
INCOMPATIBLE_ALLOW_TAGS_PROPAGATION(StarlarkSemantics::experimentalAllowTagsPropagation),
NONE(null);

// Using a Function here makes the enum definitions far cleaner, and, since this is
Expand Down Expand Up @@ -205,7 +205,7 @@ public boolean flagValue(FlagIdentifier flagIdentifier) {

public abstract boolean incompatibleDisallowDictLookupUnhashableKeys();

public abstract boolean incompatibleAllowTagsPropagation();
public abstract boolean experimentalAllowTagsPropagation();

public abstract boolean incompatibleDisallowHashingFrozenMutables();

Expand Down Expand Up @@ -242,6 +242,7 @@ public static Builder builderWithDefaults() {
public static final StarlarkSemantics DEFAULT_SEMANTICS =
builder()
// <== Add new options here in alphabetic order ==>
.experimentalAllowTagsPropagation(false)
.experimentalBuildSettingApi(true)
.experimentalCcSkylarkApiEnabledPackages(ImmutableList.of())
.experimentalAllowIncrementalRepositoryUpdates(true)
Expand Down Expand Up @@ -283,7 +284,6 @@ public static Builder builderWithDefaults() {
.incompatibleDepsetForLibrariesToLinkGetter(true)
.incompatibleRestrictStringEscapes(false)
.incompatibleDisallowDictLookupUnhashableKeys(false)
.incompatibleAllowTagsPropagation(false)
.incompatibleDisallowHashingFrozenMutables(false)
.build();

Expand All @@ -308,7 +308,7 @@ public abstract static class Builder {

public abstract Builder experimentalStarlarkUnusedInputsList(boolean value);

public abstract Builder incompatibleAllowTagsPropagation(boolean value);
public abstract Builder experimentalAllowTagsPropagation(boolean value);

public abstract Builder incompatibleBzlDisallowLoadAfterStatement(boolean value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private static StarlarkSemantics buildRandomSemantics(Random rand) {
.experimentalPlatformsApi(rand.nextBoolean())
.experimentalStarlarkConfigTransitions(rand.nextBoolean())
.experimentalStarlarkUnusedInputsList(rand.nextBoolean())
.incompatibleAllowTagsPropagation(rand.nextBoolean())
.experimentalAllowTagsPropagation(rand.nextBoolean())
.incompatibleBzlDisallowLoadAfterStatement(rand.nextBoolean())
.incompatibleDepsetForLibrariesToLinkGetter(rand.nextBoolean())
.incompatibleDepsetIsNotIterable(rand.nextBoolean())
Expand Down
10 changes: 5 additions & 5 deletions src/test/shell/bazel/tags_propagation_skylark_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test_rule = rule(
)
EOF

bazel aquery --incompatible_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
bazel aquery --experimental_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
|| fail "should have generated output successfully"

assert_contains "ExecutionInfo: {local: '', no-cache: '', no-remote: ''}" output1
Expand Down Expand Up @@ -89,7 +89,7 @@ test_rule = rule(
)
EOF

bazel aquery --incompatible_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
bazel aquery --experimental_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
|| fail "should have generated output successfully"

assert_contains "ExecutionInfo: {local: '', no-cache: '', no-remote: '', no-sandbox: '', requires-network: ''}" output1
Expand Down Expand Up @@ -128,14 +128,14 @@ test_rule = rule(
)
EOF

bazel aquery --incompatible_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
bazel aquery --experimental_allow_tags_propagation '//test:test' > output1 2> $TEST_log \
|| fail "should have generated output successfully"

assert_contains "ExecutionInfo: {local: '', no-cache: 1, no-remote: '', requires-network: '', requires-x: ''}" output1
}

# Test a basic skylark ctx.actions.run rule which has tags, that should not be propagated
# as --incompatible_allow_tags_propagation flag set to false
# as --experimental_allow_tags_propagation flag set to false
function test_tags_not_propagated_to_run_when_incompatible_flag_off() {
mkdir -p test
cat << EOF >> test/BUILD
Expand Down Expand Up @@ -166,7 +166,7 @@ test_rule = rule(
)
EOF

bazel aquery --incompatible_allow_tags_propagation=false '//test:test' > output1 2> $TEST_log \
bazel aquery --experimental_allow_tags_propagation=false '//test:test' > output1 2> $TEST_log \
|| fail "should have generated output successfully"

assert_not_contains "ExecutionInfo: {}" output1
Expand Down

0 comments on commit 7e83721

Please sign in to comment.