use of com.facebook.buck.util.sha1.Sha1HashCode in project buck by facebook.
the class Sha1Command method run.
@Override
public int run() throws EdenError, IOException, TException {
Optional<EdenClient> client = EdenClient.newInstance();
if (!client.isPresent()) {
System.err.println("Could not connect to Eden");
return 1;
}
Path mountPoint = Paths.get(this.mountPoint);
EdenMount mount = client.get().getMountFor(mountPoint);
for (String path : paths) {
Path entry = mountPoint.relativize(Paths.get(path));
Sha1HashCode sha1 = mount.getSha1(entry);
System.out.printf("%s %s\n", entry, sha1);
}
return 0;
}
use of com.facebook.buck.util.sha1.Sha1HashCode in project buck by facebook.
the class FakeProjectFilesystem method computeSha1.
/**
* Does not support symlinks.
*/
@Override
public Sha1HashCode computeSha1(Path pathRelativeToProjectRootOrJustAbsolute) throws IOException {
if (!exists(pathRelativeToProjectRootOrJustAbsolute)) {
throw new NoSuchFileException(pathRelativeToProjectRootOrJustAbsolute.toString());
}
// Because this class is a fake, the file contents may not be available as a stream, so we load
// all of the contents into memory as a byte[] and then hash them.
byte[] fileContents = getFileBytes(pathRelativeToProjectRootOrJustAbsolute);
HashCode hashCode = Hashing.sha1().newHasher().putBytes(fileContents).hash();
return Sha1HashCode.fromHashCode(hashCode);
}
use of com.facebook.buck.util.sha1.Sha1HashCode in project buck by facebook.
the class CxxPrecompiledHeaderRuleTest method deterministicHashesForSharedPCHs.
@Test
public void deterministicHashesForSharedPCHs() throws Exception {
assumeTrue(platformOkForPCHTests());
Sha1HashCode pchHashA = null;
workspace.runBuckBuild("//determinism/a:main").assertSuccess();
BuckBuildLog buildLogA = workspace.getBuildLog();
for (BuildTarget target : buildLogA.getAllTargets()) {
if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
pchHashA = buildLogA.getLogEntry(target).getRuleKey();
System.err.println("A: " + pchHashA);
}
}
assertNotNull(pchHashA);
Sha1HashCode pchHashB = null;
workspace.runBuckBuild("//determinism/b:main").assertSuccess();
BuckBuildLog buildLogB = workspace.getBuildLog();
for (BuildTarget target : buildLogB.getAllTargets()) {
if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
pchHashB = buildLogB.getLogEntry(target).getRuleKey();
System.err.println("B: " + pchHashB);
}
}
assertNotNull(pchHashB);
assertEquals(pchHashA, pchHashB);
Sha1HashCode pchHashC = null;
workspace.runBuckBuild("//determinism/c:main").assertSuccess();
BuckBuildLog buildLogC = workspace.getBuildLog();
for (BuildTarget target : buildLogC.getAllTargets()) {
if (target.toString().startsWith("//determinism/lib:pch#default,pch-cxx-")) {
pchHashC = buildLogC.getLogEntry(target).getRuleKey();
System.err.println("C: " + pchHashC);
}
}
assertNotNull(pchHashC);
assertNotEquals(pchHashA, pchHashC);
}
use of com.facebook.buck.util.sha1.Sha1HashCode in project buck by facebook.
the class StubJarTest method ordersChangesResultInADifferentOutputJar.
@Test
public void ordersChangesResultInADifferentOutputJar() throws IOException {
JarPaths paths = createFullAndStubJars(EMPTY_CLASSPATH, "A.java", Joiner.on("\n").join(ImmutableList.of("package com.example.buck;", "public class A {", " protected final static int count = 42;", " public String getGreeting() { return \"hello\"; }", " Class<?> clazz;", " public int other;", "}")));
Sha1HashCode originalHash = filesystem.computeSha1(paths.stubJar);
paths = createFullAndStubJars(EMPTY_CLASSPATH, "A.java", Joiner.on("\n").join(ImmutableList.of("package com.example.buck;", "public class A {", " Class<?> clazz;", " public String getGreeting() { return \"hello\"; }", " protected final static int count = 42;", " public int other;", "}")));
Sha1HashCode secondHash = filesystem.computeSha1(paths.stubJar);
assertNotEquals(originalHash, secondHash);
}
use of com.facebook.buck.util.sha1.Sha1HashCode in project buck by facebook.
the class SmartDexingStep method generateDxCommands.
/**
* Once the {@code .class} files have been split into separate zip files, each must be converted
* to a {@code .dex} file.
*/
private ImmutableList<Step> generateDxCommands(ProjectFilesystem filesystem, Multimap<Path, Path> outputToInputs) {
ImmutableList.Builder<DxPseudoRule> pseudoRules = ImmutableList.builder();
ImmutableMap<Path, Sha1HashCode> dexInputHashes = dexInputHashesProvider.getDexInputHashes();
for (Path outputFile : outputToInputs.keySet()) {
pseudoRules.add(new DxPseudoRule(filesystem, dexInputHashes, ImmutableSet.copyOf(outputToInputs.get(outputFile)), outputFile, successDir.resolve(outputFile.getFileName()), dxOptions, xzCompressionLevel, dxMaxHeapSize));
}
ImmutableList.Builder<Step> steps = ImmutableList.builder();
for (DxPseudoRule pseudoRule : pseudoRules.build()) {
if (!pseudoRule.checkIsCached()) {
steps.addAll(pseudoRule.buildInternal());
}
}
return steps.build();
}
Aggregations