2020-11-05 22:23:37 +00:00
|
|
|
apply plugin: 'com.android.application'
|
|
|
|
apply plugin: 'kotlin-android'
|
|
|
|
apply plugin: 'kotlin-android-extensions'
|
|
|
|
|
|
|
|
android {
|
|
|
|
compileSdkVersion 30
|
|
|
|
buildToolsVersion "30.0.2"
|
|
|
|
|
|
|
|
defaultConfig {
|
|
|
|
applicationId "com.flatbuffers.app"
|
2022-09-01 21:58:25 +00:00
|
|
|
minSdkVersion 26
|
2020-11-05 22:23:37 +00:00
|
|
|
targetSdkVersion 30
|
|
|
|
versionCode 1
|
|
|
|
versionName "1.0"
|
|
|
|
|
|
|
|
compileOptions {
|
|
|
|
sourceCompatibility JavaVersion.VERSION_1_8
|
|
|
|
targetCompatibility JavaVersion.VERSION_1_8
|
|
|
|
}
|
|
|
|
|
2022-09-01 21:58:25 +00:00
|
|
|
sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
|
|
|
srcDir '../../java'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-16 20:47:08 +00:00
|
|
|
ndk {
|
|
|
|
abiFilters 'arm64-v8a', 'armeabi-v7a'
|
|
|
|
}
|
|
|
|
|
2020-11-05 22:23:37 +00:00
|
|
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
arguments "-DFLATBUFFERS_SRC=${rootProject.projectDir}/.."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
release {
|
|
|
|
minifyEnabled false
|
|
|
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
externalNativeBuild {
|
|
|
|
cmake {
|
|
|
|
path "src/main/cpp/CMakeLists.txt"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task generateFbsCpp(type: Exec) {
|
|
|
|
def inputDir = file("$projectDir/src/main/fbs")
|
|
|
|
def outputCppDir = file("$projectDir/src/main/cpp/generated/")
|
|
|
|
def fbsFiles = layout.files { file(inputDir).listFiles() }.filter { File f -> f.name.endsWith(".fbs") }.toList()
|
|
|
|
ignoreExitValue(true)
|
|
|
|
|
|
|
|
standardOutput = new ByteArrayOutputStream()
|
|
|
|
errorOutput = new ByteArrayOutputStream()
|
2021-01-04 21:29:32 +00:00
|
|
|
def commandLineArgs = ['flatc', '-o', outputCppDir, '--cpp']
|
|
|
|
fbsFiles.forEach{
|
|
|
|
commandLineArgs.add(it.path)
|
|
|
|
}
|
2022-08-15 17:13:27 +00:00
|
|
|
|
2021-01-04 21:29:32 +00:00
|
|
|
commandLine commandLineArgs
|
2020-11-05 22:23:37 +00:00
|
|
|
|
|
|
|
doFirst {
|
|
|
|
delete "$outputCppDir/"
|
|
|
|
mkdir "$outputCppDir/"
|
|
|
|
}
|
2022-08-15 17:13:27 +00:00
|
|
|
|
2020-11-05 22:23:37 +00:00
|
|
|
doLast {
|
2022-08-15 17:13:27 +00:00
|
|
|
if (executionResult.get().exitValue != 0) {
|
|
|
|
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
2020-11-05 22:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
task generateFbsKotlin(type: Exec) {
|
|
|
|
def inputDir = file("$projectDir/src/main/fbs")
|
|
|
|
def outputKotlinDir = file("$projectDir/src/main/java/generated/")
|
|
|
|
def fbsFiles = layout.files { file(inputDir).listFiles() }.filter { File f -> f.name.endsWith(".fbs") }.toList()
|
|
|
|
ignoreExitValue(true)
|
|
|
|
|
|
|
|
standardOutput = new ByteArrayOutputStream()
|
|
|
|
errorOutput = new ByteArrayOutputStream()
|
2022-08-15 17:13:27 +00:00
|
|
|
|
|
|
|
setErrorOutput(errorOutput)
|
|
|
|
setStandardOutput(standardOutput)
|
|
|
|
|
2021-01-04 21:29:32 +00:00
|
|
|
def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
|
|
|
|
fbsFiles.forEach{
|
|
|
|
commandLineArgs.add(it.path)
|
|
|
|
}
|
|
|
|
commandLine commandLineArgs
|
2020-11-05 22:23:37 +00:00
|
|
|
|
|
|
|
doFirst {
|
|
|
|
delete "$outputKotlinDir/"
|
|
|
|
mkdir "$outputKotlinDir/"
|
|
|
|
}
|
|
|
|
doLast {
|
2022-08-15 17:13:27 +00:00
|
|
|
if (executionResult.get().exitValue != 0) {
|
|
|
|
throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
|
2020-11-05 22:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
afterEvaluate {
|
2022-08-15 17:13:27 +00:00
|
|
|
tasks.named("preBuild") {
|
|
|
|
dependsOn(generateFbsKotlin)
|
|
|
|
dependsOn(generateFbsCpp)
|
2020-11-05 22:23:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
|
|
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
|
|
implementation 'androidx.core:core-ktx:1.3.2'
|
|
|
|
implementation 'androidx.appcompat:appcompat:1.2.0'
|
2022-09-01 21:58:25 +00:00
|
|
|
|
|
|
|
// If you using java runtime you can add its dependency as the example below
|
|
|
|
// implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'
|
2020-11-05 22:23:37 +00:00
|
|
|
|
|
|
|
}
|