1 /*
   2  * Copyright (c) 2014, 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 /**
  28  * Gets the most recent android platform installed, relative to the given path.
  29  * The path will either be ANDROID_SDK or ANDROID_NDK
  30  * TODO Shouldn't we instead just ask people to point to the one they want to use?
  31  *
  32  * @param path The path to the Android SDK or NDK
  33  * @return The name of the most recent platform
  34  */
  35 String getLatestPlatform(String path) {
  36     def max = 0
  37     println("$path")
  38     file(cygpath("$path/platforms")).eachFile() {file->
  39         def pname = file.getName() - "android-"
  40         def ptf = pname?.isInteger() ? pname.toInteger() : 0
  41         if (max < ptf) {
  42             max = ptf
  43         }
  44     }
  45     if (max == 0) {
  46         return null;
  47     }
  48     return "android-" + max
  49 }
  50 
  51 int compareVersions(String s1, String s2) {
  52     def v1t = s1.tokenize(".")
  53     def v2t = s2.tokenize(".")
  54     for(int i = 0; i < v1t.size(); i++) {
  55         if (i == v2t.size()) {
  56             return 1
  57         }
  58         int n1 = v1t[i].isInteger() ? v1t[i].toInteger() : 0
  59         int n2 = v2t[i].isInteger() ? v2t[i].toInteger() : 0
  60         if (n1 == n2) {
  61             continue
  62         } else if (n1 > n2) {
  63             return 1;
  64         } else {
  65             return -1
  66         }
  67     }
  68     return (v2t.size() > v1t.size()) ? -1 : 0
  69 }
  70 
  71 String getLatestToolchain(String ndk, String tch) {
  72     def max = "0.0"
  73     def matchFile = null
  74     file(cygpath("$ndk/toolchains")).eachFile() {file->
  75         def filename = file.getName()
  76         if (filename.startsWith(tch)) {
  77             def p = filename - "$tch-"
  78             if (compareVersions(p, max) > 0) {
  79                 max = p
  80                 matchFile = file
  81             }
  82         }
  83     }
  84     return matchFile.getAbsolutePath()
  85 }
  86 
  87 boolean assertDir(File dir) {
  88     return dir != null && dir.exists() && dir.isDirectory() && dir.canRead();
  89 }
  90 
  91 boolean assertDir(String dir) {
  92     return assertDir(file(dir))
  93 }
  94 
  95 def closedDir = file("$projectDir/../rt-closed")
  96 
  97 def toolchainArchs = ["arm-linux-androideabi", "mipsel-linux-android", "x86"]
  98 def armArchs = ["armeabi", "armeabiv-7a"]
  99 
 100 ext.DALVIK = [:]
 101 DALVIK.compileSwing = false;
 102 DALVIK.compileSWT = false;
 103 DALVIK.compileFXPackager = false;
 104 DALVIK.compileDesignTime = false;
 105 DALVIK.glassPlatform = "android"
 106 DALVIK.armArch = armArchs[0]
 107 DALVIK.libDest = "lib"
 108 DALVIK.jfxdvklib = "jfxdvk.jar"
 109 DALVIK.library = { name -> return "lib${name}.so" as String }
 110 DALVIK.includeMonocole = true
 111 DALVIK.includeLens = false
 112 
 113 def sdk = project.hasProperty("ANDROID_SDK") ? "${ANDROID_SDK}" : null;
 114 def ndk = project.hasProperty("ANDROID_NDK") ? "${ANDROID_NDK}" : null;
 115 DALVIK.canBuild = sdk != null && ndk != null
 116 if (!DALVIK.canBuild) {
 117     logger.error("Can't build Android. Path to SDK or NDK was not set or is invalid!")
 118     return;
 119 }
 120 
 121 DALVIK.canBuild = assertDir(sdk) && assertDir(ndk)
 122 if (!DALVIK.canBuild) {
 123     if (!assertDir(sdk)) {
 124         logger.error("Path to ANDROID_SDK is invalid! [$sdk]")
 125     }
 126     if (!assertDir(ndk)) {
 127         logger.error("Path to ANDROID_NDK is invalid! [$ndk]")
 128     }
 129     return
 130 }
 131 
 132 def sdk_target = project.hasProperty("ANDROID_SDK_TARGET") ?  "${ANDROID_SDK_TARGET}" : getLatestPlatform(sdk);
 133 if (!assertDir(file("$sdk/platforms/$sdk_target"))) {
 134     sdk_target = getLatestPlatform(sdk);
 135     logger.warn("Redefine ANDROID_SDK_TARGET to: [$sdk_target]")
 136 }
 137 
 138 def ndk_target = project.hasProperty("ANDROID_NDK_TARGET") ? "${ANDROID_NDK_TARGET}" : getLatestPlatform(ndk);
 139 if (!assertDir(file("$ndk/platforms/$ndk_target"))) {
 140     ndk_target = getLatestPlatform(ndk);
 141     logger.warn("Redefine ANDROID_NDK_TARGET to: [$ndk_target]")
 142 }
 143 
 144 DALVIK.canBuild = sdk_target != null && ndk_target != null
 145 if (!DALVIK.canBuild) {
 146     logger.error("Can't determine sdk or ndk target platform!")
 147     return
 148 }
 149 
 150 def toolchainHome = project.hasProperty("ANDROID_CROSS_TOOLS_VER") ?
 151     "$ndk/toolchains/${ANDROID_CROSS_TOOLS_VER}" : getLatestToolchain(ndk, toolchainArchs[0])
 152 if (!assertDir(toolchainHome)) {
 153     toolchainHome = getLatestToolchain(ndk, toolchainArchs[0])
 154     logger.warn("Redefine toolchain to [$toolchainHome]")
 155 }
 156 
 157 // Look for the the Android SDK & NDK to use, as well as the compiler stuff
 158 def compilerHome = null
 159 file("$toolchainHome/prebuilt").eachDir() {subdir ->
 160     compilerHome = subdir.getAbsolutePath()
 161     return
 162 }
 163 
 164 DALVIK.canBuild = compilerHome != null
 165 if (!DALVIK.canBuild) {
 166     logger.error("Failed to access toolchain [$toolchainHome/prebuilt/$toolsPlatform]!")
 167     return
 168 }
 169 
 170 def freetypeDir = project.hasProperty("FREETYPE_DIR") ? "${FREETYPE_DIR}" : null
 171 if (!assertDir(freetypeDir)) {
 172     logger.warn("FREETYPE_DIR $freetypeDir doesn't exists! Build continues without native text support.")
 173     freetypeDir = null
 174 }
 175 def compileNativeText = freetypeDir != null
 176 
 177 def compiler = file("$compilerHome/bin/${toolchainArchs[0]}-gcc").getAbsolutePath()
 178 def linker = file("$compilerHome/bin/${toolchainArchs[0]}-g++").getAbsolutePath()
 179 
 180 // Log the settings we're building with
 181 logger.quiet("ANDROID_SDK: $sdk")
 182 logger.quiet("ANDROID_SDK_TARGET: $sdk_target")
 183 logger.quiet("ANDROID_NDK: $ndk")
 184 logger.quiet("ANDROID_NDK_TARGET: $ndk_target")
 185 logger.quiet("FREETYPE_DIR: $freetypeDir")
 186 logger.quiet("Compile native text: $compileNativeText")
 187 logger.quiet("Android Compiler: $compiler")
 188 logger.quiet("Android Linker: $linker")
 189 
 190 //exclude from build
 191 project(":swing") {
 192     apply plugin: 'java'
 193 
 194     compileJava {
 195         enabled = false
 196     }
 197 }
 198 
 199 project(":fxml") {
 200     apply plugin: 'java'
 201 
 202     jar.dependsOn("retroClass");
 203 
 204     compileJava {
 205         enabled = true
 206     }
 207 }
 208 
 209 project(":jmx") {
 210     apply plugin: 'java'
 211 
 212     compileJava {
 213         enabled = false
 214     }
 215 }
 216 
 217 
 218 allprojects() {
 219     repositories {
 220         mavenCentral()
 221     }
 222     configurations {
 223         retroconfig
 224     }
 225 
 226     dependencies {
 227         retroconfig 'net.orfjackal.retrolambda:retrolambda:1.1.4'
 228     }
 229     task retroClass() <<{
 230             file classdirs = file ("$buildDir/classes");
 231             lf = classdirs.listFiles();
 232             classdirs.eachDir{t ->
 233                 javaexec {
 234                     inputdir = t
 235                     basecp = files(lf, "${project("base").buildDir}/classes/main", "${project("graphics").buildDir}/classes/main", "${project("controls").buildDir}/classes/main").asPath
 236                     myconfig = configurations.retroconfig;
 237                     lambdaloc = myconfig.resolve().toArray()[0];
 238                     classpath = configurations.retroconfig
 239                     main = 'net.orfjackal.retrolambda.Main'
 240                     jvmArgs = [
 241                                "-Xbootclasspath:$JDK_HOME/jre/lib/rt.jar",
 242                                 "-Dretrolambda.inputDir=$inputdir",
 243                                 "-Dretrolambda.classpath=$basecp",
 244                                 "-Dretrolambda.bytecodeVersion=51",
 245                                 "-javaagent:$lambdaloc"
 246                    ]
 247             }
 248         }
 249     }
 250 }
 251 
 252 
 253 project(":base") {
 254     apply plugin: 'java'
 255     jar.dependsOn("retroClass");
 256 }
 257 
 258 project(":web") {
 259     apply plugin: 'java'
 260     jar.dependsOn("retroClass");
 261     compileJava.dependsOn(":graphics:assemble");
 262     sourceSets.main.java.srcDirs = ['src/android/java'];
 263     sourceSets {
 264         main {
 265             java {
 266                 srcDirs= ['src/android/java']
 267             }
 268         }
 269     }
 270     dependencies {
 271          compile files("../graphics/build/classes/dalvik");
 272     }
 273 
 274     afterEvaluate {
 275     sourceSets.main.java.srcDirs = ['src/android/java'];
 276         def compileWebJavaAndroid = task("compileWebJavaAndroid",
 277             type: JavaCompile, group: "Build") {
 278 
 279             dependsOn(project(":graphics").classes, project(":base").classes)
 280             description = "Task compiles web component for Android."
 281             classpath = files(
 282                 project(":controls").sourceSets.main.output.classesDir,
 283                 project(":graphics").sourceSets.main.output.classesDir,
 284                 project(":base").sourceSets.main.output.classesDir,
 285                 "${project("graphics").buildDir}/classes/dalvik"
 286             )
 287             destinationDir = file("${project("web").buildDir}/classes/android")
 288             dependencyCacheDir = file("${project("web").buildDir}/dependency-cache")
 289             source file("${project("web").projectDir}/src/android/java")
 290         }
 291 
 292         def jarWebJavaAndroid = task("jarWebJavaAndroid",
 293             type: Jar, group: "Build") {
 294             description = "Creates web.jar for Android."
 295             dependsOn(compileWebJavaAndroid)
 296             archiveName = "web.jar"
 297             includeEmptyDirs = false
 298             destinationDir = project.file("build/libs/android")
 299             from("build/classes/android")
 300         }
 301         addNative(project, "webview")
 302         // addNative(project, "dvkwebview")
 303         javahDalvikWebview.dependsOn(compileWebJavaAndroid)
 304         // javahDalvikDvkwebview.dependsOn(compileWebJavaAndroid)
 305 
 306         jfxrtDalvik {
 307             from "${project("web").buildDir}/classes/android"
 308         }
 309 
 310   sdkDalvik  {
 311             dependsOn(jarWebJavaAndroid)
 312             doLast {
 313                 def props = project.ext["DALVIK"]
 314                 copy {
 315                     from ("${project("web").buildDir}/libs/webview/dalvik/${props.library(props.webview.lib)}")
 316                     into ("build/dalvik-sdk/${props.libDest}")
 317                 }
 318             }
 319         }
 320     }
 321 
 322 
 323     jar.dependsOn("retroClass");
 324 }
 325 
 326 project(":media") {
 327     apply plugin: 'java'
 328     jar.dependsOn("retroClass");
 329 }
 330 
 331 
 332 project(":graphics") {
 333 
 334     apply plugin: 'java'
 335 
 336     sourceSets.main.java {
 337         exclude "com/sun/glass/ui/swt/**"
 338     }
 339 
 340     assemble.dependsOn("retroClass");
 341     task compileDalvikLibs(type: JavaCompile, group: "Build") {
 342         description = "Task compiles dalvik vm based libraries."
 343         options.bootClasspath = "$sdk/platforms/$sdk_target/android.jar"
 344         classpath = files("build/classes/dalvik", "build/classes/main")
 345         destinationDir = file("build/classes/dalvik")
 346         dependencyCacheDir = file("build/dependency-cache")
 347         source fileTree(dir: 'src/dalvik/java').matching { include '**' }
 348     }
 349 
 350     task jarDalvikLibs(type: Jar, group: "Build", dependsOn: compileDalvikLibs) {
 351         description = "Creates jfxdvk.jar with all dalvik based classes."
 352         archiveName = "jfxdvk.jar"
 353         includeEmptyDirs = false
 354         from("build/classes/dalvik")
 355         include("javafxports/**/*")
 356         include("com/oracle/**/*")
 357         dependsOn(compileDalvikLibs)
 358     }
 359 
 360     jarDalvikLibs {
 361         eachFile {
 362                 if (it.name.endsWith('.class')) {
 363                     RandomAccessFile raf = new RandomAccessFile(it.file.path, "rw");
 364                     raf.seek(7);
 365                     raf.writeByte(0x32); //make it jdk6
 366                     raf.close();
 367                 }
 368             }
 369     }
 370 
 371     afterEvaluate {
 372         addNative(project, "activity")
 373         if (compileNativeText) {
 374             addNative(project, "fontNativeFreetype")
 375         }
 376         tasks["javahDalvikGlass"].dependsOn(compileDalvikLibs)
 377         tasks["javahDalvikActivity"].dependsOn(compileDalvikLibs)
 378         tasks["native"].dependsOn("nativeActivity")
 379         if (compileNativeText) {
 380             tasks["native"].dependsOn("nativeFontNativeFreetype")
 381         }
 382         tasks["javahDalvikPrismSW"].enabled = false
 383         tasks["ccDalvikPrismSW"].enabled = false;
 384         tasks["linkDalvikPrismSW"].enabled = false;
 385 
 386         sdkDalvik  {
 387             dependsOn(jarDalvikLibs)
 388             doLast {
 389                 def props = project.ext["DALVIK"]
 390                 copy {
 391                     from(
 392                          "${project("graphics").buildDir}/libs/activity/dalvik/${props.library(props.activity.lib)}"
 393                     )
 394                     into ("build/dalvik-sdk/${props.libDest}")
 395                 }
 396                 copy {
 397                     from ("${project("graphics").buildDir}/libs/${props.jfxdvklib}")
 398                     into ("build/dalvik-sdk/lib")
 399                 }
 400 /*
 401                 copy {
 402                     from ("${project("compat").buildDir}/libs/compat.jar")
 403                     into ("build/dalvik-sdk/lib")
 404                 }
 405 */
 406                 if (compileNativeText) {
 407                     copy {
 408                         from ("${project("graphics").buildDir}/libs/fontNativeFreetype/dalvik")
 409                         into ("build/dalvik-sdk/${props.libDest}")
 410                     }
 411                 }
 412             }
 413         }
 414     }
 415 }
 416 
 417 project(":controls") {
 418 
 419     apply plugin: 'java'
 420 /*
 421     compileJava {
 422          options.bootClasspath="/home/johan/open-jfx/bitbucket/8u-dev-build/compat/build/libs/compat-1.0.0.jar:$sdk/platforms/$sdk_target/android.jar"
 423      }
 424 */
 425 
 426 
 427     sourceSets.main.java.srcDir('src/android/java')
 428 /*
 429     sourceSets.main.java {
 430         exclude 'javafx/scene/control/Date*.java'
 431         exclude 'com/sun/javafx/scene/control/skin/Date*.java'
 432         exclude 'com/sun/javafx/scene/control/behavior/Date*.java'
 433     }
 434 */
 435     task copyResources() << {
 436         copy {
 437             from ("src/android/resources")
 438             into ("build/resources/dalvik")
 439         }
 440     }
 441 
 442     assemble.dependsOn("copyResources","retroClass");
 443 
 444     afterEvaluate {
 445 
 446         jfxrtDalvik {
 447             from ("${project("controls").buildDir}/classes/dalvik",
 448                   "${project("controls").buildDir}/resources/dalvik")
 449         }
 450 
 451     }
 452 }
 453 
 454 allprojects {
 455     afterEvaluate {
 456         sdkDalvik {
 457             doLast {
 458                 ant.jar(update: "true", destfile: "build/dalvik-sdk/lib/jfxrt.jar",
 459                     basedir: "build/dalvik-sdk/lib", includes: "*.properties")
 460             }
 461         }
 462     }
 463 }
 464 
 465 
 466 DALVIK.jfxrtJarExcludes = [
 467     "**/*.hlsl",
 468     "com/sun/glass/ui/win",
 469     "com/sun/glass/ui/accessible/win",
 470     "com/sun/prism/j2d",
 471     "com/sun/prism/sw",
 472     "com/sun/glass/ui/accessible/mac",
 473     "com/sun/glass/ui/ios",
 474     "com/sun/glass/ui/swt", // SWT glass
 475     "com/oracle/dalvik",
 476     // "javafx/scene/media", //exclude all media for now
 477     // "com/sun/media",
 478     // "com/sun/javafx/media",
 479     "com/sun/javafx/font/directwrite", //exclude non freetype font support
 480     "com/sun/javafx/font/coretext",
 481     "com/sun/javafx/font/freetype/Pango*",
 482     "com/sun/javafx/font/freetype/OSPango*",
 483     // "com/sun/webkit",   //exclude all WebView for now
 484     // "com/sun/javafx/webkit",
 485     // "com/sun/javafx/scene/web",
 486     // "javafx/scene/web",
 487     // "com/sun/javafx/sg/prism/NGWeb*",
 488     // "com/sun/javafx/sg/prism/web*",
 489     "javafx/print", //exclude printing
 490     "com/sun/javafx/print",
 491     "com/sun/javafx/tk/Print*"
 492 ]
 493 
 494 def text = (compileNativeText) ? "native" : ""
 495 
 496 DALVIK.javafxPlatformProperties = """
 497 javafx.platform=android
 498 android.javax.xml.stream.XMLInputFactory=com.sun.xml.stream.ZephyrParserFactory
 499 android.javax.xml.stream.XMLOutputFactory=com.sun.xml.stream.ZephyrWriterFactory
 500 android.javax.xml.stream.XMLEventFactory=com.sun.xml.stream.events.ZephyrEventFactory
 501 android.glass.platform=Monocle
 502 android.glass.lens=eglfb
 503 android.log.lens=FINEST
 504 android.prism.verbose=true
 505 DALVIK.prism.verbose=true
 506 android.prism.glDepthSize=16
 507 android.prism.lcdtext=false
 508 android.prism.debugfonts=true
 509 android.prism.text=$text
 510 android.embedded=monocle
 511 android.prism.allowhidpi=true
 512 android.prism.maxTextureSize=2048
 513 android.prism.dirtyopts=true
 514 android.prism.vsync=false
 515 android.use.egl=true
 516 android.com.sun.javafx.isEmbedded=true
 517 com.sun.javafx.gestures.zoom=true
 518 com.sun.javafx.gestures.rotate=true
 519 com.sun.javafx.gestures.scroll=true
 520 """
 521 def sysroot = "$ndk/platforms/$ndk_target/arch-arm"
 522 
 523 def ccFlags = ["--sysroot=$sysroot","-std=c99", "-DANDROID", "-c", "-nostdlib",
 524                "-DANDROID_NDK", "-DDALVIK_VM"]
 525 
 526 def ccOptFlags = ["-fpic", "-ffunction-sections", "-funwind-tables","-fstack-protector",
 527                   "-Os", "-O2", "-fno-strict-aliasing", "-finline-limit=64", "-fomit-frame-pointer"]
 528 def ccWarnFlags = ["-Wa,--noexecstack", "-Wno-psabi"]
 529 def ccArchFlags = ["-mthumb", "-msoft-float", "-D__ARM_ARCH_5__", "-D__ARM_ARCH_5T__", "-D__ARM_ARCH_5E__",
 530                    "-D__ARM_ARCH_5TE__", "-march=armv5te" , "-mtune=xscale"]
 531 def ccDebugFlags = [IS_DEBUG_NATIVE ? "-DDEBUG" : "-DNDEBUG"]
 532 def ccDefaultIncludeFlags = ["-I$ndk/platforms/$ndk_target/arch-arm/usr/include"]
 533 
 534 def linkFlags = ["--sysroot=$sysroot",
 535                  "-Wl,--no-undefined", "-Wl,-z,noexecstack", "-lc", "-lm", "-shared",
 536                  "-L$ndk/platforms/$ndk_target/arch-arm/usr/lib"]
 537 
 538 DALVIK.activity = [:]
 539 DALVIK.activity.javahSource = files("${project("graphics").buildDir}/classes/dalvik")
 540 DALVIK.activity.javahClasspath = files("${project("graphics").buildDir}/classes/dalvik", "$sdk/platforms/$sdk_target/android.jar")
 541 DALVIK.activity.javahInclude = ["javafxports/android/**"]
 542 DALVIK.activity.nativeSource = file("${project("graphics").projectDir}/src/dalvik/native")
 543 DALVIK.activity.compiler = compiler
 544 DALVIK.activity.linker = linker
 545 DALVIK.activity.lib = "activity"
 546 DALVIK.activity.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 547     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 548 DALVIK.activity.linkFlags = [linkFlags, "-landroid", "-llog"].flatten()
 549 
 550 DALVIK.webview = [:]
 551 DALVIK.webview.javahSource = files("${project("web").buildDir}/classes/android")
 552 DALVIK.webview.javahClasspath = files("${project("web").buildDir}/classes/android")
 553 DALVIK.webview.javahInclude = [
 554     "com/sun/webkit/NativeWebView.class"
 555 ]
 556 DALVIK.webview.nativeSource = [
 557     files("${project("web").projectDir}/src/android/native/native_webview.c",
 558 "${project("web").projectDir}/src/android/native/android_webview.c")
 559 ]
 560 DALVIK.webview.compiler = compiler
 561 DALVIK.webview.linker = linker
 562 DALVIK.webview.lib = "webview"
 563 DALVIK.webview.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 564     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 565 DALVIK.webview.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 566 
 567 DALVIK.dvkwebview = [:]
 568 DALVIK.dvkwebview.javahSource = files("${project("web").buildDir}/classes/android")
 569 DALVIK.dvkwebview.javahClasspath = files("${project("web").buildDir}/classes/android")
 570 DALVIK.dvkwebview.javahInclude = [
 571     "com/sun/webkit/NativeWebView.class"
 572 ]
 573 DALVIK.dvkwebview.nativeSource = [
 574     file("${project("web").projectDir}/src/android/native/android_webview.c")
 575 ]
 576 DALVIK.dvkwebview.compiler = compiler
 577 DALVIK.dvkwebview.linker = linker
 578 DALVIK.dvkwebview.lib = "android_webview"
 579 DALVIK.dvkwebview.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 580     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 581 DALVIK.dvkwebview.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 582 
 583 DALVIK.glass = [:]
 584 // DALVIK.glass.variants = ["eglfb", "lensport"]
 585 DALVIK.glass.variants = []
 586 DALVIK.glass.variants = ["monocle"]
 587 DALVIK.glass.javahSource = files("${project("graphics").buildDir}/classes/dalvik",
 588  "${project("graphics").buildDir}/classes/main")
 589 DALVIK.glass.javahClasspath = files("${project("graphics").buildDir}/classes/main",
 590  "${project("graphics").buildDir}/classes/dalvik",
 591  "${project("base").buildDir}/classes/main",
 592  "$sdk/platforms/$sdk_target/android.jar")
 593 DALVIK.glass.javahInclude = [
 594     "javafxports/android/**",
 595     "com/sun/glass/ui/monocle/*",
 596     "com/sun/glass/ui/monocle/util/*",
 597     "com/sun/glass/events/**",
 598     "com/sun/glass/ui/*",
 599     "com/sun/glass/ui/android/*",
 600     "com/sun/glass/ui/lens/*"]
 601 
 602 DALVIK.glass.lensport = [:]
 603 DALVIK.glass.lensport.nativeSource = [
 604     file("${project("graphics").projectDir}/src/main/native-glass/lens/lensport/initPlatform.c"),
 605     file("${project("graphics").projectDir}/src/main/native-glass/lens/wrapped/wrapped_functions.c")
 606 ]
 607 DALVIK.glass.lensport.compiler = compiler
 608 DALVIK.glass.lensport.linker = linker
 609 DALVIK.glass.lensport.lib = "lens_porting"
 610 DALVIK.glass.lensport.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 611     ccDebugFlags, ccDefaultIncludeFlags, "-DISEGLFB", "-DLENSPORT",
 612     "-I", file("${project("graphics").projectDir}/src/main/native-glass/lens")].flatten()
 613 DALVIK.glass.lensport.linkFlags = [linkFlags, "-ldl", "-llog"].flatten()
 614 
 615 def monocleCFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 616     ccDebugFlags, ccDefaultIncludeFlags, "-DISEGLFB",
 617     "-I", file("${project("graphics").projectDir}/src/main/native-glass/monocle/"),
 618     "-I", file("${project("graphics").projectDir}/src/dalvik/native/")
 619 ].flatten()
 620 
 621 DALVIK.glass.monocle = [:]
 622 DALVIK.glass.monocle.nativeSource = [
 623         file("${project("graphics").projectDir}/src/main/native-glass/monocle"),
 624         file("${project("graphics").projectDir}/src/main/native-glass/monocle/android"),
 625         file("${project("graphics").projectDir}/src/main/native-glass/monocle/util") ]
 626 DALVIK.glass.monocle.compiler = compiler
 627 DALVIK.glass.monocle.ccFlags = monocleCFlags
 628 DALVIK.glass.monocle.linker = linker
 629 DALVIK.glass.monocle.linkFlags =  [linkFlags, "-ldl", "-llog", "-landroid", "-lGLESv2", "-lEGL"].flatten()
 630 
 631 DALVIK.glass.monocle.lib = "glass_monocle"
 632 
 633 DALVIK.javafxPlatformDefault="eglfb"
 634 
 635 def monoclePlatformAdditions = """
 636 monocle.glass.platform=Monocle
 637 monocle.prism.order=es2,sw
 638 monocle.prism.eglfb=true
 639 monocle.prism.lcdtext=false
 640 monocle.prism.maxvram=128m
 641 monocle.prism.targetvram=112m
 642 monocle.use.egl=true
 643 monocle.use.gles2=true
 644 monocle.embedded=monocle
 645 monocle.com.sun.javafx.isEmbedded=true
 646 monocle.doNativeComposite=true
 647 monocle.com.sun.javafx.scene.control.skin.FXVK.cache=true
 648 monocle.prism.glDepthSize=0
 649 monocle.com.sun.javafx.gestures.zoom=true
 650 monocle.com.sun.javafx.gestures.rotate=true
 651 monocle.com.sun.javafx.gestures.scroll=true"""
 652 
 653 
 654 
 655 DALVIK.glass.eglfb = [:]
 656 DALVIK.glass.eglfb.nativeSource = [
 657     file("${project("graphics").projectDir}/src/main/native-glass/lens"),
 658     file("${project("graphics").projectDir}/src/main/native-glass/lens/wm"),
 659     file("${project("graphics").projectDir}/src/main/native-glass/lens/cursor/nullCursor"),
 660     file("${project("graphics").projectDir}/src/main/native-glass/lens/dalvik")
 661 ]
 662 DALVIK.glass.eglfb.compiler = compiler
 663 DALVIK.glass.eglfb.linker = linker
 664 DALVIK.glass.eglfb.lib = "glass_lens_eglfb"
 665 DALVIK.glass.eglfb.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 666     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 667 DALVIK.glass.eglfb.linkFlags = [linkFlags, "-ldl", "-landroid", "-llog"].flatten()
 668 
 669 DALVIK.prism = [:]
 670 DALVIK.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
 671 DALVIK.prism.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism")
 672 DALVIK.prism.compiler = compiler
 673 DALVIK.prism.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 674     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 675 DALVIK.prism.linker = linker
 676 DALVIK.prism.linkFlags = [linkFlags].flatten()
 677 DALVIK.prism.lib = "prism_common"
 678 
 679 DALVIK.prismSW = [:]
 680 DALVIK.prismSW.javahInclude = ["com/sun/pisces/**/*"]
 681 DALVIK.prismSW.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism-sw")
 682 DALVIK.prismSW.compiler = compiler
 683 DALVIK.prismSW.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 684     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 685 DALVIK.prismSW.linker = linker
 686 DALVIK.prismSW.linkFlags = [linkFlags].flatten()
 687 DALVIK.prismSW.lib = "prism_sw"
 688 
 689 DALVIK.decora = [:]
 690 DALVIK.decora.compiler = compiler
 691 DALVIK.decora.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 692     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 693 DALVIK.decora.linker = linker
 694 DALVIK.decora.linkFlags = [linkFlags].flatten()
 695 DALVIK.decora.lib = "decora_sse"
 696 
 697 DALVIK.iio = [:]
 698 DALVIK.iio.javahInclude = ["com/sun/javafx/iio/**/*"]
 699 DALVIK.iio.nativeSource = [
 700     file("${project("graphics").projectDir}/src/main/native-iio"),
 701     file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")]
 702 DALVIK.iio.compiler = compiler
 703 DALVIK.iio.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 704     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 705 DALVIK.iio.linker = linker
 706 DALVIK.iio.linkFlags = [linkFlags].flatten()
 707 DALVIK.iio.lib = "javafx_iio"
 708 
 709 DALVIK.prismES2 = [:]
 710 DALVIK.prismES2.variants = ["monocle"]
 711 DALVIK.prismES2.javahInclude = ["com/sun/prism/es2/**/*"]
 712 
 713 DALVIK.prismES2.monocle= [:]
 714 DALVIK.prismES2.monocle.nativeSource = [
 715     file("${project("graphics").projectDir}/src/main/native-prism-es2"),
 716     file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"),
 717     file("${project("graphics").projectDir}/src/main/native-prism-es2/eglWrapper"),
 718     file("${project("graphics").projectDir}/src/main/native-prism-es2/monocle")
 719 ]
 720 DALVIK.prismES2.monocle.compiler = compiler
 721 DALVIK.prismES2.monocle.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 722     ccDebugFlags, ccDefaultIncludeFlags, "-DIS_EGLFB"].flatten()
 723 DALVIK.prismES2.monocle.linker = linker
 724 DALVIK.prismES2.monocle.linkFlags = [linkFlags, "-ldl", "-llog", "-lGLESv2", "-lEGL"].flatten()
 725 DALVIK.prismES2.monocle.lib = "prism_es2_monocle"
 726 
 727 DALVIK.prismES2.eglfb = [:]
 728 DALVIK.prismES2.eglfb.nativeSource = [
 729     file("${project("graphics").projectDir}/src/main/native-prism-es2"),
 730     file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"),
 731     file("${project("graphics").projectDir}/src/main/native-prism-es2/wrapped"),
 732     file("${project("graphics").projectDir}/src/main/native-prism-es2/eglfb")]
 733 DALVIK.prismES2.eglfb.compiler = compiler
 734 DALVIK.prismES2.eglfb.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 735     ccDebugFlags, ccDefaultIncludeFlags, "-DIS_EGLFB"].flatten()
 736 DALVIK.prismES2.eglfb.linker = linker
 737 DALVIK.prismES2.eglfb.linkFlags = [linkFlags, "-ldl", "-llog", "-lGLESv2", "-lEGL"].flatten()
 738 DALVIK.prismES2.eglfb.lib = "prism_es2_eglfb"
 739 
 740 DALVIK.font = [:]
 741 DALVIK.font.javahInclude = [
 742         "com/sun/javafx/font/**/*",
 743         "com/sun/javafx/text/**/*"]
 744 DALVIK.font.nativeSource = [file("$closedDir/javafx-font-native/src")]
 745 DALVIK.font.compiler = compiler
 746 DALVIK.font.ccFlags = [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 747     ccDebugFlags, ccDefaultIncludeFlags].flatten()
 748 DALVIK.font.linker = linker
 749 DALVIK.font.linkFlags = [linkFlags].flatten()
 750 DALVIK.font.lib = "javafx_font"
 751 
 752 if (compileNativeText) {
 753     DALVIK.fontNativeFreetype = [:]
 754     DALVIK.fontNativeFreetype.javahInclude = [
 755         "com/sun/javafx/font/freetype/OSFreetype.class"
 756     ]
 757     DALVIK.fontNativeFreetype.nativeSource = [
 758         file("${project("graphics").projectDir}/src/main/native-font/freetype.c")
 759     ]
 760     DALVIK.fontNativeFreetype.compiler = compiler
 761     DALVIK.fontNativeFreetype.linker = linker
 762     DALVIK.fontNativeFreetype.lib = "javafx_font_freetype"
 763 
 764     ccFlags += ["-D_ENABLE_HARFBUZZ"]
 765 
 766     DALVIK.fontNativeFreetype.ccFlags =
 767         [ccFlags, ccWarnFlags, ccArchFlags, ccOptFlags,
 768         ccDebugFlags, ccDefaultIncludeFlags,
 769         "-I$freetypeDir/include", "-I$freetypeDir/include/freetype2"].flatten()
 770 
 771     DALVIK.fontNativeFreetype.linkFlags =
 772         [linkFlags, "-llog",
 773          "-L$freetypeDir/lib", "$freetypeDir/lib/libfreetype.a"].flatten()
 774 }
 775 
 776 DALVIK.media = [:]
 777 DALVIK.media.compiler = compiler
 778 DALVIK.media.linker = linker
 779 DALVIK.media.lib = file("$compilerHome/bin/${toolchainArchs[0]}-ar").getAbsolutePath()
 780 DALVIK.includeEGL = true
 781 DALVIK.includeGTK = true
 782 DALVIK.includeLens = true
 783 ext.IS_COMPILE_PANGO = false
 784 ext.IS_COMPILE_JFR = false