use of com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment in project bazel by bazelbuild.
the class BuildConfigurationFunction method getConfigurationFragments.
private Set<Fragment> getConfigurationFragments(BuildConfigurationValue.Key key, Environment env) throws InvalidConfigurationException, InterruptedException {
// Get SkyKeys for the fragments we need to load.
Set<SkyKey> fragmentKeys = new LinkedHashSet<>();
for (Class<? extends BuildConfiguration.Fragment> fragmentClass : key.getFragments()) {
fragmentKeys.add(ConfigurationFragmentValue.key(key.getBuildOptions(), fragmentClass, ruleClassProvider));
}
// Load them as Skyframe deps.
Map<SkyKey, ValueOrException<InvalidConfigurationException>> fragmentDeps = env.getValuesOrThrow(fragmentKeys, InvalidConfigurationException.class);
if (env.valuesMissing()) {
return null;
}
// Collect and return the results.
ImmutableSet.Builder<Fragment> fragments = ImmutableSet.builder();
for (ValueOrException<InvalidConfigurationException> value : fragmentDeps.values()) {
BuildConfiguration.Fragment fragment = ((ConfigurationFragmentValue) value.get()).getFragment();
if (fragment != null) {
fragments.add(fragment);
}
}
return fragments.build();
}
use of com.google.devtools.build.lib.analysis.config.BuildConfiguration.Fragment 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);
}
}
Aggregations