Search in sources :

Example 6 with AllExistingProjectFilesystem

use of com.facebook.buck.testutil.AllExistingProjectFilesystem in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method createBuildRuleDefault.

@Test
public void createBuildRuleDefault() throws Exception {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET);
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) libBuilder.build(resolver, filesystem, targetGraph);
    PrebuiltCxxLibraryDescription.Arg arg = libBuilder.build().getConstructorArg();
    // Verify static native linkable input.
    NativeLinkableInput expectedStaticLinkableInput = NativeLinkableInput.of(ImmutableList.of(FileListableLinkerInputArg.withSourcePathArg(SourcePathArg.of(new PathSourcePath(filesystem, getStaticLibraryPath(arg))))), ImmutableSet.of(), ImmutableSet.of());
    assertEquals(expectedStaticLinkableInput, lib.getNativeLinkableInput(CXX_PLATFORM, Linker.LinkableDepType.STATIC));
    // Verify shared native linkable input.
    NativeLinkableInput expectedSharedLinkableInput = NativeLinkableInput.of(ImmutableList.of(SourcePathArg.of(new PathSourcePath(filesystem, getSharedLibraryPath(arg)))), ImmutableSet.of(), ImmutableSet.of());
    assertEquals(expectedSharedLinkableInput, lib.getNativeLinkableInput(CXX_PLATFORM, Linker.LinkableDepType.SHARED));
}
Also used : PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 7 with AllExistingProjectFilesystem

use of com.facebook.buck.testutil.AllExistingProjectFilesystem in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method exportedPlatformHeaders.

@Test
public void exportedPlatformHeaders() throws Exception {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET).setExportedPlatformHeaders(PatternMatchedCollection.<SourceList>builder().add(Pattern.compile(CXX_PLATFORM.getFlavor().toString()), SourceList.ofNamedSources(ImmutableSortedMap.of("foo.h", new FakeSourcePath("foo.h")))).add(Pattern.compile("DO NOT MATCH ANYTNING"), SourceList.ofNamedSources(ImmutableSortedMap.of("bar.h", new FakeSourcePath("bar.h")))).build());
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
    PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) libBuilder.build(resolver, filesystem, targetGraph);
    // Verify the preprocessable input is as expected.
    CxxPreprocessorInput input = lib.getCxxPreprocessorInput(CXX_PLATFORM, HeaderVisibility.PUBLIC);
    assertThat(getHeaderNames(input.getIncludes()), Matchers.hasItem(filesystem.getPath("foo.h")));
    assertThat(getHeaderNames(input.getIncludes()), Matchers.not(Matchers.hasItem(filesystem.getPath("bar.h"))));
    assertThat(ImmutableSortedSet.copyOf(input.getDeps(resolver, ruleFinder)), Matchers.equalTo(resolver.getAllRules(getInputRules(lib))));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) SourceList(com.facebook.buck.rules.coercer.SourceList) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 8 with AllExistingProjectFilesystem

use of com.facebook.buck.testutil.AllExistingProjectFilesystem in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method versionSubDir.

@Test
public void versionSubDir() throws Exception {
    BuildTarget dep = BuildTargetFactory.newInstance("//:dep");
    PrebuiltCxxLibraryBuilder depBuilder = new PrebuiltCxxLibraryBuilder(dep);
    PrebuiltCxxLibraryBuilder builder = new PrebuiltCxxLibraryBuilder(TARGET);
    builder.setSelectedVersions(ImmutableMap.of(dep, Version.of("1.0")));
    builder.setVersionedSubDir(VersionMatchedCollection.<String>builder().add(ImmutableMap.of(dep, Version.of("1.0")), "sub-dir").build());
    TargetGraph graph = TargetGraphFactory.newInstance(depBuilder.build(), builder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(graph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    depBuilder.build(resolver, filesystem, graph);
    PrebuiltCxxLibrary lib = (PrebuiltCxxLibrary) builder.build(resolver, filesystem, graph);
    NativeLinkableInput nativeLinkableInput = lib.getNativeLinkableInput(CXX_PLATFORM, Linker.LinkableDepType.STATIC);
    assertThat(Arg.stringify(nativeLinkableInput.getArgs(), pathResolver).get(0), Matchers.equalTo(filesystem.resolve("sub-dir").resolve(getStaticLibraryPath(builder.build().getConstructorArg())).toString()));
}
Also used : BuildTarget(com.facebook.buck.model.BuildTarget) TargetGraph(com.facebook.buck.rules.TargetGraph) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 9 with AllExistingProjectFilesystem

use of com.facebook.buck.testutil.AllExistingProjectFilesystem in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method providedDoNotReturnSharedLibs.

@Test
public void providedDoNotReturnSharedLibs() throws Exception {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder prebuiltCxxLibraryBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule")).setProvided(true);
    TargetGraph targetGraph = TargetGraphFactory.newInstance(prebuiltCxxLibraryBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) prebuiltCxxLibraryBuilder.build(resolver, filesystem, targetGraph);
    assertThat(rule.getSharedLibraries(CXX_PLATFORM).entrySet(), empty());
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) TargetGraph(com.facebook.buck.rules.TargetGraph) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Example 10 with AllExistingProjectFilesystem

use of com.facebook.buck.testutil.AllExistingProjectFilesystem in project buck by facebook.

the class PrebuiltCxxLibraryDescriptionTest method nativeLinkTargetDeps.

@Test
public void nativeLinkTargetDeps() throws Exception {
    PrebuiltCxxLibraryBuilder depBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:dep"));
    PrebuiltCxxLibraryBuilder exportedDepBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:exported_dep"));
    PrebuiltCxxLibraryBuilder ruleBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule")).setExportedDeps(ImmutableSortedSet.of(depBuilder.getTarget(), exportedDepBuilder.getTarget()));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(depBuilder.build(), exportedDepBuilder.build(), ruleBuilder.build());
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    PrebuiltCxxLibrary dep = (PrebuiltCxxLibrary) depBuilder.build(resolver, filesystem, targetGraph);
    PrebuiltCxxLibrary exportedDep = (PrebuiltCxxLibrary) exportedDepBuilder.build(resolver, filesystem, targetGraph);
    PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) ruleBuilder.build(resolver, filesystem, targetGraph);
    assertThat(ImmutableList.copyOf(rule.getNativeLinkTarget(CXX_PLATFORM).get().getNativeLinkTargetDeps(CXX_PLATFORM)), Matchers.hasItems(dep, exportedDep));
}
Also used : TargetGraph(com.facebook.buck.rules.TargetGraph) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) Test(org.junit.Test)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)26 AllExistingProjectFilesystem (com.facebook.buck.testutil.AllExistingProjectFilesystem)26 Test (org.junit.Test)26 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)24 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)22 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)22 TargetGraph (com.facebook.buck.rules.TargetGraph)18 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)10 FakeSourcePath (com.facebook.buck.rules.FakeSourcePath)9 PathSourcePath (com.facebook.buck.rules.PathSourcePath)9 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)8 BuildTarget (com.facebook.buck.model.BuildTarget)5 SourcePath (com.facebook.buck.rules.SourcePath)4 Path (java.nio.file.Path)3 PBXShellScriptBuildPhase (com.facebook.buck.apple.xcode.xcodeproj.PBXShellScriptBuildPhase)2 ReactNativeBuckConfig (com.facebook.buck.js.ReactNativeBuckConfig)2 CellPathResolver (com.facebook.buck.rules.CellPathResolver)2 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)2 RuleKey (com.facebook.buck.rules.RuleKey)2 LinkOption (java.nio.file.LinkOption)2