use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.
the class FileSystemTest method testGetMD5Digest.
@Test
public void testGetMD5Digest() throws Exception {
byte[] buffer = new byte[500000];
for (int i = 0; i < buffer.length; ++i) {
buffer[i] = 1;
}
FileSystemUtils.writeContent(xFile, buffer);
Fingerprint fp = new Fingerprint();
fp.addBytes(buffer);
assertEquals(BaseEncoding.base16().lowerCase().encode(xFile.getMD5Digest()), fp.hexDigestAndReset());
}
use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.
the class FileSystemTest method testGetMD5DigestForEmptyFile.
@Test
public void testGetMD5DigestForEmptyFile() throws Exception {
Fingerprint fp = new Fingerprint();
fp.addBytes(new byte[0]);
assertEquals(BaseEncoding.base16().lowerCase().encode(xFile.getMD5Digest()), fp.hexDigestAndReset());
}
use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.
the class AndroidDeployInfoAction method computeKey.
@Override
protected String computeKey() {
Fingerprint f = new Fingerprint().addString(GUID);
try (InputStream in = byteString.newInput()) {
byte[] buffer = new byte[512];
int amountRead;
while ((amountRead = in.read(buffer)) != -1) {
f.addBytes(buffer, 0, amountRead);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return f.hexDigestAndReset();
}
use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.
the class ApkManifestAction method computeKey.
@Override
protected String computeKey() {
// Use fake hashes for the purposes of the action's key, because the hashes are retrieved from
// the MetadataHandler, which is available at only action-execution time. This should be ok
// because if an input artifact changes (and hence its hash changes), the action should be rerun
// anyway. This is more for the purpose of putting the structure of the output data into the
// key.
ApkManifestCreator manifestCreator = new ApkManifestCreator(new ArtifactDigester() {
@Override
public byte[] getDigest(Artifact artifact) {
return Ints.toByteArray(artifact.getExecPathString().hashCode());
}
});
ApkManifest manifest;
try {
manifest = manifestCreator.createManifest();
} catch (IOException e) {
// ArtifactDigester that uses the MetadataHandler.
throw new IllegalStateException(e);
}
return new Fingerprint().addString(GUID).addBoolean(textOutput).addBytes(manifest.toByteArray()).hexDigestAndReset();
}
use of com.google.devtools.build.lib.util.Fingerprint in project bazel by bazelbuild.
the class ExtraActionSpec method getOwnerDigest.
/**
* Calculates a digest representing the rule context. We use the digest instead of the
* original value as the original value might lead to a filename that is too long.
* By using a digest, tools can deterministically find all extra_action outputs for a given
* target, without having to open every file in the package.
*/
private static String getOwnerDigest(RuleContext ruleContext) {
Fingerprint f = new Fingerprint();
f.addString(ruleContext.getLabel().toString());
return f.hexDigestAndReset();
}
Aggregations