Search in sources :

Example 21 with BuildOptions

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);
    }
}
Also used : ConfigurationFragmentKey(com.google.devtools.build.lib.skyframe.ConfigurationFragmentValue.ConfigurationFragmentKey) PackageProviderForConfigurations(com.google.devtools.build.lib.analysis.config.PackageProviderForConfigurations) ConfigurationEnvironment(com.google.devtools.build.lib.analysis.config.ConfigurationEnvironment) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) ConfigurationFragmentFactory(com.google.devtools.build.lib.analysis.config.ConfigurationFragmentFactory) Fragment(com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment) InvalidConfigurationException(com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)

Example 22 with BuildOptions

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;
        }
    };
}
Also used : BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) ImmutableList(com.google.common.collect.ImmutableList)

Example 23 with BuildOptions

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;
}
Also used : OptionsBase(com.google.devtools.common.options.OptionsBase) BuildOptions(com.google.devtools.build.lib.analysis.config.BuildOptions) InvocationPolicyEnforcer(com.google.devtools.build.lib.flags.InvocationPolicyEnforcer) OptionsParser(com.google.devtools.common.options.OptionsParser) BuildConfigurationCollection(com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection)

Aggregations

BuildOptions (com.google.devtools.build.lib.analysis.config.BuildOptions)23 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)12 ImmutableList (com.google.common.collect.ImmutableList)6 InvalidConfigurationException (com.google.devtools.build.lib.analysis.config.InvalidConfigurationException)4 SkyKey (com.google.devtools.build.skyframe.SkyKey)4 ArrayList (java.util.ArrayList)4 Dependency (com.google.devtools.build.lib.analysis.Dependency)3 Label (com.google.devtools.build.lib.cmdline.Label)3 Attribute (com.google.devtools.build.lib.packages.Attribute)3 HashSet (java.util.HashSet)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Options (com.google.devtools.build.lib.analysis.config.BuildConfiguration.Options)2 BuildConfigurationCollection (com.google.devtools.build.lib.analysis.config.BuildConfigurationCollection)2 PatchTransition (com.google.devtools.build.lib.analysis.config.PatchTransition)2 InvocationPolicyEnforcer (com.google.devtools.build.lib.flags.InvocationPolicyEnforcer)2 SplitTransition (com.google.devtools.build.lib.packages.Attribute.SplitTransition)2 LoadingResult (com.google.devtools.build.lib.pkgcache.LoadingResult)2 PackageCacheOptions (com.google.devtools.build.lib.pkgcache.PackageCacheOptions)2 ValueOrException (com.google.devtools.build.skyframe.ValueOrException)2