1 /* 2 * Copyright (c) 2013, 2018, 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 ext.ARMV6HF = [:] 27 28 // Define the location of the sdk and toolchain 29 def crossLibsPackage="armv6hf-02" 30 def sdk=file("${rootProject.CROSS_TOOLS_DIR}/$crossLibsPackage") 31 def compilerHome=file("${rootProject.CROSS_TOOLS_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux") 32 def compilerPrefix 33 def jniPlatform 34 if (IS_LINUX) { 35 fetchExternalTools('ARMV6HF', 36 ["${crossLibsPackage}.tgz", 37 "gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux.tgz" ], 38 rootProject.CROSS_TOOLS_DIR, rootProject.IS_IMPORT_CROSS_TOOLS) 39 40 compilerHome=file("${rootProject.CROSS_TOOLS_DIR}/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux") 41 compilerPrefix="arm-linux-gnueabihf-" 42 jniPlatform="linux" 43 } else if (IS_MAC) { 44 fetchExternalTools('ARMV6HF', 45 ["${crossLibsPackage}.tgz"], 46 rootProject.CROSS_TOOLS_DIR, rootProject.IS_IMPORT_CROSS_TOOLS) 47 48 compilerHome=file("/usr/local/arm-linux") 49 compilerPrefix="arm-linux-" 50 jniPlatform="darwin" 51 } else { 52 fail("armv6hf Cannot build on this platform") 53 } 54 55 if (rootProject.hasProperty("ARMV6HF_COMPILER")) { 56 logger.quiet "Using alternate ARMV6HF_COMPILER $rootProject.ARMV6HF_COMPILER" 57 compilerHome=file(rootProject.ARMV6HF_COMPILER); 58 } 59 if (rootProject.hasProperty("ARMV6HF_COMPILER_PREFIX")) { 60 logger.quiet "Using alternate ARMV6HF_COMPILER_PREFIX $rootProject.ARMV6HF_COMPILER_PREFIX" 61 compilerPrefix="${rootProject.ARMV6HF_COMPILER_PREFIX}" 62 } 63 64 def compiler = file("$compilerHome/bin/${compilerPrefix}gcc").getAbsolutePath() 65 def linker = file("$compilerHome/bin/${compilerPrefix}g++").getAbsolutePath() 66 67 // Declare whether this particular target file applies to the current system 68 ARMV6HF.canBuild = (IS_LINUX || IS_MAC) && compilerHome.exists() && sdk.exists() 69 if (!ARMV6HF.canBuild) { 70 if (!compilerHome.exists()) println "ERROR: Missing compiler $compilerHome" 71 if (!sdk.exists()) println "ERROR: Missing sdk $sdk" 72 fail("armv6hf missing required tools") 73 } 74 75 // Lambda for naming the generated libs 76 ARMV6HF.library = { name -> return "lib${name}.so" as String } 77 78 ARMV6HF.compileSwing = false; 79 ARMV6HF.compileSWT = false; 80 ARMV6HF.compileWebnodeNative = false; 81 ARMV6HF.compileMediaNative = false; 82 83 ARMV6HF.includeMonocle = true 84 ARMV6HF.includeNull3d = true 85 ARMV6HF.includeEGL = true 86 ARMV6HF.includeSwing = false 87 ARMV6HF.includeSWT = false 88 ARMV6HF.includeGTK = true 89 90 ARMV6HF.javafxPlatformDefault="monocle" 91 92 // Libraries end up in the sdk/lib/arm directory for arm builds 93 ARMV6HF.arch = "arm" 94 ARMV6HF.libDest = "lib" 95 96 def commonFlags = [ 97 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags 98 "-Wextra", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags 99 // Specify the compilation parameters and link parameters 100 def ccFlags = [ 101 commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/$jniPlatform", "-c", 102 IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten() 103 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"]) 104 def linkFlags = ["-shared", commonFlags].flatten() 105 106 // Specify the compilation parameters and link parameters 107 def extraCFlags = [ 108 ccFlags, 109 "-marm", "-mfloat-abi=hard", "-mfpu=vfp", 110 "-I$sdk/usr/include", 111 "-I$sdk/opt/vc/include", 112 "-I$sdk/opt/vc/include/interface/vcos/pthreads", 113 "-I$sdk/opt/vc/include/interface/vmcs_host/linux", 114 "-DOMAP3", "-DUSE_DISPMAN"].flatten(); 115 116 //See if we should build for imx6 117 def imxHeader=file("$sdk/usr/include/linux/mxcfb.h") 118 if (imxHeader.exists()) { 119 extraCFlags = [extraCFlags,"-DIMX6_PLATFORM"].flatten(); 120 } 121 122 def extraLFlags = [ 123 linkFlags, 124 "-L$sdk/lib/arm-linux-gnueabihf", 125 "-L$sdk/usr/lib", 126 "-L$sdk/usr/lib/arm-linux-gnueabihf", 127 "-L$sdk/opt/vc/lib"].flatten() 128 129 def monocleCFlags = [ 130 extraCFlags, 131 "-Werror", 132 "-I", file("${project("graphics").projectDir}/src/main/native-glass/monocle/")].flatten(); 133 def monocleLFlags = [extraLFlags, "-ldl", "-lm"].flatten() 134 135 def fontCFlags = [extraCFlags].flatten() 136 def fontLFlags = [extraLFlags, "-ldl"].flatten() 137 138 def iioCFlags = [extraCFlags, 139 "-Wno-main" // suppress warnings about using main as a variable, 3rd party code 140 ].flatten() 141 def iioLFlags = [extraLFlags].flatten() 142 143 def es2EglfbCFlags = [extraCFlags, "-DIS_EGLFB", "-DLINUX"].flatten() 144 def es2EglfbLFlags = [extraLFlags].flatten() 145 def es2MonocleCFlags = [extraCFlags, "-DIS_EGLFB", "-DLINUX"].flatten() 146 def es2MonocleLFlags = [extraLFlags].flatten() 147 148 def es2X11CFlags = [extraCFlags, "-DUSE_XSHM", "-DDEBUG", "-DIS_EGLX11", "-DLINUX"].flatten() 149 def es2X11LFlags = [extraLFlags, "-lX11", "-lXext", "-lXdmcp", "-lXau"].flatten() 150 151 def mediaCFlags = [extraCFlags, 152 "-I$sdk/usr/include/gstreamer-0.10", 153 "-I$sdk/usr/include/glib-2.0", 154 "-I$sdk/usr/lib/arm-linux-gnueabihf/glib-2.0/include", 155 "-DENABLE_NATIVE_SOURCE=1", "-DENABLE_GST_FFMPEG=1"].flatten() 156 def mediaLFlags = [extraLFlags, "-lgstreamer-0.10", "-lgstapp-0.10", 157 "-lgstbase-0.10", "-lglib-2.0", "-lgobject-2.0", "-lgmodule-2.0", "-lgthread-2.0"].flatten() 158 159 def webCFlags = [extraCFlags].flatten() 160 def webLFlags = [extraLFlags].flatten() 161 162 def gtkCFlags = [extraCFlags].flatten() 163 def gtkLFlags = [extraLFlags].flatten() 164 165 def gtkCFlags_pkgconfig = "-pthread -I${sdk}/usr/include/gtk-2.0 -I${sdk}/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I${sdk}/usr/include/atk-1.0 -I${sdk}/usr/include/cairo -I${sdk}/usr/include/gdk-pixbuf-2.0 -I${sdk}/usr/include/pango-1.0 -I${sdk}/usr/include/gio-unix-2.0/ -I${sdk}/usr/include -I${sdk}/usr/include/glib-2.0 -I${sdk}/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I${sdk}/usr/include/pixman-1 -I${sdk}/usr/include/freetype2 -I${sdk}/usr/include/libpng12" 166 167 def gtkLFlags_pkgconfig = "-pthread -L${sdk}/usr/lib/arm-linux-gnueabihf -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0 -lXtst" 168 169 gtkCFlags.addAll(gtkCFlags_pkgconfig.split(" ")) 170 gtkLFlags.addAll(gtkLFlags_pkgconfig.split(" ")) 171 172 def monoclePlatformAdditions = """ 173 monocle.glass.platform=Monocle 174 monocle.prism.order=es2,sw 175 monocle.prism.eglfb=true 176 monocle.prism.lcdtext=false 177 monocle.prism.maxvram=128m 178 monocle.prism.targetvram=112m 179 monocle.use.egl=true 180 monocle.use.gles2=true 181 monocle.embedded=monocle 182 monocle.com.sun.javafx.isEmbedded=true 183 monocle.doNativeComposite=true 184 monocle.com.sun.javafx.scene.control.skin.FXVK.cache=true 185 monocle.prism.glDepthSize=0 186 monocle.com.sun.javafx.gestures.zoom=true 187 monocle.com.sun.javafx.gestures.rotate=true 188 monocle.com.sun.javafx.gestures.scroll=true""" 189 190 def gtkPlatformAdditions = """ 191 gtk.com.sun.javafx.scene.control.skin.ListViewSkin.pannable=true 192 gtk.com.sun.javafx.scene.control.skin.TreeViewSkin.pannable=true 193 gtk.com.sun.javafx.scene.control.skin.TableViewSkin.pannable=true 194 gtk.glass.platform=gtk 195 gtk.prism.order=sw 196 gtk.com.sun.javafx.isEmbedded=true 197 gtk.com.sun.javafx.scene.control.skin.FXVK.cache=true 198 gtk.com.sun.javafx.gestures.zoom=true 199 gtk.com.sun.javafx.gestures.rotate=true 200 gtk.com.sun.javafx.gestures.scroll=true""" 201 202 def pangoCCFlags = [extraCFlags, "-D_ENABLE_PANGO"]; 203 def pangoLinkFlags = [extraLFlags]; 204 205 def pangoCFlags_pkgconfig = "-pthread -I${sdk}/usr/include/pango-1.0 -I${sdk}/usr/include/freetype2 -I${sdk}/usr/include -I${sdk}/usr/include/glib-2.0 -I${sdk}/usr/lib/arm-linux-gnueabihf/glib-2.0/include" 206 207 def pangoLFlags_pkgconfig = "-L${sdk}/usr/lib/arm-linux-gnueabihf -lpangoft2-1.0 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lglib-2.0" 208 209 pangoCCFlags.addAll(pangoCFlags_pkgconfig.split(" ")) 210 pangoLinkFlags.addAll(pangoLFlags_pkgconfig.split(" ")) 211 212 def freetypeCCFlags = [ext.IS_COMPILE_PANGO ? "-D_ENABLE_PANGO" : 213 ext.IS_COMPILE_HARFBUZZ ? "-D_ENABLE_HARFBUZZ" : ""] 214 def freetypeLinkFlags = [] 215 216 def freetypeCFlags_pkgconfig = "-I${sdk}/usr/include/freetype2 -I${sdk}/usr/include" 217 def freetypeLFlags_pkgconfig = "-L${sdk}/usr/lib/arm-linux-gnueabihf -lfreetype" 218 219 freetypeCCFlags.addAll(freetypeCFlags_pkgconfig.split(" ")) 220 freetypeLinkFlags.addAll(freetypeLFlags_pkgconfig.split(" ")) 221 222 ARMV6HF.javafxPlatformProperties = "javafx.platform=${ARMV6HF.javafxPlatformDefault}" 223 224 ARMV6HF.glass = [:] 225 ARMV6HF.glass.javahInclude = [ 226 "com/sun/glass/events/**", 227 "com/sun/glass/ui/*"] 228 ARMV6HF.glass.variants = [ ] 229 if (ARMV6HF.includeMonocle) { 230 ARMV6HF.glass.variants.addAll("monocle", "monocle_x11"); 231 ARMV6HF.glass.javahInclude.addAll( 232 "com/sun/glass/ui/monocle/*", 233 "com/sun/glass/ui/monocle/dispman/*", 234 "com/sun/glass/ui/monocle/mx6/*", 235 "com/sun/glass/ui/monocle/linux/*", 236 "com/sun/glass/ui/monocle/util/*", 237 "com/sun/glass/ui/monocle/x11/*"); 238 ARMV6HF.javafxPlatformProperties = ARMV6HF.javafxPlatformProperties + monoclePlatformAdditions 239 } 240 if (ARMV6HF.includeGTK) { 241 ARMV6HF.glass.variants.addAll("gtk"); 242 ARMV6HF.glass.javahInclude.addAll("com/sun/glass/ui/gtk/*"); 243 ARMV6HF.javafxPlatformProperties = ARMV6HF.javafxPlatformProperties + gtkPlatformAdditions 244 } 245 246 ARMV6HF.glass.lib = "glass" 247 248 ARMV6HF.glass.monocle = [:] 249 ARMV6HF.glass.monocle.nativeSource = [ 250 file("${project("graphics").projectDir}/src/main/native-glass/monocle"), 251 file("${project("graphics").projectDir}/src/main/native-glass/monocle/dispman"), 252 file("${project("graphics").projectDir}/src/main/native-glass/monocle/mx6"), 253 file("${project("graphics").projectDir}/src/main/native-glass/monocle/linux"), 254 file("${project("graphics").projectDir}/src/main/native-glass/monocle/util") ] 255 ARMV6HF.glass.monocle.compiler = compiler 256 ARMV6HF.glass.monocle.ccFlags = monocleCFlags 257 ARMV6HF.glass.monocle.linker = linker 258 ARMV6HF.glass.monocle.linkFlags = monocleLFlags 259 ARMV6HF.glass.monocle.lib = "glass_monocle" 260 261 ARMV6HF.glass.monocle_x11 = [:] 262 ARMV6HF.glass.monocle_x11.nativeSource = [ 263 file("${project("graphics").projectDir}/src/main/native-glass/monocle/util"), 264 file("${project("graphics").projectDir}/src/main/native-glass/monocle/x11") ] 265 ARMV6HF.glass.monocle_x11.compiler = compiler 266 ARMV6HF.glass.monocle_x11.ccFlags = monocleCFlags 267 ARMV6HF.glass.monocle_x11.linker = linker 268 ARMV6HF.glass.monocle_x11.linkFlags = [ monocleLFlags, "-lX11" ].flatten() 269 ARMV6HF.glass.monocle_x11.lib = "glass_monocle_x11" 270 271 FileTree ft_gtk = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") { 272 exclude("**/launcher.c") 273 } 274 File gen_headers = new File("${project(":graphics").buildDir}/gensrc/headers/javafx.graphics") 275 276 ARMV6HF.glass.gtk = [:] 277 ARMV6HF.glass.gtk.nativeSource = ft_gtk.getFiles() 278 ARMV6HF.glass.gtk.compiler = compiler 279 ARMV6HF.glass.gtk.ccFlags = ["-ffast-math", gtkCFlags, "-DLINUX", "-I${gen_headers}"].flatten() 280 ARMV6HF.glass.gtk.linker = linker 281 ARMV6HF.glass.gtk.linkFlags = [gtkLFlags, "-lstdc++"].flatten() 282 ARMV6HF.glass.gtk.lib = "glass" 283 284 ARMV6HF.decora = [:] 285 ARMV6HF.decora.compiler = compiler 286 ARMV6HF.decora.ccFlags = extraCFlags 287 ARMV6HF.decora.linker = linker 288 ARMV6HF.decora.linkFlags = extraLFlags 289 ARMV6HF.decora.lib = "decora_sse" 290 291 ARMV6HF.prism = [:] 292 ARMV6HF.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 293 ARMV6HF.prism.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism") 294 ARMV6HF.prism.compiler = compiler 295 ARMV6HF.prism.ccFlags = [extraCFlags].flatten() 296 ARMV6HF.prism.linker = linker 297 ARMV6HF.prism.linkFlags = [extraLFlags].flatten() 298 ARMV6HF.prism.lib = "prism_common" 299 300 ARMV6HF.prismSW = [:] 301 ARMV6HF.prismSW.javahInclude = ["com/sun/pisces/**/*"] 302 ARMV6HF.prismSW.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism-sw") 303 ARMV6HF.prismSW.compiler = compiler 304 ARMV6HF.prismSW.ccFlags = [extraCFlags].flatten() 305 ARMV6HF.prismSW.linker = linker 306 ARMV6HF.prismSW.linkFlags = [extraLFlags].flatten() 307 ARMV6HF.prismSW.lib = "prism_sw" 308 309 ARMV6HF.iio = [:] 310 ARMV6HF.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 311 ARMV6HF.iio.nativeSource = [ 312 file("${project("graphics").projectDir}/src/main/native-iio"), 313 file("${project("graphics").projectDir}/src/main/native-iio/libjpeg9c")] 314 ARMV6HF.iio.compiler = compiler 315 ARMV6HF.iio.ccFlags = iioCFlags 316 ARMV6HF.iio.linker = linker 317 ARMV6HF.iio.linkFlags = iioLFlags 318 ARMV6HF.iio.lib = "javafx_iio" 319 320 ARMV6HF.prismES2 = [:] 321 ARMV6HF.prismES2.variants = ["monocle"] 322 ARMV6HF.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 323 324 ARMV6HF.prismES2.monocle= [:] 325 ARMV6HF.prismES2.monocle.nativeSource = [ 326 file("${project("graphics").projectDir}/src/main/native-prism-es2"), 327 file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), 328 file("${project("graphics").projectDir}/src/main/native-prism-es2/monocle") 329 ] 330 ARMV6HF.prismES2.monocle.compiler = compiler 331 ARMV6HF.prismES2.monocle.ccFlags = [ es2EglfbCFlags, "-I", "-I${gen_headers}" ].flatten() 332 ARMV6HF.prismES2.monocle.linker = linker 333 ARMV6HF.prismES2.monocle.linkFlags =[ es2EglfbLFlags, "-ldl" ].flatten() 334 ARMV6HF.prismES2.monocle.lib = "prism_es2_monocle" 335 336 def closedDir = file("$projectDir/../rt-closed") 337 ARMV6HF.font = [:] 338 ARMV6HF.font.javahInclude = [ 339 "com/sun/javafx/font/**/*", 340 "com/sun/javafx/text/**/*"] 341 ARMV6HF.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] 342 ARMV6HF.font.compiler = compiler 343 ARMV6HF.font.ccFlags = fontCFlags 344 ARMV6HF.font.linker = linker 345 ARMV6HF.font.linkFlags = fontLFlags 346 ARMV6HF.font.lib = "javafx_font" 347 348 ARMV6HF.fontFreetype = [:] 349 ARMV6HF.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class*"] 350 ARMV6HF.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 351 ARMV6HF.fontFreetype.compiler = compiler 352 ARMV6HF.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, fontCFlags, freetypeCCFlags].flatten() 353 ARMV6HF.fontFreetype.linker = linker 354 ARMV6HF.fontFreetype.linkFlags = [linkFlags, fontLFlags, freetypeLinkFlags, "-ldl"].flatten() 355 ARMV6HF.fontFreetype.lib = "javafx_font_freetype" 356 357 ARMV6HF.fontPango = [:] 358 ARMV6HF.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"] 359 ARMV6HF.fontPango.nativeSource = ["src/main/native-font/pango.c"] 360 ARMV6HF.fontPango.compiler = compiler 361 ARMV6HF.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 362 ARMV6HF.fontPango.linker = linker 363 ARMV6HF.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 364 ARMV6HF.fontPango.lib = "javafx_font_pango" 365 366 ARMV6HF.webkit = [:] 367 ARMV6HF.webkit.binDir = "$compilerHome/bin" 368 ARMV6HF.webkit.compiler = compiler 369 ARMV6HF.webkit.linker = linker 370 ARMV6HF.webkit.ar = file("$compilerHome/bin/${compilerPrefix}ar").getAbsolutePath() 371 ARMV6HF.webkit.objcopy = file("$compilerHome/bin/${compilerPrefix}objcopy").getAbsolutePath() 372 ARMV6HF.webkit.strip = file("$compilerHome/bin/${compilerPrefix}strip").getAbsolutePath() 373 ARMV6HF.webkit.ccFlags = extraCFlags.join(' ') 374 ARMV6HF.webkit.linkFlags = extraLFlags.join(' ') 375 376 ARMV6HF.disableMedia = true 377 ARMV6HF.media = [:] 378 ARMV6HF.media.compiler = compiler 379 ARMV6HF.media.linker = linker 380 ARMV6HF.media.extra_cflags = mediaCFlags.join(' ') 381 ARMV6HF.media.extra_ldflags = mediaLFlags.join(' ') 382 383 ARMV6HF.deploy = [:] 384 ARMV6HF.deploy.publicLibraryFilter = [ 385 "fxavcodecplugin-52.so", 386 "fxavcodecplugin-53.so", 387 "fxplugins.so", 388 "libjfxwebkit.so", 389 "libgstplugins-lite.so", 390 "libgstreamer-lite.so", 391 "libprism_es2_eglx11.so", 392 ] 393 ARMV6HF.deploy.compressBigJar=true