1 /*
   2  * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /**
  27  * Gets the most recent android platform installed, relative to the given path.
  28  * The path will either be ANDROID_SDK or ANDROID_NDK
  29  * TODO Shouldn't we instead just ask people to point to the one they want to use?
  30  *
  31  * @param path The path to the Android SDK or NDK
  32  * @return The name of the most recent platform
  33  */
  34 String getLatestPlatform(String path) {
  35     def max = 0
  36     file(cygpath("$path/platforms")).eachFile() {file->
  37         def pname = file.getName() - "android-"
  38         def ptf = pname?.isInteger() ? pname.toInteger() : 0
  39         if (max < ptf) {
  40             max = ptf
  41         }
  42     }
  43     if (max == 0) {
  44         return null;
  45     }
  46     return "android-" + max
  47 }
  48 
  49 int compareVersions(String s1, String s2) {
  50     def v1t = s1.tokenize(".")
  51     def v2t = s2.tokenize(".")
  52     for(int i = 0; i < v1t.size(); i++) {
  53         if (i == v2t.size()) {
  54             return 1
  55         }
  56         int n1 = v1t[i].isInteger() ? v1t[i].toInteger() : 0
  57         int n2 = v2t[i].isInteger() ? v2t[i].toInteger() : 0
  58         if (n1 == n2) {
  59             continue
  60         } else if (n1 > n2) {
  61             return 1;
  62         } else {
  63             return -1
  64         }
  65     }
  66     return (v2t.size() > v1t.size()) ? -1 : 0
  67 }
  68 
  69 String getLatestToolchain(String ndk, String tch) {
  70     def max = "0.0"
  71     def matchFile = null
  72     file(cygpath("$ndk/toolchains")).eachFile() {file->
  73         def filename = file.getName()
  74         if (filename.startsWith(tch)) {
  75             def p = filename - "$tch-"
  76             if (compareVersions(p, max) > 0) {
  77                 max = p
  78                 matchFile = file
  79             }
  80         }
  81     }
  82     return matchFile.getAbsolutePath()
  83 }
  84 
  85 boolean assertDir(File dir) {
  86     return dir != null && dir.exists() && dir.isDirectory() && dir.canRead();
  87 }
  88 
  89 boolean assertDir(String dir) {
  90     return assertDir(file(dir))
  91 }
  92 
  93 def closedDir = file("$projectDir/../rt-closed")
  94 
  95 def toolchainArchs = ["arm-linux-androideabi", "mipsel-linux-android", "x86"]
  96 def armArchs = ["armeabi", "armeabiv-7a"]
  97 
  98 ANDROID = [:]
  99 ANDROID.compileSwing = false;
 100 ANDROID.compileSWT = false;
 101 ANDROID.compileFXPackager = false;
 102 ANDROID.glassPlatform = "android"
 103 ANDROID.armArch = armArchs[0]
 104 ANDROID.libDest = "lib"
 105 ANDROID.jfxdvklib = "jfxdvk.jar"
 106 ANDROID.library = { name -> return "lib${name}.so" as String }
 107 
 108 def sdk = project.hasProperty("ANDROID_SDK") ? "${ANDROID_SDK}" : null;
 109 def ndk = project.hasProperty("ANDROID_NDK") ? "${ANDROID_NDK}" : null;
 110 ANDROID.canBuild = sdk != null && ndk != null
 111 if (!ANDROID.canBuild) {
 112     fail("Can't build Android. Path to SDK or NDK was not set or is invalid!")
 113 }
 114 
 115 ANDROID.canBuild = assertDir(sdk) && assertDir(ndk)
 116 if (!ANDROID.canBuild) {
 117     if (!assertDir(sdk)) {
 118         logger.error("Path to ANDROID_SDK is invalid! [$sdk]")
 119     }
 120     if (!assertDir(ndk)) {
 121         logger.error("Path to ANDROID_NDK is invalid! [$ndk]")
 122     }
 123     fail("Cannot build, missing android tools")
 124 }
 125 
 126 def sdk_target = project.hasProperty("ANDROID_SDK_TARGET") ?  "${ANDROID_SDK_TARGET}" : getLatestPlatform(sdk);
 127 if (!assertDir(file("$sdk/platforms/$sdk_target"))) {
 128     sdk_target = getLatestPlatform(sdk);
 129     logger.warn("Redefine ANDROID_SDK_TARGET to: [$sdk_target]")
 130 }
 131 
 132 def ndk_target = project.hasProperty("ANDROID_NDK_TARGET") ? "${ANDROID_NDK_TARGET}" : getLatestPlatform(ndk);
 133 if (!assertDir(file("$ndk/platforms/$ndk_target"))) {
 134     ndk_target = getLatestPlatform(ndk);
 135     logger.warn("Redefine ANDROID_NDK_TARGET to: [$ndk_target]")
 136 }
 137 
 138 ANDROID.canBuild = sdk_target != null && ndk_target != null
 139 if (!ANDROID.canBuild) {
 140     fail("Can't determine sdk or ndk target platform!")
 141 }
 142 
 143 def toolchainHome = project.hasProperty("ANDROID_CROSS_TOOLS_VER") ?
 144     "$ndk/toolchains/${ANDROID_CROSS_TOOLS_VER}" : getLatestToolchain(ndk, toolchainArchs[0])
 145 if (!assertDir(toolchainHome)) {
 146     toolchainHome = getLatestToolchain(ndk, toolchainArchs[0])
 147     logger.warn("Redefine toolchain to [$toolchainHome]")
 148 }
 149 
 150 // Look for the the Android SDK & NDK to use, as well as the compiler stuff
 151 def compilerHome = null
 152 file("$toolchainHome/prebuilt").eachDir() {subdir ->
 153     compilerHome = subdir.getAbsolutePath()
 154     return
 155 }
 156 
 157 ANDROID.canBuild = compilerHome != null
 158 if (!ANDROID.canBuild) {
 159     fail("Failed to access toolchain [$toolchainHome/prebuilt/$toolsPlatform]!")
 160 }
 161 
 162 def freetypeDir = project.hasProperty("FREETYPE_DIR") ? "${FREETYPE_DIR}" : null
 163 if (!assertDir(freetypeDir)) {
 164     logger.warn("FREETYPE_DIR $freetypeDir doesn't exists! Build continues without native text support.")
 165     freetypeDir = null
 166 }
 167 def compileNativeText = freetypeDir != null
 168 
 169 def compiler = file("$compilerHome/bin/${toolchainArchs[0]}-gcc").getAbsolutePath()
 170 def linker = file("$compilerHome/bin/${toolchainArchs[0]}-g++").getAbsolutePath()
 171 
 172 // Log the settings we're building with
 173 logger.quiet("ANDROID_SDK: $sdk")
 174 logger.quiet("ANDROID_SDK_TARGET: $sdk_target")
 175 logger.quiet("ANDROID_NDK: $ndk")
 176 logger.quiet("ANDROID_NDK_TARGET: $ndk_target")
 177 logger.quiet("FREETYPE_DIR: $freetypeDir")
 178 logger.quiet("Compile native text: $compileNativeText")
 179 logger.quiet("Android Compiler: $compiler")
 180 logger.quiet("Android Linker: $linker")
 181 
 182 project(":graphics") {
 183 
 184     task compileDalvikLibs(type: JavaCompile, group: "Build") {
 185         description = "Task compiles dalvik vm based libraries."
 186         sourceCompatibility = JavaVersion.VERSION_1_6
 187         targetCompatibility = JavaVersion.VERSION_1_6
 188         options.bootClasspath = "$sdk/platforms/$sdk_target/android.jar"
 189         classpath = files("build/classes/android")
 190         destinationDir = file("build/classes/android")
 191         dependencyCacheDir = file("build/dependency-cache")
 192         source fileTree(dir: 'src/android/java').matching { include 'com/oracle/dalvik/**' }
 193     }
 194 
 195     task jarDalvikLibs(type: Jar, group: "Build", dependsOn: compileDalvikLibs) {
 196         description = "Creates jfxdvk.jar with all dalvik based classes."
 197         archiveName = "jfxdvk.jar"
 198         includeEmptyDirs = false
 199         from("build/classes/android")
 200         include("com/oracle/dalvik/**/*")
 201         dependsOn(compileDalvikLibs)
 202     }
 203 
 204     afterEvaluate {
 205         addNative(project, "surface", ["android"])
 206         addNative(project, "vmlauncher", ["android"])
 207         if (compileNativeText) {
 208             addNative(project, "fontNativeFreetype", ["android"])
 209         }
 210         tasks["javahAndroidVmlauncher"].dependsOn(compileDalvikLibs)
 211         tasks["native"].dependsOn("nativeSurface", "nativeVmlauncher")
 212         if (compileNativeText) {
 213             tasks["native"].dependsOn("nativeFontNativeFreetype")
 214         }
 215 
 216         sdkAndroid  {
 217             dependsOn(jarDalvikLibs)
 218             doLast {
 219                 def props = project.ext["ANDROID"]
 220                 copy {
 221                     from(
 222                          "${project("graphics").buildDir}/libs/vmlauncher/android/${props.library(props.vmlauncher.lib)}",
 223                          "${project("graphics").buildDir}/libs/surface/android/${props.library(props.surface.lib)}"
 224                     )
 225                     into ("build/android-sdk/dalvik/${props.libDest}")
 226                 }
 227                 copy {
 228                     from ("${project("graphics").buildDir}/libs/${props.jfxdvklib}")
 229                     into ("build/android-sdk/dalvik/lib")
 230                 }
 231                 if (compileNativeText) {
 232                     copy {
 233                         from ("${project("graphics").buildDir}/libs/fontNativeFreetype/android")
 234                         into ("build/android-sdk/$ANDROID.libDest")
 235                     }
 236                 }
 237             }
 238         }
 239     }
 240 }
 241 
 242 project(":controls") {
 243     afterEvaluate {
 244         task compileControlsJavaAndroid(type: JavaCompile, group: "Build", dependsOn: [":graphics:compileJava", ":controls:compileJava"]) {
 245             description = "Task compiles controls for Android"
 246             classpath = files("${project("base").buildDir}/classes/main",
 247                 "${project("graphics").buildDir}/classes/main",
 248                 "${project("controls").buildDir}/classes/main"
 249             )
 250             destinationDir = file("${project("controls").buildDir}/classes/android")
 251             dependencyCacheDir = file("${project("controls").buildDir}/dependency-cache")
 252             source file("${project("controls").projectDir}/src/android/java")
 253         }
 254 
 255        task processControlsResourcesAndroid() {
 256            copy {
 257                from ("${project("controls").projectDir}/src/android/resources")
 258                into ("${project("controls").buildDir}/resources/android")
 259            }
 260         }
 261 
 262         sdkAndroid {
 263             dependsOn(compileControlsJavaAndroid, processControlsResourcesAndroid)
 264         }
 265     }
 266 }
 267 
 268 project(":web") {
 269     apply plugin: 'java'
 270 
 271     compileJava {
 272         enabled = false
 273     }
 274 
 275     afterEvaluate {
 276         if (!BUILD_CLOSED) {
 277             logger.warn("OpenJFX build. Skipping webkit build on Android.")
 278             return
 279         }
 280         def compileWebJavaAndroid = task("compileWebJavaAndroid",
 281             type: JavaCompile, group: "Build") {
 282 
 283             dependsOn(project(":graphics").classes, project(":base").classes)
 284             description = "Task compiles web component for Android."
 285             classpath = files(
 286                 project(":controls").sourceSets.main.output.classesDir,
 287                 project(":graphics").sourceSets.main.output.classesDir,
 288                 project(":base").sourceSets.main.output.classesDir
 289             )
 290             destinationDir = file("${project("web").buildDir}/classes/android")
 291             dependencyCacheDir = file("${project("web").buildDir}/dependency-cache")
 292             source file("${project("web").projectDir}/src/android/java")
 293         }
 294 
 295         def jarWebJavaAndroid = task("jarWebJavaAndroid",
 296             type: Jar, group: "Build") {
 297             description = "Creates web.jar for Android."
 298             dependsOn(compileWebJavaAndroid)
 299             archiveName = "web.jar"
 300             includeEmptyDirs = false
 301             destinationDir = project.file("build/libs/android")
 302             from("build/classes/android")
 303         }
 304 
 305         addNative(project, "webview", ["android"])
 306         addNative(project, "dvkwebview", ["android"])
 307         javahAndroidWebview.dependsOn(compileWebJavaAndroid)
 308         javahAndroidDvkwebview.dependsOn(compileWebJavaAndroid)
 309 
 310         jfxrtAndroid {
 311             from "${project("web").buildDir}/classes/android"
 312         }
 313 
 314         sdkAndroid  {
 315             dependsOn(jarWebJavaAndroid)
 316             doLast {
 317                 def props = project.ext["ANDROID"]
 318                 copy {
 319                     from(
 320                          "${project("web").buildDir}/libs/dvkwebview/android/${props.library(props.dvkwebview.lib)}"
 321                     )
 322                     into ("build/android-sdk/dalvik/${props.libDest}")
 323                 }
 324                 copy {
 325                     from ("${project("web").buildDir}/libs/webview/android/${props.library(props.webview.lib)}")
 326                     into ("build/android-sdk/${props.libDest}")
 327                 }
 328             }
 329         }
 330     }
 331 }
 332 
 333 
 334 ANDROID.jfxrtJarExcludes = [
 335     "**/*.hlsl",
 336     "com/sun/glass/ui/win",
 337     "com/sun/prism/d3d",
 338     "com/sun/prism/es2/gl/win",
 339     "com/sun/prism/null3d",
 340     "com/sun/scenario/effect/impl/hw/d3d",
 341     "com/sun/glass/events/mac",
 342     "com/sun/glass/ui/mac",
 343     "com/sun/prism/es2/gl/mac",
 344     "com/sun/glass/ui/gtk",
 345     "com/sun/glass/ui/ios",
 346     "com/sun/prism/es2/gl/eglx11",
 347     "com/sun/prism/es2/gl/x11",
 348     "com/sun/glass/ui/swt", // SWT glass
 349     "javafx/embed/swing", // Swing Interop
 350     "javafx/embed/swt", // SWT Interop
 351     "com/oracle/dalvik"
 352 ]
 353 
 354 def text = (compileNativeText) ? "native" : "t2k"
 355 
 356 ANDROID.javafxPlatformProperties = """
 357 javafx.platform=android
 358 android.glass.platform=Lens
 359 android.glass.lens=eglfb
 360 android.prism.glDepthSize=16
 361 android.prism.lcdtext=false
 362 android.prism.debugfonts=true
 363 android.prism.text=$text
 364 android.embedded=eglfb
 365 android.prism.allowhidpi=false
 366 android.prism.maxTextureSize=2048
 367 android.prism.dirtyopts=true
 368 android.prism.vsync=false
 369 android.log.lens=FINE
 370 android.use.egl=true
 371 android.com.sun.javafx.isEmbedded=true
 372 """
 373 def sysroot = "$ndk/platforms/$ndk_target/arch-arm"
 374 
 375 def ccFlags = ["--sysroot=$sysroot","-std=c99", "-DANDROID", "-c", "-nostdlib",
 376                "-DANDROID_NDK"]
 377 
 378 if (project.hasProperty("DALVIK_VM")) {
 379     ccFlags += ["-DDALVIK_VM"]
 380 }
 381 
 382 def ccOptFlags = ["-fpic", "-ffunction-sections", "-funwind-tables","-fstack-protector",
 383                   "-Os", "-O2", "-fno-strict-aliasing", "-finline-limit=64", "-fomit-frame-pointer"]
 384 def ccWarnFlags = ["-Wa,--noexecstack", "-Wno-psabi"]
 385 def ccArchFlags = ["-mthumb", "-msoft-float", "-D__ARM_ARCH_5__", "-D__ARM_ARCH_5T__", "-D__ARM_ARCH_5E__",
 386                    "-D__ARM_ARCH_5TE__", "-march=armv5te" , "-mtune=xscale"]
 387 def ccDebugFlags = [IS_DEBUG_NATIVE ? "-DDEBUG" : "-DNDEBUG"]
 388 def ccDefaultIncludeFlags = ["-I$ndk/platforms/$ndk_target/arch-arm/usr/include"]
 389 
 390 def linkFlags = ["--sysroot=$sysroot",
 391                  "-Wl,--no-undefined", "-Wl,-z,noexecstack", "-lc", "-lm", "-shared",
 392                  "-L$ndk/platforms/$ndk_target/arch-arm/usr/lib"]
 393 
 394 
 395 ANDROID.vmlauncher = [:]
 396 ANDROID.vmlauncher.classpath = files("$sdk/platforms/$sdk_target/android.jar",
 397                                      "${project("graphics").buildDir}/classes/android")
 398 
 399 ANDROID.vmlauncher.javahSource = files("${project("graphics").buildDir}/classes/android")
 400 ANDROID.vmlauncher.javahClasspath = files("${project("graphics").buildDir}/classes/android",
 401                                           "$sdk/platforms/$sdk_target/android.jar")
 402 ANDROID.vmlauncher.javahInclude = [
 403     "com/oracle/dalvik/*"
 404 ]
 405 ANDROID.vmlauncher.nativeSource = [
 406     file("${project("graphics").projectDir}/src/android/native/VMLauncher.c"),
 407     file("${project("graphics").projectDir}/src/android/native/NativePipeReader.c"),
 408     file("${project("graphics").projectDir}/src/android/native/DalvikProxySelector.c")
 409 ]
 410 ANDROID.vmlauncher.compiler = compiler
 411 ANDROID.vmlauncher.linker = linker
 412 ANDROID.vmlauncher.lib = "vmlauncher"
 413 ANDROID.vmlauncher.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 414     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 415 ANDROID.vmlauncher.linkFlags = [linkFlags, "-llog"].flatten()
 416 
 417 ANDROID.surface = [:]
 418 ANDROID.surface.javahInclude = [
 419     "com/sun/glass/events/*",
 420     "com/sun/glass/ui/android/*"
 421 ]
 422 ANDROID.surface.nativeSource = [
 423     file("${project("graphics").projectDir}/src/main/native-glass/lens/android")
 424 ]
 425 ANDROID.surface.compiler = compiler
 426 ANDROID.surface.linker = linker
 427 ANDROID.surface.lib = "glass_lens_android"
 428 ANDROID.surface.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 429     ccDebugFlags, ccDefaultIncludeFlags, "-Isrc/main/native-glass/lens"].flatten()
 430 ANDROID.surface.linkFlags = [linkFlags, "-ldl", "-landroid", "-llog"].flatten()
 431 
 432 ANDROID.webview = [:]
 433 ANDROID.webview.javahSource = files("${project("web").buildDir}/classes/android")
 434 ANDROID.webview.javahClasspath = files("${project("web").buildDir}/classes/android")
 435 ANDROID.webview.javahInclude = [
 436     "com/sun/webkit/NativeWebView.class"
 437 ]
 438 ANDROID.webview.nativeSource = [
 439     file("${project("web").projectDir}/src/android/native/native_webview.c")
 440 ]
 441 ANDROID.webview.compiler = compiler
 442 ANDROID.webview.linker = linker
 443 ANDROID.webview.lib = "webview"
 444 ANDROID.webview.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 445     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 446 ANDROID.webview.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 447 
 448 ANDROID.dvkwebview = [:]
 449 ANDROID.dvkwebview.javahSource = files("${project("web").buildDir}/classes/android")
 450 ANDROID.dvkwebview.javahClasspath = files("${project("web").buildDir}/classes/android")
 451 ANDROID.dvkwebview.javahInclude = [
 452     "com/sun/webkit/NativeWebView.class"
 453 ]
 454 ANDROID.dvkwebview.nativeSource = [
 455     file("${project("web").projectDir}/src/android/native/android_webview.c")
 456 ]
 457 ANDROID.dvkwebview.compiler = compiler
 458 ANDROID.dvkwebview.linker = linker
 459 ANDROID.dvkwebview.lib = "android_webview"
 460 ANDROID.dvkwebview.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 461     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 462 ANDROID.dvkwebview.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 463 
 464 ANDROID.glass = [:]
 465 ANDROID.glass.variants = ["eglfb", "lensport"]
 466 ANDROID.glass.javahInclude = [
 467     "com/sun/glass/events/**",
 468     "com/sun/glass/ui/*",
 469     "com/sun/glass/ui/android/*",
 470     "com/sun/glass/ui/lens/*"]
 471 
 472 ANDROID.glass.lensport = [:]
 473 ANDROID.glass.lensport.nativeSource = [
 474     file("${project("graphics").projectDir}/src/main/native-glass/lens/lensport"),
 475     file("${project("graphics").projectDir}/src/main/native-glass/lens/lensport/initPlatform.c"),
 476     file("${project("graphics").projectDir}/src/main/native-glass/lens/lensport/wrapped_functions.c")
 477 ]
 478 ANDROID.glass.lensport.compiler = compiler
 479 ANDROID.glass.lensport.linker = linker
 480 ANDROID.glass.lensport.lib = "lens_porting"
 481 ANDROID.glass.lensport.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 482     ccDebugFlags, ccDefaultIncludeFlags, "-DISEGLFB", "-DLENSPORT",
 483     "-I", file("${project("graphics").projectDir}/src/main/native-glass/lens")].flatten()
 484 ANDROID.glass.lensport.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 485 
 486 ANDROID.glass.eglfb = [:]
 487 ANDROID.glass.eglfb.nativeSource = [
 488     file("${project("graphics").projectDir}/src/main/native-glass/lens"),
 489     file("${project("graphics").projectDir}/src/main/native-glass/lens/wm"),
 490     file("${project("graphics").projectDir}/src/main/native-glass/lens/cursor/nullCursor"),
 491     file("${project("graphics").projectDir}/src/main/native-glass/lens/input/android"),
 492     file("${project("graphics").projectDir}/src/main/native-glass/lens/wm/screen/androidScreen.c")
 493 ]
 494 ANDROID.glass.eglfb.compiler = compiler
 495 ANDROID.glass.eglfb.linker = linker
 496 ANDROID.glass.eglfb.lib = "glass_lens_eglfb"
 497 ANDROID.glass.eglfb.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 498     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 499 ANDROID.glass.eglfb.linkFlags = [linkFlags, "-ldl", "-landroid", "-llog"].flatten()
 500 
 501 ANDROID.prism = [:]
 502 ANDROID.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
 503 ANDROID.prism.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism")
 504 ANDROID.prism.compiler = compiler
 505 ANDROID.prism.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 506     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 507 ANDROID.prism.linker = linker
 508 ANDROID.prism.linkFlags = [linkFlags].flatten()
 509 ANDROID.prism.lib = "prism_common"
 510 
 511 ANDROID.prismSW = [:]
 512 ANDROID.prismSW.javahInclude = ["com/sun/pisces/**/*"]
 513 ANDROID.prismSW.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism-sw")
 514 ANDROID.prismSW.compiler = compiler
 515 ANDROID.prismSW.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 516     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 517 ANDROID.prismSW.linker = linker
 518 ANDROID.prismSW.linkFlags = [linkFlags].flatten()
 519 ANDROID.prismSW.lib = "prism_sw"
 520 
 521 ANDROID.decora = [:]
 522 ANDROID.decora.compiler = compiler
 523 ANDROID.decora.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 524     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 525 ANDROID.decora.linker = linker
 526 ANDROID.decora.linkFlags = [linkFlags].flatten()
 527 ANDROID.decora.lib = "decora_sse"
 528 
 529 ANDROID.iio = [:]
 530 ANDROID.iio.javahInclude = ["com/sun/javafx/iio/**/*"]
 531 ANDROID.iio.nativeSource = [
 532     file("${project("graphics").projectDir}/src/main/native-iio"),
 533     file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")]
 534 ANDROID.iio.compiler = compiler
 535 ANDROID.iio.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 536     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 537 ANDROID.iio.linker = linker
 538 ANDROID.iio.linkFlags = [linkFlags].flatten()
 539 ANDROID.iio.lib = "javafx_iio"
 540 
 541 ANDROID.prismES2 = [:]
 542 ANDROID.prismES2.variants = ["eglfb"]
 543 ANDROID.prismES2.javahInclude = ["com/sun/prism/es2/**/*"]
 544 
 545 ANDROID.prismES2.eglfb = [:]
 546 ANDROID.prismES2.eglfb.nativeSource = [
 547     file("${project("graphics").projectDir}/src/main/native-prism-es2"),
 548     file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"),
 549     file("${project("graphics").projectDir}/src/main/native-prism-es2/eglfb")]
 550 ANDROID.prismES2.eglfb.compiler = compiler
 551 ANDROID.prismES2.eglfb.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 552     ccDebugFlags, ccDefaultIncludeFlags, "-DIS_EGLFB"].flatten()
 553 ANDROID.prismES2.eglfb.linker = linker
 554 ANDROID.prismES2.eglfb.linkFlags = [linkFlags, "-ldl", "-llog", "-lGLESv2", "-lEGL"].flatten()
 555 ANDROID.prismES2.eglfb.lib = "prism_es2_eglfb"
 556 
 557 ANDROID.font = [:]
 558 ANDROID.font.javahInclude = [
 559         "com/sun/javafx/font/**/*",
 560         "com/sun/javafx/text/**/*"]
 561 ANDROID.font.nativeSource = [file("$closedDir/javafx-font-native/src")]
 562 ANDROID.font.compiler = compiler
 563 ANDROID.font.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 564     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 565 ANDROID.font.linker = linker
 566 ANDROID.font.linkFlags = [linkFlags].flatten()
 567 ANDROID.font.lib = "javafx_font"
 568 
 569 if (BUILD_CLOSED) {
 570     ANDROID.fontT2K = [:]
 571     ANDROID.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"]
 572     ANDROID.fontT2K.nativeSource = [
 573         file("$closedDir/javafx-font-t2k-native/src"),
 574         file("$closedDir/javafx-font-t2k-native/src/layout")]
 575     ANDROID.fontT2K.compiler = compiler
 576     ANDROID.fontT2K.ccFlags = [ccFlags, "-DLE_STANDALONE", "-fno-exceptions", "-fno-rtti", ccWarnFlags,
 577         ccArchFlags, ccOptFlags, ccDebugFlags, ccDefaultIncludeFlags].flatten()
 578     ANDROID.fontT2K.linker = linker
 579     ANDROID.fontT2K.linkFlags = [linkFlags, "-lstdc++"].flatten()
 580     ANDROID.fontT2K.lib = "javafx_font_t2k"
 581 }
 582 
 583 if (compileNativeText) {
 584     ANDROID.fontNativeFreetype = [:]
 585     ANDROID.fontNativeFreetype.javahInclude = [
 586         "com/sun/javafx/font/freetype/OSFreetype.class"
 587     ]
 588     ANDROID.fontNativeFreetype.nativeSource = [
 589         file("${project("graphics").projectDir}/src/main/native-font/freetype.c")
 590     ]
 591     ANDROID.fontNativeFreetype.compiler = compiler
 592     ANDROID.fontNativeFreetype.linker = linker
 593     ANDROID.fontNativeFreetype.lib = "javafx_font_freetype"
 594 
 595     ccFlags += ["-D_ENABLE_HARFBUZZ"]
 596 
 597     ANDROID.fontNativeFreetype.ccFlags =
 598         [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 599         ccDebugFlags, ccDefaultIncludeFlags,
 600         "-I$freetypeDir/include", "-I$freetypeDir/include/freetype2"].flatten()
 601 
 602     ANDROID.fontNativeFreetype.linkFlags =
 603         [linkFlags, "-llog",
 604          "-L$freetypeDir/lib", "$freetypeDir/lib/libfreetype.a"].flatten()
 605 }
 606 
 607 ANDROID.media = [:]
 608 ANDROID.media.compiler = compiler
 609 ANDROID.media.linker = linker
 610 ANDROID.media.lib = file("$compilerHome/bin/${toolchainArchs[0]}-ar").getAbsolutePath()