Skip to content

Commit

Permalink
Exec transition should clear out all feature flags.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 343104216
  • Loading branch information
katre authored and copybara-github committed Nov 18, 2020
1 parent 4ed65b0 commit f581436
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/com/google/devtools/build/lib/analysis/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/events",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/rules/config:feature_flag_value",
"//src/main/java/com/google/devtools/build/lib/starlarkbuildapi",
"//third_party:guava",
"//third_party:jsr305",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package com.google.devtools.build.lib.analysis.config;

import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.devtools.build.lib.analysis.ToolchainCollection.DEFAULT_EXEC_GROUP_NAME;

import com.google.common.base.Preconditions;
Expand All @@ -25,7 +26,9 @@
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.events.EventHandler;
import com.google.devtools.build.lib.packages.AttributeTransitionData;
import com.google.devtools.build.lib.rules.config.FeatureFlagValue;
import com.google.devtools.build.lib.starlarkbuildapi.StarlarkConfigApi.ExecTransitionFactoryApi;
import java.util.Map;
import javax.annotation.Nullable;

/**
Expand Down Expand Up @@ -135,7 +138,20 @@ public BuildOptions patch(BuildOptionsView options, EventHandler eventHandler) {
ImmutableList.of(executionPlatform);
}

return execOptions.underlying();
BuildOptions result = execOptions.underlying();
// Remove any FeatureFlags that were set.
ImmutableList<Label> featureFlags =
execOptions.underlying().getStarlarkOptions().entrySet().stream()
.filter(entry -> entry.getValue() instanceof FeatureFlagValue)
.map(Map.Entry::getKey)
.collect(toImmutableList());
if (!featureFlags.isEmpty()) {
BuildOptions.Builder resultBuilder = result.toBuilder();
featureFlags.stream().forEach(flag -> resultBuilder.removeStarlarkOption(flag));
result = resultBuilder.build();
}

return result;
});
}
}
Expand Down

0 comments on commit f581436

Please sign in to comment.