Search in sources :

Example 21 with AllExistingProjectFilesystem

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

the class PrebuiltCxxLibraryDescriptionTest method nativeLinkTargetInput.

@Test
public void nativeLinkTargetInput() throws Exception {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder ruleBuilder = new PrebuiltCxxLibraryBuilder(BuildTargetFactory.newInstance("//:rule")).setExportedLinkerFlags(ImmutableList.of("--exported-flag"));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(ruleBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    PrebuiltCxxLibrary rule = (PrebuiltCxxLibrary) ruleBuilder.build(resolver, filesystem, targetGraph);
    NativeLinkableInput input = rule.getNativeLinkTarget(CXX_PLATFORM).get().getNativeLinkTargetInput(CxxPlatformUtils.DEFAULT_PLATFORM);
    assertThat(Arg.stringify(input.getArgs(), pathResolver), Matchers.hasItems("--exported-flag"));
}
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) 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 22 with AllExistingProjectFilesystem

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

the class PrebuiltCxxLibraryDescriptionTest method locationMacro.

@Test
public void locationMacro() throws NoSuchBuildTargetException {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    CellPathResolver cellRoots = TestCellBuilder.createCellRoots(filesystem);
    Optional<String> libName = Optional.of("test");
    Optional<String> libDir = Optional.of("$(location //other:gen_lib)/");
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    BuildTarget genTarget = BuildTargetFactory.newInstance("//other:gen_lib");
    GenruleBuilder genruleBuilder = GenruleBuilder.newGenruleBuilder(genTarget).setOut("lib_dir");
    BuildRule genRule = genruleBuilder.build(resolver);
    CxxPlatform platform = CxxPlatformUtils.DEFAULT_PLATFORM.withFlavor(InternalFlavor.of("PLATFORM1"));
    Path path = pathResolver.getAbsolutePath(Preconditions.checkNotNull(genRule.getSourcePathToOutput()));
    final SourcePath staticLibraryPath = PrebuiltCxxLibraryDescription.getStaticLibraryPath(TARGET, cellRoots, filesystem, resolver, platform, Optional.empty(), libDir, libName);
    assertEquals(TARGET.getBasePath().resolve(String.format("%s/libtest.a", path)), pathResolver.getAbsolutePath(staticLibraryPath));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) Path(java.nio.file.Path) PathSourcePath(com.facebook.buck.rules.PathSourcePath) GenruleBuilder(com.facebook.buck.shell.GenruleBuilder) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) BuildTarget(com.facebook.buck.model.BuildTarget) CellPathResolver(com.facebook.buck.rules.CellPathResolver) BuildRule(com.facebook.buck.rules.BuildRule) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) AllExistingProjectFilesystem(com.facebook.buck.testutil.AllExistingProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) Test(org.junit.Test)

Example 23 with AllExistingProjectFilesystem

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

the class PrebuiltCxxLibraryDescriptionTest method headerNamespace.

@Test
public void headerNamespace() throws Exception {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    PrebuiltCxxLibraryBuilder libBuilder = new PrebuiltCxxLibraryBuilder(TARGET).setHeaderNamespace("hello").setExportedHeaders(SourceList.ofUnnamedSources(ImmutableSortedSet.of(new FakeSourcePath("foo.h"))));
    TargetGraph targetGraph = TargetGraphFactory.newInstance(libBuilder.build());
    BuildRuleResolver resolver = new BuildRuleResolver(targetGraph, new DefaultTargetNodeToBuildRuleTransformer());
    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.contains(filesystem.getPath("hello", "foo.h")));
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) 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 24 with AllExistingProjectFilesystem

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

the class PrebuiltCxxLibraryDescriptionTest method goodPathNoLocation.

@Test
public void goodPathNoLocation() {
    ProjectFilesystem filesystem = new AllExistingProjectFilesystem();
    BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(resolver));
    CxxPlatform platform = CxxPlatformUtils.DEFAULT_PLATFORM.withFlavor(InternalFlavor.of("PLATFORM1"));
    final SourcePath staticLibraryPath = PrebuiltCxxLibraryDescription.getStaticLibraryPath(TARGET_TWO, TestCellBuilder.createCellRoots(filesystem), filesystem, resolver, platform, Optional.empty(), Optional.of("lib"), Optional.empty());
    assertThat(MorePaths.pathWithUnixSeparators(pathResolver.getAbsolutePath(staticLibraryPath)), Matchers.containsString(String.format("two/%s/libtarget.a", "lib")));
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) 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 25 with AllExistingProjectFilesystem

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

the class PrebuiltCxxLibraryDescriptionTest method providedLibIsNotANativeLinkTargetSoname.

@Test
public void providedLibIsNotANativeLinkTargetSoname() 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);
    assertFalse(rule.getNativeLinkTarget(CXX_PLATFORM).isPresent());
}
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)

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