Search in sources :

Example 1 with BuildInfoKeyAndConfig

use of com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig in project bazel by bazelbuild.

the class SkyframeBuildView method getWorkspaceStatusValues.

/**
   * Because we don't know what build-info artifacts this configured target may request, we
   * conservatively register a dep on all of them.
   */
// TODO(bazel-team): Allow analysis to return null so the value builder can exit and wait for a
// restart deps are not present.
private static boolean getWorkspaceStatusValues(Environment env, BuildConfiguration config) throws InterruptedException {
    env.getValue(WorkspaceStatusValue.SKY_KEY);
    Map<BuildInfoKey, BuildInfoFactory> buildInfoFactories = PrecomputedValue.BUILD_INFO_FACTORIES.get(env);
    if (buildInfoFactories == null) {
        return false;
    }
    // These factories may each create their own build info artifacts, all depending on the basic
    // build-info.txt and build-changelist.txt.
    List<SkyKey> depKeys = Lists.newArrayList();
    for (BuildInfoKey key : buildInfoFactories.keySet()) {
        if (buildInfoFactories.get(key).isEnabled(config)) {
            depKeys.add(BuildInfoCollectionValue.key(new BuildInfoKeyAndConfig(key, config)));
        }
    }
    env.getValues(depKeys);
    return !env.valuesMissing();
}
Also used : BuildInfoKey(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey) SkyKey(com.google.devtools.build.skyframe.SkyKey) BuildInfoKeyAndConfig(com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig) BuildInfoFactory(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory)

Example 2 with BuildInfoKeyAndConfig

use of com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig in project bazel by bazelbuild.

the class BuildInfoCollectionFunction method compute.

@Override
public SkyValue compute(SkyKey skyKey, Environment env) throws InterruptedException {
    final BuildInfoKeyAndConfig keyAndConfig = (BuildInfoKeyAndConfig) skyKey.argument();
    WorkspaceStatusValue infoArtifactValue = (WorkspaceStatusValue) env.getValue(WorkspaceStatusValue.SKY_KEY);
    if (infoArtifactValue == null) {
        return null;
    }
    Map<BuildInfoKey, BuildInfoFactory> buildInfoFactories = PrecomputedValue.BUILD_INFO_FACTORIES.get(env);
    if (buildInfoFactories == null) {
        return null;
    }
    WorkspaceNameValue nameValue = (WorkspaceNameValue) env.getValue(WorkspaceNameValue.key());
    if (nameValue == null) {
        return null;
    }
    RepositoryName repositoryName = RepositoryName.createFromValidStrippedName(nameValue.maybeGetName());
    final ArtifactFactory factory = artifactFactory.get();
    BuildInfoContext context = new BuildInfoContext() {

        @Override
        public Artifact getBuildInfoArtifact(PathFragment rootRelativePath, Root root, BuildInfoType type) {
            return type == BuildInfoType.NO_REBUILD ? factory.getConstantMetadataArtifact(rootRelativePath, root, keyAndConfig) : factory.getDerivedArtifact(rootRelativePath, root, keyAndConfig);
        }
    };
    return new BuildInfoCollectionValue(buildInfoFactories.get(keyAndConfig.getInfoKey()).create(context, keyAndConfig.getConfig(), infoArtifactValue.getStableArtifact(), infoArtifactValue.getVolatileArtifact(), repositoryName));
}
Also used : Root(com.google.devtools.build.lib.actions.Root) BuildInfoType(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoType) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RepositoryName(com.google.devtools.build.lib.cmdline.RepositoryName) BuildInfoKey(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey) BuildInfoContext(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoContext) ArtifactFactory(com.google.devtools.build.lib.actions.ArtifactFactory) BuildInfoKeyAndConfig(com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig) BuildInfoFactory(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory)

Aggregations

BuildInfoFactory (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory)2 BuildInfoKey (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey)2 BuildInfoKeyAndConfig (com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig)2 ArtifactFactory (com.google.devtools.build.lib.actions.ArtifactFactory)1 Root (com.google.devtools.build.lib.actions.Root)1 BuildInfoContext (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoContext)1 BuildInfoType (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoType)1 RepositoryName (com.google.devtools.build.lib.cmdline.RepositoryName)1 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)1 SkyKey (com.google.devtools.build.skyframe.SkyKey)1