use of com.google.devtools.build.lib.analysis.config.BuildOptions in project bazel by bazelbuild.
the class ConfigurationFragmentFunction method compute.
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException, ConfigurationFragmentFunctionException {
ConfigurationFragmentKey configurationFragmentKey = (ConfigurationFragmentKey) skyKey.argument();
BuildOptions buildOptions = configurationFragmentKey.getBuildOptions();
ConfigurationFragmentFactory factory = getFactory(configurationFragmentKey.getFragmentType());
try {
PackageProviderForConfigurations packageProvider = new SkyframePackageLoaderWithValueEnvironment(env, ruleClassProvider);
ConfigurationEnvironment confEnv = new ConfigurationBuilderEnvironment(packageProvider);
Fragment fragment = factory.create(confEnv, buildOptions);
if (env.valuesMissing()) {
return null;
}
return new ConfigurationFragmentValue(fragment);
} catch (InvalidConfigurationException e) {
// exception with missing Skyframe dependencies.
if (env.valuesMissing()) {
return null;
}
throw new ConfigurationFragmentFunctionException(e);
}
}
use of com.google.devtools.build.lib.analysis.config.BuildOptions in project bazel by bazelbuild.
the class ConfigurationsForTargetsWithDynamicConfigurationsTest method newSplitTransition.
/**
* Returns a custom {@link Attribute.SplitTransition} that splits
* {@link BuildConfiguration.Options#testFilter} down two paths: {@code += prefix + "1"}
* and {@code += prefix + "2"}.
*/
private static Attribute.SplitTransition<BuildOptions> newSplitTransition(final String prefix) {
return new Attribute.SplitTransition<BuildOptions>() {
@Override
public List<BuildOptions> split(BuildOptions buildOptions) {
ImmutableList.Builder<BuildOptions> result = ImmutableList.builder();
for (int index = 1; index <= 2; index++) {
BuildOptions toOptions = buildOptions.clone();
BuildConfiguration.Options baseOptions = toOptions.get(BuildConfiguration.Options.class);
baseOptions.testFilter = (baseOptions.testFilter == null ? "" : baseOptions.testFilter) + prefix + index;
result.add(toOptions);
}
return result.build();
}
@Override
public boolean defaultsToSelf() {
return false;
}
};
}
use of com.google.devtools.build.lib.analysis.config.BuildOptions in project bazel by bazelbuild.
the class ConfigurationTestCase method createCollection.
protected BuildConfigurationCollection createCollection(String... args) throws Exception {
OptionsParser parser = OptionsParser.newOptionsParser(ImmutableList.<Class<? extends OptionsBase>>builder().addAll(buildOptionClasses).add(TestOptions.class).build());
parser.parse(args);
InvocationPolicyEnforcer optionsPolicyEnforcer = analysisMock.getInvocationPolicyEnforcer();
optionsPolicyEnforcer.enforce(parser);
ImmutableSortedSet<String> multiCpu = ImmutableSortedSet.copyOf(parser.getOptions(TestOptions.class).multiCpus);
BuildOptions buildOptions = BuildOptions.applyStaticConfigOverride(BuildOptions.of(buildOptionClasses, parser));
skyframeExecutor.handleDiffs(reporter);
BuildConfigurationCollection collection = skyframeExecutor.createConfigurations(reporter, configurationFactory, buildOptions, multiCpu, false);
return collection;
}
Aggregations