File: build.gradle

package info (click to toggle)
golang-github-google-flatbuffers 24.12.23-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, forky, sid, trixie
  • size: 17,704 kB
  • sloc: cpp: 53,217; python: 6,900; cs: 5,566; java: 4,370; php: 1,460; javascript: 1,061; xml: 1,016; sh: 886; makefile: 13
file content (125 lines) | stat: -rw-r--r-- 3,231 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
  compileSdk 33

  defaultConfig {
    applicationId "com.flatbuffers.app"
    minSdkVersion 26
    targetSdkVersion 33
    versionCode 1
    versionName "1.0"

    compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
    }

    sourceSets {
      main {
        java {
          srcDir '../../java/src/main/java/'
        }
      }
    }

    ndk {
      abiFilters 'arm64-v8a', 'armeabi-v7a'
    }
    
    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()
    def commandLineArgs = ['flatc', '-o', outputCppDir, '--cpp']
    fbsFiles.forEach{
      commandLineArgs.add(it.path)
    }

    commandLine commandLineArgs

    doFirst {
      delete "$outputCppDir/"
      mkdir "$outputCppDir/"
    }

    doLast {
      if (executionResult.get().exitValue != 0) {
        throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
      }
    }
  }

  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()

    setErrorOutput(errorOutput)
    setStandardOutput(standardOutput)

    def commandLineArgs = ['flatc', '-o', outputKotlinDir, '--kotlin']
    fbsFiles.forEach{
      commandLineArgs.add(it.path)
    }
    commandLine commandLineArgs

    doFirst {
      delete "$outputKotlinDir/"
      mkdir "$outputKotlinDir/"
    }
    doLast {
      if (executionResult.get().exitValue != 0) {
        throw new GradleException("flatc failed with: ${executionResult.get().toString()}")
      }
    }
  }

  afterEvaluate {
    tasks.named("preBuild") {
      dependsOn(generateFbsKotlin)
      dependsOn(generateFbsCpp)
    }
  }
  namespace 'com.flatbuffers.app'
}

dependencies {
  implementation fileTree(dir: "libs", include: ["*.jar"])
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  implementation 'androidx.appcompat:appcompat:1.6.1'

  // If you using java runtime you can add its dependency as the example below
  // implementation 'com.google.flatbuffers:flatbuffers-java:$latest_version'

}