use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class DistBuildSlaveExecutor method createStackOfDefaultFileHashCache.
private StackedFileHashCache createStackOfDefaultFileHashCache() throws IOException {
ImmutableList.Builder<ProjectFileHashCache> allCachesBuilder = ImmutableList.builder();
Cell rootCell = args.getState().getRootCell();
// 1. Add all cells (including the root cell).
for (Path cellPath : rootCell.getKnownRoots()) {
Cell cell = rootCell.getCell(cellPath);
allCachesBuilder.add(DefaultFileHashCache.createDefaultFileHashCache(cell.getFilesystem()));
}
// 2. Add the Operating System roots.
allCachesBuilder.addAll(DefaultFileHashCache.createOsRootDirectoriesCaches());
return new StackedFileHashCache(allCachesBuilder.build());
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class DistBuildSlaveExecutor method createStackedFileHashesAndPreload.
private StackedFileHashCaches createStackedFileHashesAndPreload() throws IOException {
StackedFileHashCache stackedFileHashCache = createStackOfDefaultFileHashCache();
// Used for rule key computations.
StackedFileHashCache remoteStackedFileHashCache = stackedFileHashCache.newDecoratedFileHashCache(cache -> args.getState().createRemoteFileHashCache(cache));
// Used for the real build.
StackedFileHashCache materializingStackedFileHashCache = stackedFileHashCache.newDecoratedFileHashCache(cache -> {
try {
return args.getState().createMaterializerAndPreload(cache, args.getProvider());
} catch (IOException exception) {
throw new RuntimeException(String.format("Failed to create the Materializer for file system [%s]", cache.getFilesystem()), exception);
}
});
return new StackedFileHashCaches(remoteStackedFileHashCache, materializingStackedFileHashCache);
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class AndroidResourceTest method testInputRuleKeyChangesIfDependencySymbolsChanges.
@Test
public void testInputRuleKeyChangesIfDependencySymbolsChanges() throws Exception {
ProjectFilesystem filesystem = new FakeProjectFilesystem();
TargetNode<?, ?> depNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:dep"), filesystem).setManifest(new FakeSourcePath("manifest")).setRes(Paths.get("res")).build();
TargetNode<?, ?> resourceNode = AndroidResourceBuilder.createBuilder(BuildTargetFactory.newInstance("//:rule"), filesystem).setDeps(ImmutableSortedSet.of(depNode.getBuildTarget())).build();
TargetGraph targetGraph = TargetGraphFactory.newInstance(depNode, resourceNode);
BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
AndroidResource dep = (AndroidResource) resolver.requireRule(depNode.getBuildTarget());
AndroidResource resource = (AndroidResource) resolver.requireRule(resourceNode.getBuildTarget());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
filesystem.writeContentsToPath("something", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
RuleKey original = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
fileHashCache.invalidateAll();
filesystem.writeContentsToPath("something else", pathResolver.getRelativePath(dep.getPathToTextSymbolsFile()));
RuleKey changed = new InputBasedRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder).build(resource);
assertThat(original, Matchers.not(Matchers.equalTo(changed)));
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class CleanCommandTest method createCommandRunnerParams.
private CommandRunnerParams createCommandRunnerParams() throws InterruptedException, IOException {
projectFilesystem = new FakeProjectFilesystem();
Cell cell = new TestCellBuilder().setFilesystem(projectFilesystem).build();
Supplier<AndroidPlatformTarget> androidPlatformTargetSupplier = AndroidPlatformTarget.EXPLODING_ANDROID_PLATFORM_TARGET_SUPPLIER;
return CommandRunnerParams.builder().setConsole(new TestConsole()).setStdIn(new ByteArrayInputStream("".getBytes("UTF-8"))).setCell(cell).setAndroidPlatformTargetSupplier(androidPlatformTargetSupplier).setArtifactCacheFactory(new SingletonArtifactCacheFactory(new NoopArtifactCache())).setBuckEventBus(BuckEventBusFactory.newInstance()).setParser(createMock(Parser.class)).setPlatform(Platform.detect()).setEnvironment(ImmutableMap.copyOf(System.getenv())).setJavaPackageFinder(new FakeJavaPackageFinder()).setObjectMapper(ObjectMappers.newDefaultInstance()).setClock(new DefaultClock()).setProcessManager(Optional.empty()).setWebServer(Optional.empty()).setBuckConfig(FakeBuckConfig.builder().build()).setFileHashCache(new StackedFileHashCache(ImmutableList.of())).setExecutors(ImmutableMap.of()).setBuildEnvironmentDescription(CommandRunnerParamsForTesting.BUILD_ENVIRONMENT_DESCRIPTION).setVersionedTargetGraphCache(new VersionedTargetGraphCache()).setActionGraphCache(new ActionGraphCache(new BroadcastEventListener())).setKnownBuildRuleTypesFactory(new KnownBuildRuleTypesFactory(new FakeProcessExecutor(), new FakeAndroidDirectoryResolver())).build();
}
use of com.facebook.buck.util.cache.StackedFileHashCache in project buck by facebook.
the class CxxTestDescriptionTest method getRuleKey.
private RuleKey getRuleKey(BuildRuleResolver resolver, BuildRule rule) {
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(rule.getProjectFilesystem())));
DefaultRuleKeyFactory factory = new DefaultRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder);
return factory.build(rule);
}
Aggregations