Search in sources :

Example 1 with NdkLibraryBuilder

use of com.facebook.buck.android.NdkLibraryBuilder in project buck by facebook.

the class ProjectTest method testNdkLibraryHasCorrectPath.

@Test
public void testNdkLibraryHasCorrectPath() throws Exception {
    BuildRuleResolver ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    // Build up a the graph that corresponds to:
    //
    // ndk_library(
    //   name = 'foo-jni'
    // )
    //
    // project_config(
    //   src_target = ':foo-jni',
    // )
    ProjectFilesystem projectFilesystem = new FakeProjectFilesystem();
    BuildTarget fooJni = BuildTargetFactory.newInstance("//third_party/java/foo/jni:foo-jni");
    NdkLibrary ndkLibrary = new NdkLibraryBuilder(fooJni).build(ruleResolver, projectFilesystem);
    ProjectConfig ndkProjectConfig = ProjectConfigBuilder.createBuilder(BuildTargetFactory.newInstance("//third_party/java/foo/jni:project_config")).setSrcRule(ndkLibrary.getBuildTarget()).build(ruleResolver);
    ProjectWithModules projectWithModules = getModulesForActionGraph(ruleResolver, ImmutableSortedSet.of(ndkProjectConfig), null, /* javaPackageFinder */
    null);
    List<SerializableModule> modules = projectWithModules.modules;
    assertEquals("Should be one module for the ndk_library.", 1, modules.size());
    SerializableModule androidLibraryModule = Iterables.getOnlyElement(modules);
    assertListEquals(ImmutableList.of(SerializableDependentModule.newSourceFolder(), SerializableDependentModule.newInheritedJdk()), androidLibraryModule.getDependencies());
    assertEquals(Paths.get(String.format("../../../../%s", ndkLibrary.getLibraryPath())), androidLibraryModule.nativeLibs);
}
Also used : ProjectConfig(com.facebook.buck.rules.ProjectConfig) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) BuildTarget(com.facebook.buck.model.BuildTarget) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) NdkLibrary(com.facebook.buck.android.NdkLibrary) NdkLibraryBuilder(com.facebook.buck.android.NdkLibraryBuilder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) Test(org.junit.Test)

Aggregations

NdkLibrary (com.facebook.buck.android.NdkLibrary)1 NdkLibraryBuilder (com.facebook.buck.android.NdkLibraryBuilder)1 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)1 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)1 ProjectConfig (com.facebook.buck.rules.ProjectConfig)1 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)1 Test (org.junit.Test)1