2018-11-06 04:08:46 +03:00
|
|
|
|
2018-03-12 22:40:25 +03:00
|
|
|
// General gradle arguments for root project
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
dependencies {
|
2018-11-06 04:08:46 +03:00
|
|
|
//
|
2018-11-02 19:54:00 +03:00
|
|
|
// https://developer.android.com/studio/releases/gradle-plugin
|
2018-11-06 04:08:46 +03:00
|
|
|
//
|
2019-02-10 12:35:05 +03:00
|
|
|
// Notice that 3.3.0 here is the version of [Android Gradle Plugin]
|
|
|
|
// Accroding to URL above you will need Gradle 5.0 or higher
|
2018-11-06 04:08:46 +03:00
|
|
|
//
|
2019-02-10 12:35:05 +03:00
|
|
|
// If you are using Android Studio, and it is using Gradle's lower
|
|
|
|
// version, Use the plugin version 3.1.3 ~ 3.2.0 for Gradle 4.4 ~ 4.10
|
|
|
|
classpath 'com.android.tools.build:gradle:3.3.0'
|
2018-03-12 22:40:25 +03:00
|
|
|
}
|
|
|
|
}
|
2018-11-02 19:54:00 +03:00
|
|
|
repositories {
|
|
|
|
google()
|
|
|
|
jcenter()
|
|
|
|
}
|
|
|
|
|
2018-03-12 22:40:25 +03:00
|
|
|
// Output: Shared library (.so) for Android
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileSdkVersion 25 // Android 7.0
|
|
|
|
|
|
|
|
// Target ABI
|
|
|
|
// - This option controls target platform of module
|
|
|
|
// - The platform might be limited by compiler's support
|
|
|
|
// some can work with Clang(default), but some can work only with GCC...
|
|
|
|
// if bad, both toolchains might not support it
|
|
|
|
splits {
|
|
|
|
abi {
|
|
|
|
enable true
|
|
|
|
// Specify platforms for Application
|
|
|
|
reset()
|
2018-11-02 19:54:00 +03:00
|
|
|
include "arm64-v8a", "armeabi-v7a", "x86_64"
|
2018-03-12 22:40:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
minSdkVersion 21 // Android 5.0+
|
|
|
|
targetSdkVersion 25 // Follow Compile SDK
|
2019-02-10 12:35:05 +03:00
|
|
|
versionCode 21 // Follow release count
|
|
|
|
versionName "5.3.0" // Follow Official version
|
2018-03-12 22:40:25 +03:00
|
|
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
arguments "-DANDROID_STL=c++_shared" // Specify Android STL
|
|
|
|
arguments "-DBUILD_SHARED_LIBS=true" // Build shared object
|
|
|
|
arguments "-DFMT_TEST=false" // Skip test
|
|
|
|
arguments "-DFMT_DOC=false" // Skip document
|
2018-11-02 19:54:00 +03:00
|
|
|
cppFlags "-std=c++17"
|
2018-03-12 22:40:25 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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{
|
|
|
|
// Android Manifest for Gradle
|
|
|
|
main {
|
|
|
|
manifest.srcFile 'AndroidManifest.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
assemble.doLast
|
|
|
|
{
|
|
|
|
// Instead of `ninja install`, Gradle will deploy the files.
|
|
|
|
// We are doing this since FMT is dependent to the ANDROID_STL after build
|
|
|
|
copy {
|
|
|
|
from 'build/intermediates/cmake'
|
|
|
|
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'
|
|
|
|
}
|