Search in sources :

Example 41 with ConfiguredTarget

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);
}
Also used : ConflictException(com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.ConflictException) Attribute(com.google.devtools.build.lib.packages.Attribute) Label(com.google.devtools.build.lib.cmdline.Label) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) ActionAnalysisMetadata(com.google.devtools.build.lib.actions.ActionAnalysisMetadata) Dependency(com.google.devtools.build.lib.analysis.Dependency) EvalException(com.google.devtools.build.lib.syntax.EvalException) InconsistentAspectOrderException(com.google.devtools.build.lib.analysis.DependencyResolver.InconsistentAspectOrderException) InvalidConfigurationException(com.google.devtools.build.lib.analysis.config.InvalidConfigurationException) BuildConfiguration(com.google.devtools.build.lib.analysis.config.BuildConfiguration) TargetAndConfiguration(com.google.devtools.build.lib.analysis.TargetAndConfiguration) ConfigMatchingProvider(com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider) Nullable(javax.annotation.Nullable)

Example 42 with ConfiguredTarget

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());
}
Also used : ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) FileConfiguredTarget(com.google.devtools.build.lib.analysis.FileConfiguredTarget) Test(org.junit.Test)

Example 43 with ConfiguredTarget

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());
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) FileConfiguredTarget(com.google.devtools.build.lib.analysis.FileConfiguredTarget) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Example 44 with ConfiguredTarget

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));
}
Also used : ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) FileConfiguredTarget(com.google.devtools.build.lib.analysis.FileConfiguredTarget) Test(org.junit.Test)

Example 45 with ConfiguredTarget

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());
}
Also used : PathFragment(com.google.devtools.build.lib.vfs.PathFragment) ConfiguredTarget(com.google.devtools.build.lib.analysis.ConfiguredTarget) FileConfiguredTarget(com.google.devtools.build.lib.analysis.FileConfiguredTarget) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Aggregations

ConfiguredTarget (com.google.devtools.build.lib.analysis.ConfiguredTarget)222 Test (org.junit.Test)178 Artifact (com.google.devtools.build.lib.actions.Artifact)51 FileConfiguredTarget (com.google.devtools.build.lib.analysis.FileConfiguredTarget)41 RuleConfiguredTarget (com.google.devtools.build.lib.analysis.RuleConfiguredTarget)25 Label (com.google.devtools.build.lib.cmdline.Label)17 SkylarkProviders (com.google.devtools.build.lib.analysis.SkylarkProviders)15 BuildConfiguration (com.google.devtools.build.lib.analysis.config.BuildConfiguration)13 AnalysisResult (com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)12 Nullable (javax.annotation.Nullable)10 SkylarkClassObject (com.google.devtools.build.lib.packages.SkylarkClassObject)9 Variables (com.google.devtools.build.lib.rules.cpp.CcToolchainFeatures.Variables)9 MergedConfiguredTarget (com.google.devtools.build.lib.analysis.MergedConfiguredTarget)7 Map (java.util.Map)7 OutputGroupProvider (com.google.devtools.build.lib.analysis.OutputGroupProvider)6 TestAspects (com.google.devtools.build.lib.analysis.util.TestAspects)6 Attribute (com.google.devtools.build.lib.packages.Attribute)6 RunfilesProvider (com.google.devtools.build.lib.analysis.RunfilesProvider)5 ConfigMatchingProvider (com.google.devtools.build.lib.analysis.config.ConfigMatchingProvider)5 TestFilteringCompleteEvent (com.google.devtools.build.lib.buildtool.buildevent.TestFilteringCompleteEvent)5