Search in sources :

Example 11 with NdkModuleModel

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

the class AndroidModuleNode method getChildren.

@NotNull
public static Collection<AbstractTreeNode> getChildren(@NotNull AndroidFacet facet, @NotNull ViewSettings settings, @NotNull AndroidProjectViewPane pane, @NotNull List<IdeaSourceProvider> providers) {
    Project project = facet.getModule().getProject();
    List<AbstractTreeNode> result = Lists.newArrayList();
    AndroidModuleModel androidModuleModel = AndroidModuleModel.get(facet);
    HashMultimap<AndroidSourceType, VirtualFile> sourcesByType = getSourcesBySourceType(providers, androidModuleModel);
    NdkModuleModel ndkModuleModel = NdkModuleModel.get(facet.getModule());
    for (AndroidSourceType sourceType : sourcesByType.keySet()) {
        if (sourceType == AndroidSourceType.CPP && ndkModuleModel != null) {
            // Native sources will be added separately from NativeAndroidGradleModel.
            continue;
        }
        if (sourceType == AndroidSourceType.MANIFEST) {
            result.add(new AndroidManifestsGroupNode(project, facet, settings, sourcesByType.get(sourceType)));
            continue;
        }
        if (sourceType == AndroidSourceType.RES) {
            result.add(new AndroidResFolderNode(project, facet, settings, sourcesByType.get(sourceType), pane));
            continue;
        }
        if (sourceType == AndroidSourceType.SHADERS) {
            if (androidModuleModel == null || !androidModuleModel.getFeatures().isShadersSupported()) {
                continue;
            }
        }
        result.add(new AndroidSourceTypeNode(project, facet, settings, sourceType, sourcesByType.get(sourceType), pane));
    }
    if (ndkModuleModel != null) {
        result.add(new AndroidJniFolderNode(project, ndkModuleModel, settings));
    }
    return result;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) AbstractTreeNode(com.intellij.ide.util.treeView.AbstractTreeNode) AndroidSourceType(org.jetbrains.android.facet.AndroidSourceType) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) NotNull(org.jetbrains.annotations.NotNull)

Example 12 with NdkModuleModel

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

the class AndroidJniFolderNode method hashCode.

@Override
public int hashCode() {
    int result = super.hashCode();
    NdkModuleModel model = getModel();
    return 31 * result + model.hashCode();
}
Also used : NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel)

Example 13 with NdkModuleModel

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

the class GradleProjectSyncData method createFrom.

@Nullable
@VisibleForTesting
static GradleProjectSyncData createFrom(@NotNull Project project) throws IOException {
    GradleProjectSyncData data = new GradleProjectSyncData();
    File rootDirPath = getBaseDirPath(project);
    Module[] modules = ModuleManager.getInstance(project).getModules();
    for (Module module : modules) {
        GradleFacet gradleFacet = GradleFacet.getInstance(module);
        if (gradleFacet != null) {
            GradleModuleModel gradleModuleModel = gradleFacet.getGradleModuleModel();
            if (gradleModuleModel != null) {
                data.addFileChecksum(rootDirPath, gradleModuleModel.getBuildFile());
            } else {
                LOG.warn(String.format("Trying to create project data from a not initialized project '%1$s'. Abort.", project.getName()));
                return null;
            }
        }
        if (isGradleProjectModule(module)) {
            data.addFileChecksum(rootDirPath, getGradleBuildFile(module));
            data.addFileChecksum(rootDirPath, getGradleSettingsFile(rootDirPath));
            data.addFileChecksum(rootDirPath, new File(rootDirPath, FN_GRADLE_PROPERTIES));
            data.addFileChecksum(rootDirPath, new File(rootDirPath, FN_LOCAL_PROPERTIES));
            data.addFileChecksum(rootDirPath, getGradleUserSettingsFile());
        }
        NdkModuleModel ndkModuleModel = NdkModuleModel.get(module);
        if (ndkModuleModel != null) {
            for (File externalBuildFile : ndkModuleModel.getAndroidProject().getBuildFiles()) {
                data.addFileChecksum(rootDirPath, externalBuildFile);
            }
        }
    }
    GradleSyncState syncState = GradleSyncState.getInstance(project);
    data.myLastGradleSyncTimestamp = syncState.getSummary().getSyncTimestamp();
    return data;
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) GradleFacet(com.android.tools.idea.gradle.project.facet.gradle.GradleFacet) Projects.isGradleProjectModule(com.android.tools.idea.gradle.util.Projects.isGradleProjectModule) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) VfsUtil.findFileByIoFile(com.intellij.openapi.vfs.VfsUtil.findFileByIoFile) GradleSyncState(com.android.tools.idea.gradle.project.sync.GradleSyncState) VisibleForTesting(com.android.annotations.VisibleForTesting) Nullable(org.jetbrains.annotations.Nullable)

Example 14 with NdkModuleModel

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

the class NdkModuleModelDataService method importData.

@Override
protected void importData(@NotNull Collection<DataNode<NdkModuleModel>> toImport, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider, @NotNull Map<String, NdkModuleModel> modelsByName) {
    for (Module module : modelsProvider.getModules()) {
        NdkModuleModel ndkModuleModel = modelsByName.get(module.getName());
        myModuleSetup.setUpModule(module, modelsProvider, ndkModuleModel, null, null);
    }
}
Also used : Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel)

Example 15 with NdkModuleModel

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

the class BuildVariantUpdater method doUpdate.

@Nullable
private Module doUpdate(@NotNull Project project, @NotNull String moduleName, @NotNull String variant, @NotNull List<AndroidFacet> affectedAndroidFacets, @NotNull List<NdkFacet> affectedNativeAndroidFacets) {
    Module moduleToUpdate = findModule(project, moduleName);
    if (moduleToUpdate == null) {
        logAndShowUpdateFailure(variant, String.format("Cannot find module '%1$s'.", moduleName));
        return null;
    }
    AndroidFacet androidFacet = AndroidFacet.getInstance(moduleToUpdate);
    NdkFacet ndkFacet = NdkFacet.getInstance(moduleToUpdate);
    if (androidFacet == null && ndkFacet == null) {
        String msg = String.format("Cannot find 'Android' or 'Native-Android-Gradle' facets in module '%1$s'.", moduleToUpdate.getName());
        logAndShowUpdateFailure(variant, msg);
    }
    if (ndkFacet != null) {
        NdkModuleModel ndkModuleModel = getNativeAndroidModel(ndkFacet, variant);
        if (ndkModuleModel == null || !updateSelectedVariant(ndkFacet, ndkModuleModel, variant)) {
            return null;
        }
        affectedNativeAndroidFacets.add(ndkFacet);
    }
    if (androidFacet != null) {
        AndroidModuleModel androidModel = getAndroidModel(androidFacet, variant);
        if (androidModel == null || !updateSelectedVariant(androidFacet, androidModel, variant, affectedAndroidFacets)) {
            return null;
        }
        affectedAndroidFacets.add(androidFacet);
    }
    return moduleToUpdate;
}
Also used : AndroidModuleModel(com.android.tools.idea.gradle.project.model.AndroidModuleModel) NdkFacet(com.android.tools.idea.gradle.project.facet.ndk.NdkFacet) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel) AndroidFacet(org.jetbrains.android.facet.AndroidFacet) Nullable(org.jetbrains.annotations.Nullable)

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