Search in sources :

Example 1 with StackedFileHashCache

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());
}
Also used : Path(java.nio.file.Path) ImmutableList(com.google.common.collect.ImmutableList) ProjectFileHashCache(com.facebook.buck.util.cache.ProjectFileHashCache) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) Cell(com.facebook.buck.rules.Cell)

Example 2 with StackedFileHashCache

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);
}
Also used : StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) IOException(java.io.IOException)

Example 3 with StackedFileHashCache

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)));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) DefaultFileHashCache(com.facebook.buck.util.cache.DefaultFileHashCache) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FileHashCache(com.facebook.buck.util.cache.FileHashCache) InputBasedRuleKeyFactory(com.facebook.buck.rules.keys.InputBasedRuleKeyFactory) RuleKey(com.facebook.buck.rules.RuleKey) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 4 with StackedFileHashCache

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();
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) KnownBuildRuleTypesFactory(com.facebook.buck.rules.KnownBuildRuleTypesFactory) BroadcastEventListener(com.facebook.buck.event.listener.BroadcastEventListener) VersionedTargetGraphCache(com.facebook.buck.versions.VersionedTargetGraphCache) SingletonArtifactCacheFactory(com.facebook.buck.artifact_cache.SingletonArtifactCacheFactory) TestCellBuilder(com.facebook.buck.rules.TestCellBuilder) AndroidPlatformTarget(com.facebook.buck.android.AndroidPlatformTarget) ActionGraphCache(com.facebook.buck.rules.ActionGraphCache) FakeAndroidDirectoryResolver(com.facebook.buck.android.FakeAndroidDirectoryResolver) FakeJavaPackageFinder(com.facebook.buck.jvm.java.FakeJavaPackageFinder) ByteArrayInputStream(java.io.ByteArrayInputStream) NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) FakeProcessExecutor(com.facebook.buck.util.FakeProcessExecutor) DefaultClock(com.facebook.buck.timing.DefaultClock) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) TestConsole(com.facebook.buck.testutil.TestConsole) Cell(com.facebook.buck.rules.Cell)

Example 5 with StackedFileHashCache

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);
}
Also used : DefaultFileHashCache(com.facebook.buck.util.cache.DefaultFileHashCache) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) FileHashCache(com.facebook.buck.util.cache.FileHashCache) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver)

Aggregations

StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)44 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)34 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)33 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)32 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)32 Test (org.junit.Test)31 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)28 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)27 FileHashCache (com.facebook.buck.util.cache.FileHashCache)27 DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)24 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)22 RuleKey (com.facebook.buck.rules.RuleKey)21 Path (java.nio.file.Path)21 PathSourcePath (com.facebook.buck.rules.PathSourcePath)16 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)14 BuildRule (com.facebook.buck.rules.BuildRule)13 SourcePath (com.facebook.buck.rules.SourcePath)13 InputBasedRuleKeyFactory (com.facebook.buck.rules.keys.InputBasedRuleKeyFactory)12 BuildTarget (com.facebook.buck.model.BuildTarget)8 NoopBuildRule (com.facebook.buck.rules.NoopBuildRule)8