use of org.jetbrains.android.util.AndroidNativeLibData in project android by JetBrains.
the class AndroidFacetConfiguration method setAdditionalNativeLibraries.
public void setAdditionalNativeLibraries(@NotNull List<AndroidNativeLibData> additionalNativeLibraries) {
myProperties.myNativeLibs = new ArrayList<JpsAndroidModuleProperties.AndroidNativeLibDataEntry>(additionalNativeLibraries.size());
for (AndroidNativeLibData lib : additionalNativeLibraries) {
final JpsAndroidModuleProperties.AndroidNativeLibDataEntry data = new JpsAndroidModuleProperties.AndroidNativeLibDataEntry();
data.myArchitecture = lib.getArchitecture();
data.myUrl = VfsUtilCore.pathToUrl(lib.getPath());
data.myTargetFileName = lib.getTargetFileName();
myProperties.myNativeLibs.add(data);
}
}
use of org.jetbrains.android.util.AndroidNativeLibData in project android by JetBrains.
the class AndroidFacetImporterBase method importNativeDependencies.
private void importNativeDependencies(@NotNull AndroidFacet facet, @NotNull MavenProject mavenProject, @NotNull String moduleDirPath) {
final List<AndroidNativeLibData> additionalNativeLibs = new ArrayList<AndroidNativeLibData>();
final String localRepository = MavenProjectsManager.getInstance(facet.getModule().getProject()).getLocalRepository().getPath();
String defaultArchitecture = getPathFromConfig(facet.getModule(), mavenProject, moduleDirPath, "nativeLibrariesDependenciesHardwareArchitectureDefault", false, true);
if (defaultArchitecture == null) {
defaultArchitecture = DEFAULT_NATIVE_ARCHITECTURE;
}
final String forcedArchitecture = getPathFromConfig(facet.getModule(), mavenProject, moduleDirPath, "nativeLibrariesDependenciesHardwareArchitectureOverride", false, true);
for (MavenArtifact depArtifact : mavenProject.getDependencies()) {
if (AndroidMavenUtil.SO_PACKAGING_AND_DEPENDENCY_TYPE.equals(depArtifact.getType())) {
final String architecture;
if (forcedArchitecture != null) {
architecture = forcedArchitecture;
} else {
final String classifier = depArtifact.getClassifier();
architecture = classifier != null ? classifier : defaultArchitecture;
}
final String path = FileUtil.toSystemIndependentName(localRepository + '/' + depArtifact.getRelativePath());
final String artifactId = depArtifact.getArtifactId();
final String targetFileName = artifactId.startsWith("lib") ? artifactId + ".so" : "lib" + artifactId + ".so";
additionalNativeLibs.add(new AndroidNativeLibData(architecture, path, targetFileName));
}
}
facet.getConfiguration().setAdditionalNativeLibraries(additionalNativeLibs);
}
use of org.jetbrains.android.util.AndroidNativeLibData in project android by JetBrains.
the class AndroidPackagingBuilder method doPackagingForModule.
private static boolean doPackagingForModule(@NotNull CompileContext context, @NotNull JpsModule module, @NotNull AndroidApkBuilderConfigStateStorage apkBuilderConfigStateStorage, @NotNull AndroidPackagingStateStorage packagingStateStorage, boolean release, boolean hasDirtyFiles, @NotNull BuildOutputConsumer outputConsumer) throws IOException {
final JpsAndroidModuleExtension extension = AndroidJpsUtil.getExtension(module);
if (extension == null || extension.isLibrary()) {
return true;
}
final String[] resourceRoots = AndroidJpsUtil.toPaths(AndroidJpsUtil.getJavaOutputRootsForModuleAndDependencies(module));
Arrays.sort(resourceRoots);
final File moduleOutputDir = ProjectPaths.getModuleOutputDir(module, false);
if (moduleOutputDir == null) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.output.dir.not.specified", module.getName())));
return false;
}
final AndroidPlatform platform = AndroidJpsUtil.getAndroidPlatform(module, context, BUILDER_NAME);
if (platform == null) {
return false;
}
final Set<String> externalJarsSet = new HashSet<String>();
for (String jarPath : AndroidJpsUtil.getExternalLibraries(context, module, platform)) {
if (new File(jarPath).exists()) {
externalJarsSet.add(jarPath);
}
}
final BuildDataPaths dataPaths = context.getProjectDescriptor().dataManager.getDataPaths();
final File resPackage = AndroidResourcePackagingBuildTarget.getOutputFile(dataPaths, module);
final File classesDexFile = AndroidDexBuildTarget.getOutputFile(dataPaths, module);
final String sdkPath = platform.getSdk().getHomePath();
final String outputPath = AndroidJpsUtil.getApkPath(extension, moduleOutputDir);
if (outputPath == null) {
context.processMessage(new CompilerMessage(BUILDER_NAME, BuildMessage.Kind.ERROR, AndroidJpsBundle.message("android.jps.errors.cannot.compute.output.apk", module.getName())));
return false;
}
final String customKeyStorePath = FileUtil.toSystemDependentName(extension.getCustomDebugKeyStorePath());
final String[] nativeLibDirs = AndroidPackagingBuildTarget.collectNativeLibsFolders(extension, true);
final String resPackagePath = resPackage.getPath();
final String classesDexFilePath = classesDexFile.getPath();
final String[] externalJars = ArrayUtil.toStringArray(externalJarsSet);
Arrays.sort(externalJars);
final List<AndroidNativeLibData> additionalNativeLibs = extension.getAdditionalNativeLibs();
final AndroidApkBuilderConfigState currentApkBuilderConfigState = new AndroidApkBuilderConfigState(outputPath, customKeyStorePath, additionalNativeLibs);
if (!hasDirtyFiles) {
final AndroidApkBuilderConfigState savedApkBuilderConfigState = apkBuilderConfigStateStorage.getState(module.getName());
final AndroidPackagingStateStorage.MyState packagingState = packagingStateStorage.read();
if (currentApkBuilderConfigState.equalsTo(savedApkBuilderConfigState) && packagingState != null && packagingState.isRelease() == release) {
return true;
}
}
context.processMessage(new ProgressMessage(AndroidJpsBundle.message("android.jps.progress.packaging", AndroidJpsUtil.getApkName(module))));
final Map<AndroidCompilerMessageKind, List<String>> messages = AndroidApkBuilder.execute(resPackagePath, classesDexFilePath, resourceRoots, externalJars, nativeLibDirs, additionalNativeLibs, outputPath, release, sdkPath, platform.getTarget(), customKeyStorePath, new MyExcludedSourcesFilter(context.getProjectDescriptor().getProject()));
if (messages.get(AndroidCompilerMessageKind.ERROR).size() == 0) {
final List<String> srcFiles = new ArrayList<String>();
srcFiles.add(resPackagePath);
srcFiles.add(classesDexFilePath);
for (String resourceRoot : resourceRoots) {
FileUtil.processFilesRecursively(new File(resourceRoot), new Processor<File>() {
@Override
public boolean process(File file) {
if (file.isFile() && AndroidApkBuilder.checkFileForPackaging(file)) {
srcFiles.add(file.getPath());
}
return true;
}
});
}
Collections.addAll(srcFiles, externalJars);
for (String nativeLibDir : nativeLibDirs) {
FileUtil.processFilesRecursively(new File(nativeLibDir), new Processor<File>() {
@Override
public boolean process(File file) {
if (file.isFile()) {
srcFiles.add(file.getPath());
}
return true;
}
});
}
outputConsumer.registerOutputFile(new File(outputPath), srcFiles);
}
AndroidJpsUtil.addMessages(context, messages, BUILDER_NAME, module.getName());
final boolean success = messages.get(AndroidCompilerMessageKind.ERROR).isEmpty();
apkBuilderConfigStateStorage.update(module.getName(), success ? currentApkBuilderConfigState : null);
packagingStateStorage.saveState(new AndroidPackagingStateStorage.MyState(release));
return success;
}
use of org.jetbrains.android.util.AndroidNativeLibData in project android by JetBrains.
the class AndroidApkBuilderConfigState method save.
@Override
public void save(DataOutput out) throws IOException {
out.writeUTF(myOutputApkPath);
out.writeUTF(myCustomKeystorePath);
out.writeInt(myAdditionalNativeLibs.size());
for (AndroidNativeLibData lib : myAdditionalNativeLibs) {
out.writeUTF(lib.getArchitecture());
out.writeUTF(lib.getPath());
out.writeUTF(lib.getTargetFileName());
}
}
Aggregations