Search in sources :

Example 1 with BuildInfoContext

use of com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoContext 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

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