Skip to content

Commit

Permalink
Allow feature configuration to be created from skylark
Browse files Browse the repository at this point in the history
Working towards #4571.

RELNOTES: CppRules: Feature configuration can be created from Skylark
PiperOrigin-RevId: 194048906
  • Loading branch information
hlopko authored and Copybara-Service committed Apr 24, 2018
1 parent e6febea commit ce2aa95
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import com.google.devtools.build.lib.concurrent.ThreadSafety.Immutable;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec;
import com.google.devtools.build.lib.skyframe.serialization.autocodec.AutoCodec.VisibleForSerialization;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModule;
import com.google.devtools.build.lib.skylarkinterface.SkylarkModuleCategory;
import com.google.devtools.build.lib.util.Pair;
import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.view.config.crosstool.CrosstoolConfig.CToolchain;
Expand Down Expand Up @@ -928,11 +930,11 @@ public int hashCode() {
}

/**
* An executable to be invoked by a blaze action. Can carry information on its platform
* An executable to be invoked by a blaze action. Can carry information on its platform
* restrictions.
*/
@Immutable
static class Tool {
public static class Tool {
private final PathFragment toolPathFragment;
private final ImmutableSet<String> executionRequirements;
private final ImmutableSet<WithFeatureSet> withFeatureSetSets;
Expand All @@ -957,7 +959,7 @@ public Tool(
}

/** Returns the path to this action's tool relative to the provided crosstool path. */
PathFragment getToolPathFragment() {
public PathFragment getToolPathFragment() {
return toolPathFragment;
}

Expand Down Expand Up @@ -2054,6 +2056,12 @@ VariableValue getNonStructuredVariable(String name) {
/** Captures the set of enabled features and action configs for a rule. */
@Immutable
@AutoCodec
@SkylarkModule(
name = "feature_configuration",
documented = false,
category = SkylarkModuleCategory.BUILTIN,
doc = "Class used to construct command lines from CROSSTOOL features."
)
public static class FeatureConfiguration {
private final ImmutableSet<String> enabledFeatureNames;
private final ImmutableList<Feature> enabledFeatures;
Expand Down Expand Up @@ -2161,10 +2169,8 @@ ImmutableMap<String, String> getEnvironmentVariables(String action, Variables va
return envBuilder.build();
}

/**
* Returns a given action's tool under this FeatureConfiguration.
*/
Tool getToolForAction(String actionName) {
/** Returns a given action's tool under this FeatureConfiguration. */
public Tool getToolForAction(String actionName) {
Preconditions.checkArgument(
actionConfigByActionName.containsKey(actionName),
"Action %s does not have an enabled configuration in the toolchain.",
Expand Down

0 comments on commit ce2aa95

Please sign in to comment.