use of com.android.builder.model.NativeArtifact in project android by JetBrains.
the class NativeAndroidLibraryNode method getDirectories.
@NotNull
@Override
public PsiDirectory[] getDirectories() {
PsiManager psiManager = PsiManager.getInstance(myProject);
List<PsiDirectory> psiDirectories = new ArrayList<>();
for (NativeArtifact artifact : getArtifacts()) {
for (VirtualFile f : getSourceFolders(artifact)) {
PsiDirectory dir = psiManager.findDirectory(f);
if (dir != null) {
psiDirectories.add(dir);
}
}
}
return psiDirectories.toArray(new PsiDirectory[psiDirectories.size()]);
}
use of com.android.builder.model.NativeArtifact in project android by JetBrains.
the class NativeAndroidLibraryNode method getSourceDirectoryNodes.
@NotNull
public static Collection<AbstractTreeNode> getSourceDirectoryNodes(@NotNull Project project, @NotNull Collection<NativeArtifact> artifacts, @NotNull ViewSettings settings, @NotNull Collection<String> sourceFileExtensions) {
TreeMap<String, RootDirectory> rootDirectories = new TreeMap<>();
for (NativeArtifact artifact : artifacts) {
addSourceFolders(rootDirectories, artifact);
addSourceFiles(rootDirectories, artifact);
}
if (rootDirectories.size() > 1) {
groupDirectories(rootDirectories);
}
if (rootDirectories.size() > 1) {
mergeDirectories(rootDirectories);
}
Set<String> fileExtensions = Sets.newHashSetWithExpectedSize(sourceFileExtensions.size() + HEADER_FILE_EXTENSIONS.size());
fileExtensions.addAll(sourceFileExtensions);
// add header files extension explicitly as the model only provides the extensions of source files.
fileExtensions.addAll(HEADER_FILE_EXTENSIONS);
PsiManager psiManager = PsiManager.getInstance(project);
List<AbstractTreeNode> children = Lists.newArrayList();
for (RootDirectory rootDirectory : rootDirectories.values()) {
PsiDirectory psiDir = psiManager.findDirectory(rootDirectory.rootDir);
if (psiDir != null) {
children.add(new NativeAndroidSourceDirectoryNode(project, psiDir, settings, fileExtensions, rootDirectory.sourceFolders, rootDirectory.sourceFiles));
}
}
return children;
}
use of com.android.builder.model.NativeArtifact 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;
}
Aggregations