Search in sources :

Example 1 with UncachedRuleKeyBuilder

use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.

the class CxxHeadersDirTest method getRuleKey.

private RuleKey getRuleKey(ProjectFilesystem filesystem, CxxHeaders cxxHeaders) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(filesystem)));
    DefaultRuleKeyFactory factory = new DefaultRuleKeyFactory(0, fileHashCache, pathResolver, ruleFinder);
    UncachedRuleKeyBuilder builder = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, fileHashCache, factory);
    cxxHeaders.appendToRuleKey(builder);
    return builder.build();
}
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) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver)

Example 2 with UncachedRuleKeyBuilder

use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.

the class HeaderVerificationTest method getRuleKey.

private RuleKey getRuleKey(HeaderVerification headerVerification) {
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
    FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(new FakeProjectFilesystem())));
    DefaultRuleKeyFactory factory = new DefaultRuleKeyFactory(0, fileHashCache, resolver, ruleFinder);
    RuleKeyBuilder<RuleKey> builder = new UncachedRuleKeyBuilder(ruleFinder, resolver, fileHashCache, factory);
    builder.setReflectively("headerVerification", headerVerification);
    return builder.build();
}
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) RuleKey(com.facebook.buck.rules.RuleKey) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver)

Example 3 with UncachedRuleKeyBuilder

use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.

the class CommandToolTest method sourcePathsContributeToRuleKeys.

@Test
public void sourcePathsContributeToRuleKeys() {
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    SourcePath path = new FakeSourcePath("input");
    CommandTool tool = new CommandTool.Builder().addArg(SourcePathArg.of(path)).build();
    FileHashCache hashCache = FakeFileHashCache.createFromStrings(ImmutableMap.of("input", Strings.repeat("a", 40)));
    DefaultRuleKeyFactory ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
    RuleKey ruleKey = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", tool).build();
    hashCache = FakeFileHashCache.createFromStrings(ImmutableMap.of("input", Strings.repeat("b", 40)));
    ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
    RuleKey changedRuleKey = new UncachedRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", tool).build();
    assertThat(ruleKey, Matchers.not(Matchers.equalTo(changedRuleKey)));
}
Also used : FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) FileHashCache(com.facebook.buck.util.cache.FileHashCache) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) GenruleBuilder(com.facebook.buck.shell.GenruleBuilder) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) Test(org.junit.Test)

Example 4 with UncachedRuleKeyBuilder

use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.

the class SanitizedArgTest method createRuleKeyBuilder.

private RuleKeyBuilder<RuleKey> createRuleKeyBuilder() {
    FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
    FileHashCache fileHashCache = new StackedFileHashCache(ImmutableList.of(DefaultFileHashCache.createDefaultFileHashCache(projectFilesystem)));
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver resolver = new SourcePathResolver(ruleFinder);
    return new UncachedRuleKeyBuilder(ruleFinder, resolver, fileHashCache, new DefaultRuleKeyFactory(0, fileHashCache, resolver, ruleFinder));
}
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) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) StackedFileHashCache(com.facebook.buck.util.cache.StackedFileHashCache) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver)

Example 5 with UncachedRuleKeyBuilder

use of com.facebook.buck.rules.keys.UncachedRuleKeyBuilder in project buck by facebook.

the class RuleKeyTest method subclassWithNoopSetter.

@Test
public void subclassWithNoopSetter() {
    class NoopSetterRuleKeyBuilder extends UncachedRuleKeyBuilder {

        public NoopSetterRuleKeyBuilder(SourcePathRuleFinder ruleFinder, SourcePathResolver pathResolver, FileHashCache hashCache, RuleKeyFactory<RuleKey> defaultRuleKeyFactory) {
            super(ruleFinder, pathResolver, hashCache, defaultRuleKeyFactory);
        }

        @Override
        protected NoopSetterRuleKeyBuilder setSourcePath(SourcePath sourcePath) {
            return this;
        }
    }
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()));
    SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
    FileHashCache hashCache = new FakeFileHashCache(ImmutableMap.of());
    RuleKeyFactory<RuleKey> ruleKeyFactory = new DefaultRuleKeyFactory(0, hashCache, pathResolver, ruleFinder);
    RuleKey nullRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).build();
    RuleKey noopRuleKey = new NoopSetterRuleKeyBuilder(ruleFinder, pathResolver, hashCache, ruleKeyFactory).setReflectively("key", new FakeSourcePath("value")).build();
    assertThat(noopRuleKey, is(equalTo(nullRuleKey)));
}
Also used : NullFileHashCache(com.facebook.buck.util.cache.NullFileHashCache) 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) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) FakeFileHashCache(com.facebook.buck.testutil.FakeFileHashCache) UncachedRuleKeyBuilder(com.facebook.buck.rules.keys.UncachedRuleKeyBuilder) DefaultRuleKeyFactory(com.facebook.buck.rules.keys.DefaultRuleKeyFactory) RuleKeyFactory(com.facebook.buck.rules.keys.RuleKeyFactory) Test(org.junit.Test)

Aggregations

DefaultRuleKeyFactory (com.facebook.buck.rules.keys.DefaultRuleKeyFactory)5 UncachedRuleKeyBuilder (com.facebook.buck.rules.keys.UncachedRuleKeyBuilder)5 FileHashCache (com.facebook.buck.util.cache.FileHashCache)5 DefaultFileHashCache (com.facebook.buck.util.cache.DefaultFileHashCache)4 StackedFileHashCache (com.facebook.buck.util.cache.StackedFileHashCache)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)3 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)3 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)3 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)3 FakeFileHashCache (com.facebook.buck.testutil.FakeFileHashCache)2 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 Test (org.junit.Test)2 RuleKey (com.facebook.buck.rules.RuleKey)1 RuleKeyFactory (com.facebook.buck.rules.keys.RuleKeyFactory)1 GenruleBuilder (com.facebook.buck.shell.GenruleBuilder)1 NullFileHashCache (com.facebook.buck.util.cache.NullFileHashCache)1