use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class PostConfiguredTargetFunction method compute.
@Nullable
@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws SkyFunctionException, InterruptedException {
ImmutableMap<ActionAnalysisMetadata, ConflictException> badActions = PrecomputedValue.BAD_ACTIONS.get(env);
ConfiguredTargetValue ctValue = (ConfiguredTargetValue) env.getValue(ConfiguredTargetValue.key((ConfiguredTargetKey) skyKey.argument()));
if (env.valuesMissing()) {
return null;
}
for (ActionAnalysisMetadata action : ctValue.getActions()) {
if (badActions.containsKey(action)) {
throw new ActionConflictFunctionException(badActions.get(action));
}
}
ConfiguredTarget ct = ctValue.getConfiguredTarget();
TargetAndConfiguration ctgValue = new TargetAndConfiguration(ct.getTarget(), ct.getConfiguration());
ImmutableMap<Label, ConfigMatchingProvider> configConditions = getConfigurableAttributeConditions(ctgValue, env);
if (configConditions == null) {
return null;
}
OrderedSetMultimap<Attribute, Dependency> deps;
try {
BuildConfiguration hostConfiguration = buildViewProvider.getSkyframeBuildView().getHostConfiguration(ct.getConfiguration());
SkyframeDependencyResolver resolver = buildViewProvider.getSkyframeBuildView().createDependencyResolver(env);
// We don't track root causes here - this function is only invoked for successfully analyzed
// targets - as long as we redo the exact same steps here as in ConfiguredTargetFunction, this
// can never fail.
deps = resolver.dependentNodeMap(ctgValue, hostConfiguration, /*aspect=*/
null, configConditions);
if (ct.getConfiguration() != null && ct.getConfiguration().useDynamicConfigurations()) {
deps = ConfiguredTargetFunction.getDynamicConfigurations(env, ctgValue, deps, hostConfiguration, ruleClassProvider);
}
} catch (EvalException | ConfiguredTargetFunction.DependencyEvaluationException | InvalidConfigurationException | InconsistentAspectOrderException e) {
throw new PostConfiguredTargetFunctionException(e);
}
env.getValues(Iterables.transform(deps.values(), TO_KEYS));
if (env.valuesMissing()) {
return null;
}
return new PostConfiguredTargetValue(ct);
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testGetExecutable.
@Test
public void testGetExecutable() throws Exception {
ConfiguredTarget turtle = scratchConfiguredTarget("java/com/google/turtle", "turtle_bootstrap", "genrule(name = 'turtle_bootstrap',", " srcs = ['Turtle.java'],", " outs = ['turtle'],", " executable = 1,", " cmd = 'touch $(OUTS)')");
assertEquals("turtle", getExecutable(turtle).getExecPath().getBaseName());
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testD.
@Test
public void testD() throws Exception {
createFiles();
ConfiguredTarget z = getConfiguredTarget("//hello:z");
Artifact y = getOnlyElement(getFilesToBuild(z));
assertEquals(new PathFragment("hello/x/y"), y.getRootRelativePath());
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testGetExecutableForMultipleOuts.
@Test
public void testGetExecutableForMultipleOuts() throws Exception {
ConfiguredTarget turtle = scratchConfiguredTarget("java/com/google/turtle", "turtle_bootstrap", "genrule(name = 'turtle_bootstrap',", " srcs = ['Turtle.java'],", " outs = ['turtle', 'debugdata.txt'],", " cmd = 'touch $(OUTS)')");
assertNull(getExecutable(turtle));
}
use of com.google.devtools.build.lib.analysis.ConfiguredTarget in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testDMultiOutput.
@Test
public void testDMultiOutput() throws Exception {
createFiles();
ConfiguredTarget z = getConfiguredTarget("//hello:w");
List<Artifact> files = getFilesToBuild(z).toList();
assertThat(files).hasSize(2);
assertEquals(new PathFragment("hello/a/b"), files.get(0).getRootRelativePath());
assertEquals(new PathFragment("hello/c/d"), files.get(1).getRootRelativePath());
}
Aggregations