Search in sources :

Example 1 with BuildInfoKey

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

use of com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey in project bazel by bazelbuild.

the class SkyframeExecutor method injectBuildInfoFactories.

/**
   * Injects the build info factory map that will be used when constructing build info
   * actions/artifacts. Unchanged across the life of the Blaze server, although it must be injected
   * each time the evaluator is created.
   */
private void injectBuildInfoFactories() {
    ImmutableMap.Builder<BuildInfoKey, BuildInfoFactory> factoryMapBuilder = ImmutableMap.builder();
    for (BuildInfoFactory factory : buildInfoFactories) {
        factoryMapBuilder.put(factory.getKey(), factory);
    }
    PrecomputedValue.BUILD_INFO_FACTORIES.set(injectable(), factoryMapBuilder.build());
}
Also used : BuildInfoKey(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey) BuildInfoFactory(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with BuildInfoKey

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

Example 4 with BuildInfoKey

use of com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey in project bazel by bazelbuild.

the class CachingAnalysisEnvironment method collectDebugInfoAndCrash.

// See SkyframeBuildView#getWorkspaceStatusValues for the code that this method is attempting to
// verify.
private NullPointerException collectDebugInfoAndCrash(BuildInfoKey key, BuildConfiguration config) throws InterruptedException {
    String debugInfo = key + " " + config;
    Preconditions.checkState(skyframeEnv.valuesMissing(), debugInfo);
    Map<BuildInfoKey, BuildInfoFactory> buildInfoFactories = Preconditions.checkNotNull(PrecomputedValue.BUILD_INFO_FACTORIES.get(skyframeEnv), debugInfo);
    BuildInfoFactory buildInfoFactory = Preconditions.checkNotNull(buildInfoFactories.get(key), debugInfo);
    Preconditions.checkState(buildInfoFactory.isEnabled(config), debugInfo);
    throw new NullPointerException("BuildInfoCollectionValue shouldn't have been null");
}
Also used : BuildInfoKey(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey) BuildInfoFactory(com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory)

Aggregations

BuildInfoFactory (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory)4 BuildInfoKey (com.google.devtools.build.lib.analysis.buildinfo.BuildInfoFactory.BuildInfoKey)4 BuildInfoKeyAndConfig (com.google.devtools.build.lib.skyframe.BuildInfoCollectionValue.BuildInfoKeyAndConfig)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 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