Search in sources :

Example 11 with Fingerprint

use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.

the class ExtraActionSpec method getActionId.

/**
   * Creates a unique id for the action shadowed by this extra_action.
   *
   * We need to have a unique id for the extra_action to use. We build this
   * from the owner's  label and the shadowed action id (which is only
   * guaranteed to be unique per target). Together with the subfolder
   * matching the original target's package name, we believe this is enough
   * of a uniqueness guarantee.
   */
@VisibleForTesting
public static String getActionId(ActionOwner owner, Action action) {
    Fingerprint f = new Fingerprint();
    f.addString(owner.getLabel().toString());
    ImmutableList<AspectDescriptor> aspectDescriptors = owner.getAspectDescriptors();
    f.addInt(aspectDescriptors.size());
    for (AspectDescriptor aspectDescriptor : aspectDescriptors) {
        f.addString(aspectDescriptor.getDescription());
    }
    f.addString(action.getKey());
    return f.hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint) AspectDescriptor(com.google.devtools.build.lib.packages.AspectDescriptor) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Example 12 with Fingerprint

use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.

the class TestAction method computeKey.

@Override
protected String computeKey() {
    Fingerprint f = new Fingerprint();
    f.addPaths(Artifact.asSortedPathFragments(getOutputs()));
    f.addPaths(Artifact.asSortedPathFragments(getMandatoryInputs()));
    return f.hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint)

Example 13 with Fingerprint

use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.

the class SymlinkTreeAction method computeKey.

@Override
protected String computeKey() {
    Fingerprint f = new Fingerprint();
    f.addString(GUID);
    f.addInt(filesetTree ? 1 : 0);
    return f.hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint)

Example 14 with Fingerprint

use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.

the class FileWriteAction method computeKey.

/**
   * Computes the Action key for this action by computing the fingerprint for
   * the file contents.
   */
@Override
protected String computeKey() {
    Fingerprint f = new Fingerprint();
    f.addString(GUID);
    f.addString(String.valueOf(makeExecutable));
    f.addString(getFileContents());
    return f.hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint)

Example 15 with Fingerprint

use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.

the class SourceManifestAction method computeKey.

@Override
protected String computeKey() {
    Fingerprint f = new Fingerprint();
    f.addString(GUID);
    f.addBoolean(runfiles.getLegacyExternalRunfiles());
    f.addPath(runfiles.getSuffix());
    Map<PathFragment, Artifact> symlinks = runfiles.getSymlinksAsMap(null);
    f.addInt(symlinks.size());
    for (Map.Entry<PathFragment, Artifact> symlink : symlinks.entrySet()) {
        f.addPath(symlink.getKey());
        f.addPath(symlink.getValue().getPath());
    }
    Map<PathFragment, Artifact> rootSymlinks = runfiles.getRootSymlinksAsMap(null);
    f.addInt(rootSymlinks.size());
    for (Map.Entry<PathFragment, Artifact> rootSymlink : rootSymlinks.entrySet()) {
        f.addPath(rootSymlink.getKey());
        f.addPath(rootSymlink.getValue().getPath());
    }
    for (Artifact artifact : runfiles.getArtifactsWithoutMiddlemen()) {
        f.addPath(artifact.getRootRelativePath());
        f.addPath(artifact.getPath());
    }
    return f.hexDigestAndReset();
}
Also used : Fingerprint(com.google.devtools.build.lib.util.Fingerprint) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) Map(java.util.Map) Artifact(com.google.devtools.build.lib.actions.Artifact)

Aggregations

Fingerprint (com.google.devtools.build.lib.util.Fingerprint)38 Artifact (com.google.devtools.build.lib.actions.Artifact)9 IOException (java.io.IOException)6 Map (java.util.Map)6 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)5 RepositoryFunctionException (com.google.devtools.build.lib.rules.repository.RepositoryFunction.RepositoryFunctionException)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Rule (com.google.devtools.build.lib.packages.Rule)2 InputStream (java.io.InputStream)2 TreeMap (java.util.TreeMap)2 Nullable (javax.annotation.Nullable)2 Test (org.junit.Test)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableSortedMap (com.google.common.collect.ImmutableSortedMap)1 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)1 BlazeDirectories (com.google.devtools.build.lib.analysis.BlazeDirectories)1 RunUnder (com.google.devtools.build.lib.analysis.config.RunUnder)1 MavenServerRule (com.google.devtools.build.lib.bazel.rules.workspace.MavenServerRule)1 AspectDescriptor (com.google.devtools.build.lib.packages.AspectDescriptor)1 NoSuchThingException (com.google.devtools.build.lib.packages.NoSuchThingException)1