Search in sources :

Example 16 with NdkModuleModel

use of com.android.tools.idea.gradle.project.model.NdkModuleModel in project android by JetBrains.

the class BuildVariantView method getVariantNames.

@Nullable
private static Collection<String> getVariantNames(@NotNull Module module) {
    AndroidModuleModel androidModel = AndroidModuleModel.get(module);
    if (androidModel != null) {
        return androidModel.getVariantNames();
    }
    NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
    if (ndkModuleModel != null) {
        return ndkModuleModel.getVariantNames();
    }
    return null;
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with NdkModuleModel

use of com.android.tools.idea.gradle.project.model.NdkModuleModel in project android by JetBrains.

the class NdkModuleNode method getNativeSourceNodes.

@NotNull
public static Collection<AbstractTreeNode> getNativeSourceNodes(@NotNull Project project, @NotNull NdkModuleModel ndkModuleModel, @NotNull ViewSettings viewSettings) {
    NativeAndroidProject nativeAndroidProject = ndkModuleModel.getAndroidProject();
    Collection<String> sourceFileExtensions = nativeAndroidProject.getFileExtensions().keySet();
    NdkModuleModel.NdkVariant variant = ndkModuleModel.getSelectedVariant();
    Multimap<String, NativeArtifact> nativeLibraries = HashMultimap.create();
    for (NativeArtifact artifact : variant.getArtifacts()) {
        String artifactOutputFileName = artifact.getOutputFile().getName();
        nativeLibraries.put(artifactOutputFileName, artifact);
    }
    if (nativeLibraries.keySet().size() == 1) {
        return getSourceDirectoryNodes(project, nativeLibraries.values(), viewSettings, sourceFileExtensions);
    }
    List<AbstractTreeNode> children = Lists.newArrayList();
    for (String name : nativeLibraries.keySet()) {
        String nativeLibraryType = "";
        String nativeLibraryName = trimEnd(name, ".so");
        if (nativeLibraryName.length() < name.length()) {
            nativeLibraryType = "Shared Library";
        } else {
            nativeLibraryName = trimEnd(name, ".a");
            if (nativeLibraryName.length() < name.length()) {
                nativeLibraryType = "Static Library";
            }
        }
        nativeLibraryName = trimStart(nativeLibraryName, "lib");
        children.add(new NativeAndroidLibraryNode(project, nativeLibraryName, nativeLibraryType, nativeLibraries.get(name), viewSettings, sourceFileExtensions));
    }
    return children;
}
Also used : NativeAndroidProject(com.android.builder.model.NativeAndroidProject) NativeArtifact(com.android.builder.model.NativeArtifact) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) NotNull(org.jetbrains.annotations.NotNull)

Example 18 with NdkModuleModel

use of com.android.tools.idea.gradle.project.model.NdkModuleModel in project android by JetBrains.

the class AndroidGradleProjectResolverIdeaTest method testPopulateModuleContentRootsWithNativeAndroidProject.

public void testPopulateModuleContentRootsWithNativeAndroidProject() {
    ProjectData project = myProjectResolver.createProject();
    DataNode<ProjectData> projectNode = new DataNode<>(PROJECT, project, null);
    DataNode<ModuleData> moduleDataNode = myProjectResolver.createModule(myNativeAndroidModuleModel, projectNode);
    myProjectResolver.populateModuleContentRoots(myNativeAndroidModuleModel, moduleDataNode);
    // Verify module does not have AndroidGradleModel.
    Collection<DataNode<AndroidModuleModel>> androidModelNodes = getChildren(moduleDataNode, ANDROID_MODEL);
    assertThat(androidModelNodes).isEmpty();
    // Verify module has NativeAndroidGradleModel.
    Collection<DataNode<NdkModuleModel>> ndkModuleModelNodes = getChildren(moduleDataNode, NDK_MODEL);
    assertThat(ndkModuleModelNodes).hasSize(1);
    DataNode<NdkModuleModel> nativeAndroidModelNode = getFirstItem(ndkModuleModelNodes);
    assertNotNull(nativeAndroidModelNode);
    assertSame(myNativeAndroidProject, nativeAndroidModelNode.getData().getAndroidProject());
    // Verify module has IdeaGradleProject.
    Collection<DataNode<GradleModuleModel>> gradleModelNodes = getChildren(moduleDataNode, GRADLE_MODULE_MODEL);
    assertThat(gradleModelNodes).hasSize(1);
    DataNode<GradleModuleModel> gradleModelNode = getFirstItem(gradleModelNodes);
    assertNotNull(gradleModelNode);
    assertEquals(myNativeAndroidModuleModel.getGradleProject().getPath(), gradleModelNode.getData().getGradlePath());
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)18 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)10 Module (com.intellij.openapi.module.Module)9 NativeAndroidProject (com.android.builder.model.NativeAndroidProject)4 NdkFacet (com.android.tools.idea.gradle.project.facet.ndk.NdkFacet)4 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)4 AndroidProject (com.android.builder.model.AndroidProject)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 File (java.io.File)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 Nullable (org.jetbrains.annotations.Nullable)3 VisibleForTesting (com.android.annotations.VisibleForTesting)2 GradleFacet (com.android.tools.idea.gradle.project.facet.gradle.GradleFacet)2 GradleSyncState (com.android.tools.idea.gradle.project.sync.GradleSyncState)2 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)2 DataNode (com.intellij.openapi.externalSystem.model.DataNode)2 VfsUtil.findFileByIoFile (com.intellij.openapi.vfs.VfsUtil.findFileByIoFile)2 VfsUtilCore.virtualToIoFile (com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile)2 NotNull (org.jetbrains.annotations.NotNull)2 NativeArtifact (com.android.builder.model.NativeArtifact)1