Reconfigured the android Gradle build (#47)
* CMakeLists.txt now build jar with ant and gradle package .jar into .aar. Updated README with instructions. * Updated instructions. * Fixed code block formatting. * Replcaing txt with md. * Fixed formatting. * Removed README.TXT.pull/56/head
parent
4f6f663671
commit
29bd835c69
|
|
@ -1,20 +0,0 @@
|
||||||
This directoy contains Android Studio project files for building the NORM
|
|
||||||
library for Android.
|
|
||||||
|
|
||||||
TO BUILD:
|
|
||||||
|
|
||||||
./gradlew build
|
|
||||||
|
|
||||||
The lib/build/ directory will contain the binary libraries built.
|
|
||||||
|
|
||||||
The "./gradlew clean" command can be used to delete the files built.
|
|
||||||
|
|
||||||
This directory may also be opened as an Android Studio project and built from
|
|
||||||
the IDE GUI.
|
|
||||||
|
|
||||||
This will evolve as we update NORM and associated projects to the newer Android
|
|
||||||
Studio tool chain.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
This directoy contains Android Studio project files for building the NORM
|
||||||
|
library for Android.
|
||||||
|
|
||||||
|
REQUIREMENTS:
|
||||||
|
|
||||||
|
Ninja is required in order to run the ant build for the java .jar file
|
||||||
|
|
||||||
|
Download and install ndk and cmake using the SDK manager within Android Studio. To do this:
|
||||||
|
|
||||||
|
-> Tools -> SDK Manager -> System Settings -> Android SDK -> SDK Tools -> Select 'Show Package Details' at the bottom
|
||||||
|
|
||||||
|
The latest compatible versions are ndk version 20.0.5594570 and cmake version 3.10.2.4988404
|
||||||
|
|
||||||
|
* Important *
|
||||||
|
If you decide to install different version of the SDK Tools above, make sure to edit the path locations in the local.properties file
|
||||||
|
|
||||||
|
TO BUILD:
|
||||||
|
|
||||||
|
./gradlew build
|
||||||
|
|
||||||
|
The lib/build/ directory will contain the binary libraries built.
|
||||||
|
|
||||||
|
The "./gradlew clean" command can be used to delete the files built.
|
||||||
|
|
||||||
|
This directory may also be opened as an Android Studio project and built from
|
||||||
|
the IDE GUI.
|
||||||
|
|
||||||
|
This will evolve as we update NORM and associated projects to the newer Android
|
||||||
|
Studio tool chain.
|
||||||
|
|
||||||
|
USAGE:
|
||||||
|
|
||||||
|
Copy the .aar file into your ${project.rootDir}/app/libs/ folder
|
||||||
|
|
||||||
|
Within your app level build.gradle include the following two tasks before your dependencies section:
|
||||||
|
|
||||||
|
```
|
||||||
|
task extractSo(type: Copy) {
|
||||||
|
println 'Extracting *.so file(s)....'
|
||||||
|
|
||||||
|
from zipTree("${project.rootDir}/app/libs/lib-release_-release.aar")
|
||||||
|
into "${project.rootDir}/app/src/main/jniLibs"
|
||||||
|
include "jni/**/*.so"
|
||||||
|
|
||||||
|
eachFile {
|
||||||
|
def segments = it.getRelativePath().getSegments() as List
|
||||||
|
println segments
|
||||||
|
it.setPath(segments.tail().join("/"))
|
||||||
|
return it
|
||||||
|
}
|
||||||
|
includeEmptyDirs = false
|
||||||
|
}
|
||||||
|
|
||||||
|
task extractJar(type: Copy, dependsOn: extractSo) {
|
||||||
|
println 'Extracting *.jar file(s)....'
|
||||||
|
|
||||||
|
from zipTree("${project.rootDir}/app/libs/lib-release_-release.aar")
|
||||||
|
into "${project.rootDir}/app/libs/"
|
||||||
|
include "norm-*.jar"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
@ -1 +1 @@
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8-bin.zip
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,13 @@ include_directories( AFTER
|
||||||
"../../protolib/include"
|
"../../protolib/include"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_program(ANTPATH ant)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${ANTPATH}
|
||||||
|
WORKING_DIRECTORY "$ENV{HOME}/norm/makefiles/java/"
|
||||||
|
)
|
||||||
|
|
||||||
enable_language(ASM)
|
enable_language(ASM)
|
||||||
|
|
||||||
IF(BUILD_CONFIGURATION MATCHES "DEBUG")
|
IF(BUILD_CONFIGURATION MATCHES "DEBUG")
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_PLATFORM=android-15", "-DANDROID_STL=c++_static", "-DANDROID_CPP_FEATURES=exceptions rtti", "-DANDROID_ARM_MODE=arm", "-DANDROID_ARM_NEON=TRUE"
|
arguments "-DANDROID_TOOLCHAIN=clang", "-DANDROID_PLATFORM=android-15", "-DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja", "-DANDROID_STL=c++_static", "-DANDROID_CPP_FEATURES=exceptions rtti", "-DANDROID_ARM_MODE=arm", "-DANDROID_ARM_NEON=TRUE"
|
||||||
cFlags "-fsigned-char"
|
cFlags "-fsigned-char"
|
||||||
cppFlags "-fsigned-char", "-std=c++14"
|
cppFlags "-fsigned-char", "-std=c++14"
|
||||||
}
|
}
|
||||||
|
|
@ -91,3 +91,53 @@ dependencies {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task copyReleaseJar(type: Copy) {
|
||||||
|
println 'Unzipping release .aar and including .jar....'
|
||||||
|
|
||||||
|
if (file("${project.rootDir}/lib/build/outputs/aar/lib-release_-release.aar").exists()) {
|
||||||
|
from zipTree("${project.rootDir}/lib/build/outputs/aar/lib-release_-release.aar")
|
||||||
|
into "${project.rootDir}/lib/build/outputs/aar/lib-release_-release"
|
||||||
|
|
||||||
|
from "${System.env.HOME}/norm/lib/norm-1.0.0.jar"
|
||||||
|
into "${project.rootDir}/lib/build/outputs/aar/lib-release_-release/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyDebugJar(type: Copy, dependsOn: copyReleaseJar) {
|
||||||
|
println 'Unzipping debug .aar and including .jar....'
|
||||||
|
|
||||||
|
if (file("${project.rootDir}/lib/build/outputs/aar/lib-debug_-debug.aar").exists()){
|
||||||
|
from zipTree("${project.rootDir}/lib/build/outputs/aar/lib-debug_-debug.aar")
|
||||||
|
into "${project.rootDir}/lib/build/outputs/aar/lib-debug_-debug"
|
||||||
|
|
||||||
|
from "${System.env.HOME}/norm/lib/norm-1.0.0.jar"
|
||||||
|
into "${project.rootDir}/lib/build/outputs/aar/lib-debug_-debug/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task zipReleaseAAR(type: Exec, dependsOn: copyDebugJar) {
|
||||||
|
println 'Creating new release .aar..'
|
||||||
|
ignoreExitValue true
|
||||||
|
workingDir "${project.rootDir}/lib/build/outputs/aar/"
|
||||||
|
executable 'jar'
|
||||||
|
def releaseArgsList = ['cvf', 'lib-release_-release.aar', '-C', 'lib-release_-release/', '.']
|
||||||
|
args releaseArgsList
|
||||||
|
}
|
||||||
|
|
||||||
|
task zipDebugAAR(type: Exec, dependsOn: zipReleaseAAR) {
|
||||||
|
println 'Creating new debug .aar..'
|
||||||
|
ignoreExitValue true
|
||||||
|
workingDir "${project.rootDir}/lib/build/outputs/aar/"
|
||||||
|
executable 'jar'
|
||||||
|
def debugArgsList = ['cvf', 'lib-debug_-debug.aar', '-C', 'lib-debug_-debug/', '.']
|
||||||
|
args debugArgsList
|
||||||
|
}
|
||||||
|
|
||||||
|
task deleteAARAssets(type: Delete, dependsOn: zipDebugAAR) {
|
||||||
|
delete "${project.rootDir}/lib/build/outputs/aar/lib-release_-release"
|
||||||
|
delete "${project.rootDir}/lib/build/outputs/aar/lib-debug_-debug"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.build.finalizedBy(deleteAARAssets)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
## This file must *NOT* be checked into Version Control Systems,
|
||||||
|
# as it contains information specific to your local configuration.
|
||||||
|
#
|
||||||
|
# Location of the SDK. This is only used by Gradle.
|
||||||
|
# For customization when using a Version Control System, please read the
|
||||||
|
# header note.
|
||||||
|
#Sat Nov 13 08:28:03 EST 2021
|
||||||
|
sdk.dir=/Users/alessandrogrossmann/Library/Android/sdk
|
||||||
|
ndk.dir=/Users/alessandrogrossmann/Library/Android/sdk/ndk/20.0.5594570
|
||||||
|
cmake.dir=/Users/alessandrogrossmann/Library/Android/sdk/cmake/3.10.2.4988404
|
||||||
Loading…
Reference in New Issue