Gradle
Gradle support for Android projects. For command line build, `gradle assembe` will trigger build phase - Config for Android .so file generation - Commented build.gradle - Automatic file copy after build - Dummy AndroidManifest file
This commit is contained in:
parent
4df4752b63
commit
f58ea87c26
111
build.gradle
111
build.gradle
@ -10,28 +10,11 @@ buildscript {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
google()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Output: Shared library (.so) for Android
|
// Output: Shared library (.so) for Android
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 24 // Android 7.0
|
compileSdkVersion 25 // Android 7.0
|
||||||
|
|
||||||
// External Native build
|
|
||||||
// - Use existing CMakeList.txt
|
|
||||||
// - Give path to CMake. This gradle file should be
|
|
||||||
// neighbor of the top level cmake
|
|
||||||
externalNativeBuild {
|
|
||||||
cmake {
|
|
||||||
path "CMakeLists.txt"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target ABI
|
// Target ABI
|
||||||
// - This option controls target platform of module
|
// - This option controls target platform of module
|
||||||
@ -40,72 +23,76 @@ android {
|
|||||||
// if bad, both toolchains might not support it
|
// if bad, both toolchains might not support it
|
||||||
splits {
|
splits {
|
||||||
abi {
|
abi {
|
||||||
// Be general, as it can...
|
|
||||||
enable true
|
enable true
|
||||||
universalApk true
|
// Be general, as much as possible ...
|
||||||
// We can specify platforms, like...
|
// universalApk true
|
||||||
// reset()
|
|
||||||
// include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
|
// Specify platforms for Application
|
||||||
|
reset()
|
||||||
|
include "x86", "x86_64", "armeabi-v7a", "arm64-v8a"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 21 // Android 5.0+
|
minSdkVersion 21 // Android 5.0+
|
||||||
targetSdkVersion 24 // Follow Compile SDK
|
targetSdkVersion 25 // Follow Compile SDK
|
||||||
versionCode 16 // Follow release count
|
versionCode 16 // Follow release count
|
||||||
versionName "4.1.0" // Follow Official version
|
versionName "4.1.0" // Follow Official version
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
|
||||||
// - Specify Android STL
|
|
||||||
// - Additional flags
|
|
||||||
externalNativeBuild {
|
externalNativeBuild {
|
||||||
cmake {
|
cmake {
|
||||||
arguments "-DANDROID_STL=c++_shared"
|
arguments "-DANDROID_STL=c++_shared" // Specify Android STL
|
||||||
"-DBUILD_SHARED=true"
|
arguments "-DBUILD_SHARED_LIBS=true" // Build shared object
|
||||||
|
arguments "-DFMT_TEST=false" // Skip test
|
||||||
|
arguments "-DFMT_DOC=false" // Skip document
|
||||||
cppFlags "-std=c++14"
|
cppFlags "-std=c++14"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
println("Gradle CMake Plugin: ")
|
||||||
|
println(externalNativeBuild.cmake.cppFlags)
|
||||||
|
println(externalNativeBuild.cmake.arguments)
|
||||||
|
}
|
||||||
|
|
||||||
|
// External Native build
|
||||||
|
// - Use existing CMakeList.txt
|
||||||
|
// - Give path to CMake. This gradle file should be
|
||||||
|
// neighbor of the top level cmake
|
||||||
|
externalNativeBuild {
|
||||||
|
cmake {
|
||||||
|
path "CMakeLists.txt"
|
||||||
|
// buildStagingDirectory "./build" // Custom path for cmake output
|
||||||
|
}
|
||||||
|
//println(cmake.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceSets{
|
sourceSets{
|
||||||
// gradle assemble
|
// Android Manifest for Gradle
|
||||||
main.setRoot('./')
|
|
||||||
main {
|
main {
|
||||||
manifest.srcFile 'support/AndroidManifest.xml'
|
manifest.srcFile 'support/AndroidManifest.xml'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// // Custom SourceSet for JNI adapter
|
|
||||||
// // - Source path/directory for Gradle
|
|
||||||
// sourceSets {
|
|
||||||
// // gradle assemble
|
|
||||||
// main.setRoot('droid/main')
|
|
||||||
// // main {
|
|
||||||
// // manifest.srcFile 'droid/main/AndroidManifest.xml'
|
|
||||||
// // java.srcDirs = ['droid/main/java']
|
|
||||||
// // jniLibs.srcDirs = ['droid/main/jniLibs']
|
|
||||||
// // res.srcDirs = ['droid/main/res']
|
|
||||||
// // assets.srcDirs = ['droid/main/assets']
|
|
||||||
// // }
|
|
||||||
// // gradle connectedAndroidTest
|
|
||||||
// androidTest.setRoot('droid/androidTest')
|
|
||||||
// // androidTest {
|
|
||||||
// // java.srcDir 'droid/androidTest/java'
|
|
||||||
// // }
|
|
||||||
// // If ABI includes `armeabi-v7a`, the following directory MUST exists.
|
|
||||||
// // Notice that the path is relative to `build.gradle` file
|
|
||||||
// // `droid/main/jniLibs/armeabi-v7a`
|
|
||||||
// // `libs/armeabi-v7a`
|
|
||||||
// // The library files in there will be installed automatically
|
|
||||||
// main.jniLibs.srcDirs = ['droid/main/jniLibs', 'libs']
|
|
||||||
// androidTest.jniLibs.srcDirs = ['droid/main/jniLibs', 'libs']
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
assemble.doLast
|
||||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
{
|
||||||
|
// Instead of `ninja install`, Gradle will deploy the files.
|
||||||
implementation 'com.android.support:appcompat-v7:24.+' // Follow target SDK
|
// We are doing this since FMT is dependent to the ANDROID_STL after build
|
||||||
testImplementation 'junit:junit:4.12'
|
copy {
|
||||||
androidTestImplementation 'com.android.support.test:runner:1.0.1'
|
from 'build/intermediates/cmake'
|
||||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
|
into 'libs'
|
||||||
|
}
|
||||||
|
// Copy debug binaries
|
||||||
|
copy {
|
||||||
|
from 'libs/debug/obj'
|
||||||
|
into 'libs/debug'
|
||||||
|
}
|
||||||
|
// Copy Release binaries
|
||||||
|
copy {
|
||||||
|
from 'libs/release/obj'
|
||||||
|
into 'libs/release'
|
||||||
|
}
|
||||||
|
// Remove empty directory
|
||||||
|
delete 'libs/debug/obj'
|
||||||
|
delete 'libs/release/obj'
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user