view buildSrc/armv6sf.gradle @ 4255:35a82a42d440

RT-31523 add gradle support to build font-pango library
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Wed, 10 Jul 2013 13:32:02 -0700
parents b43eb1f37da3
children fc82052a4113
line wrap: on
line source
/*
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

ext.ARMV6SF = [:]

fetchExternalTools('ARMV6SF', [ "armv6-vfp-03.tgz" ], 
  rootProject.CROSS_TOOLS_DIR, rootProject.IMPORT_CROSS_TOOLS)

// Define the location of the sdk and toolchain
def sdk=file("${rootProject.CROSS_TOOLS_DIR}/armv6-vfp-03")

def compilerHome=file("/opt/arm-2009q1")

// Declare whether this particular target file applies to the current system
ARMV6SF.canBuild = IS_LINUX && compilerHome.exists() && sdk.exists()
if (!ARMV6SF.canBuild) {
    if (!compilerHome.exists()) println "ERROR: Mising compiler $compilerHome"
    if (!sdk.exists()) println "ERROR: Mising sdk $sdk"
    return;
}

// Lambda for naming the generated libs
ARMV6SF.library = { name -> return "lib${name}.so" as String }

// alias for this platform in legacy artifacts
ARMV6SF.artifactsName = "armv6-vfp"

ARMV6SF.compileSwing = false;
ARMV6SF.compileSWT = false;
ARMV6SF.compileFXPackager = false;
ARMV6SF.compileDesignTime = false;

// Libraries end up in the sdk/rt/lib/arm directory for arm builds
ARMV6SF.libDest = "lib/arm"

// TODO this is garbage. Each target file should define what it includes,
// not what it excludes.
ARMV6SF.jfxrtJarExcludes = [
    "**/*.hlsl",
    "com/sun/glass/ui/win",
    "com/sun/glass/ui/accessible/win",
    "com/sun/prism/d3d",
    "com/sun/prism/es2/gl/win",
    //"com/sun/prism/null3d",
    "com/sun/scenario/effect/impl/hw/d3d",
    
    "com/sun/glass/events/mac",
    "com/sun/glass/ui/mac",
    "com/sun/glass/ui/accessible/mac",
    "com/sun/prism/es2/gl/mac",
        
    "com/sun/glass/ui/android",
    
    "com/sun/glass/ui/ios",
    
    "com/sun/glass/ui/swt", // SWT glass
    
    "javafx/embed/swing", // Swing Interop
    
    "javafx/embed/swt", // SWT Interop

    "com/sun/prism/es2/MacGL*",
    "com/sun/prism/es2/IOSGL*",
    "com/sun/prism/es2/WinGL*",
]

def commonFlags = [
        "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags
        "-W", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags
// Specify the compilation parameters and link parameters
def ccFlags = [
        commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c",
        IS_DEBUG ? ["-ggdb", "-DVERBOSE"] : "-O2"].flatten()
//ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"])
def linkFlags = ["-shared", commonFlags].flatten()

// Specify the compilation parameters and link parameters
def extraCFlags = [
        "-I", "-L",
        ccFlags,
        "-march=armv6", "-mfloat-abi=softfp", "-mfpu=vfp",
        "-I$sdk/usr/include",
        "-D_GNU_SOURCE", "-DOMAP3"].flatten();
def extraLFlags = [
        "-I", "-L",
        linkFlags,
        "-Wl,-rpath-link", "$sdk/usr/lib",
        "-L$sdk/usr/lib"].flatten()

def x11CFlags = [extraCFlags, "-DUSE_XSHM"].flatten()
def x11LFlags = [extraLFlags, "-lX11", "-lXext"].flatten()
def eglCFlags = [extraCFlags].flatten()
def eglLFlags = [extraLFlags].flatten()
def dfbCFlags = ["-I$sdk/usr/include/directfb"]
def dfbLFlags = ["-ldl"]
// TODO dfb.args=disable-module=ps2mouse,disable-module=keyboard

def lensLFlags = [extraLFlags, "-lpthread", "-ludev", "-ldl", "-lm"].flatten()
def glassCFlags = ["-ffast-math"]
def glassLFlags = []

def fontCFlags = [extraCFlags].flatten()
def fontLFlags = [extraLFlags].flatten()

def iioCFlags = [extraCFlags].flatten()
def iioLFlags = [extraLFlags].flatten()

def es2CFlags = [extraCFlags].flatten()
def es2LFlags = [extraLFlags, x11LFlags, eglLFlags].flatten()

def es2EglfbCFlags = [extraCFlags, eglCFlags, "-DIS_EGLFB", "-DLINUX", "-DGRADLE_BUILD"].flatten()
def es2EglfbLFlags = [extraLFlags, eglLFlags].flatten()

def es2X11CFlags = [extraCFlags, eglCFlags, x11CFlags, "-DDEBUG", "-DIS_EGLX11", "-DLINUX", "-DGRADLE_BUILD"].flatten()
def es2X11LFlags = [extraLFlags, x11LFlags, eglLFlags, "-lXdmcp", "-lXau"].flatten()

def prismSWCFlags = [extraCFlags].flatten()
def prismSWLFlags = [extraLFlags].flatten()

def mediaCFlags = [extraCFlags,
    "-I$sdk/usr/include/gstreamer-0.10",
    "-I$sdk/usr/include/glib-2.0",
    "-I$sdk/usr/lib/arm-linux-gnueabihf/glib-2.0/include",
    "-DENABLE.nativeSource=1", "-DENABLE_GST_FFMPEG=1"].flatten()
def mediaLFlags = [extraLFlags, "-lgstreamer-0.10", "-lgstapp-0.10",
    "-lgstbase-0.10", "-lglib-2.0", "-lgobject-2.0", "-lgmodule-2.0", "-lgthread-2.0"].flatten()

def webCFlags = [extraCFlags].flatten()
def webLFlags = [extraLFlags].flatten()

// libraries to remove from the sdk
//deploy.trim.public.library.filter= \
//  fxavcodecplugin-52.so \
//  fxavcodecplugin-53.so \
//  fxplugins.so \
//  libjfxwebkit.so \
//  libgstplugins-lite.so \
//  libgstreamer-lite.so \
//  libprism-es2-eglx11.so \
//  libglass-lens-fb.so \

//defineProperty("CC", "gcc");
//defineProperty("PRISM_CC", "cc");
//defineProperty("PRISM_SW_CC", "cc");

setupTools("armv6-sf_tools",
    { propFile ->
        ByteArrayOutputStream results = new ByteArrayOutputStream();
        exec {
            commandLine("$sdk/bin/pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst");
            setStandardOutput(results);
        }
        propFile << "cflags=" << results.toString().trim() << "\n";

        results = new ByteArrayOutputStream();
        exec {
            commandLine "$sdk/bin/pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst"
            standardOutput = results
        }
        propFile << "libs=" << results.toString().trim();
    },
    { properties ->
        // TODO ONLY TO BE USED WITH GTK COMPILATION
//        extraCFlags.addAll(properties.getProperty("cflags").split(" "))
//        extraLFlags.addAll(properties.getProperty("libs").split(" "))
    }
)

ARMV6SF.javafxPlatformProperties = """javafx.platform=eglfb
directfb.glass.platform=Lens
directfb.glass.lens=dfb
directfb.prism.order=sw
directfb.com.sun.javafx.isEmbedded=true
directfb.com.sun.javafx.scene.control.skin.FXVK.cache=true
eglfb.maxTextureSize=2048
eglfb.glass.platform=Lens
eglfb.glass.lens=eglfb
eglfb.prism.order=es2
eglfb.prism.eglfb=true
eglfb.prism.device=true
eglfb.prism.lcdtext=false
eglfb.use.egl=true
eglfb.doNativeComposite=true
eglfb.use.gles2=true
eglfb.embedded=eglfb
eglfb.com.sun.javafx.isEmbedded=true
eglfb.com.sun.javafx.scene.control.skin.FXVK.cache=true
fb.glass.platform=Lens
fb.glass.lens=fb
fb.prism.order=sw
fb.com.sun.javafx.isEmbedded=true
fb.glass.restrictWindowToScreen=true
fb.com.sun.javafx.scene.control.skin.FXVK.cache=true
eglx11.glass.platform=Lens
eglx11.glass.lens=eglx11
eglx11.prism.order=es2
eglx11.prism.eglx11=true
eglx11.prism.device=true
eglx11.prism.lcdtext=false
eglx11.use.egl=true
eglx11.use.gles2=true
eglx11.embedded=eglx11
eglx11.com.sun.javafx.isEmbedded=true
eglx11.com.sun.javafx.scene.control.skin.FXVK.cache=true
gtk.glass.platform=gtk
gtk.prism.order=sw
gtk.com.sun.javafx.isEmbedded=true
gtk.com.sun.javafx.scene.control.skin.FXVK.cache=true"""

def pangoCCFlags = [extraCFlags, "-D_ENABLE_PANGO"];
def pangoLinkFlags = [extraLFlags];
setupTools("linux_pango_tools",
    { propFile ->
        ByteArrayOutputStream results = new ByteArrayOutputStream();
        exec {
            commandLine "pkg-config", "--cflags", "pangoft2"
            standardOutput = results
        }
        propFile << "cflags=" << results.toString().trim() << "\n";

        results = new ByteArrayOutputStream();
        exec {
            commandLine "pkg-config", "--libs", "pangoft2"
            standardOutput = results
        }
        propFile << "libs=" << results.toString().trim();
    },
    { properties ->
        pangoCCFlags.addAll(properties.getProperty("cflags").split(" "))
        pangoLinkFlags.addAll(properties.getProperty("libs").split(" "))
    }
)


def compiler = file("$compilerHome/bin/arm-none-linux-gnueabi-gcc").getAbsolutePath()
def linker = file("$compilerHome/bin/arm-none-linux-gnueabi-g++").getAbsolutePath()

ARMV6SF.glass = [:]
ARMV6SF.glass.variants = ["eglfb", "directfb", "fb", "eglx11", "gtk"]
ARMV6SF.glass.javahInclude = [
    "com/sun/glass/events/**",
    "com/sun/glass/ui/*",
    "com/sun/glass/ui/lens/*"]
ARMV6SF.glass.lib = "glass"

ARMV6SF.glass.eglfb = [:]
// TODO when building headless, use lens/cursor/nullcursor/
// otherwise we use lens/cursor/fbCursor/ and lens/input/udev

// TODO when USE_RFB is specified use lens/rfb

// TODO use /eglfb/x11ContainerScreen when using eglfb and EGL_X11_FB_CONTAINER
// TODO use /headless/headlessScreen when using headless
ARMV6SF.glass.eglfb.nativeSource = [
    file("modules/graphics/src/main/native-glass/lens"),
    file("modules/graphics/src/main/native-glass/lens/wm"),
    file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
    file("modules/graphics/src/main/native-glass/lens/input/udev"),
    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c")]
ARMV6SF.glass.eglfb.compiler = compiler
ARMV6SF.glass.eglfb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DGRADLE_BUILD"].flatten()
ARMV6SF.glass.eglfb.linker = linker
ARMV6SF.glass.eglfb.linkFlags = [lensLFlags].flatten()
ARMV6SF.glass.eglfb.lib = "glass-lens-eglfb"

ARMV6SF.glass.directfb = [:]
ARMV6SF.glass.directfb.nativeSource = [
    file("modules/graphics/src/main/native-glass/lens"),
    file("modules/graphics/src/main/native-glass/lens/wm"),
    file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
    file("modules/graphics/src/main/native-glass/lens/input/udev"),
    file("modules/graphics/src/main/native-glass/lens/wm/screen/dfbScreen.c")]
ARMV6SF.glass.directfb.compiler = compiler
ARMV6SF.glass.directfb.ccFlags = ["-ffast-math", extraCFlags, "-I$sdk/usr/include/directfb", "-DLINUX", "-DGRADLE_BUILD"].flatten()
ARMV6SF.glass.directfb.linker = linker
ARMV6SF.glass.directfb.linkFlags = [lensLFlags].flatten()
ARMV6SF.glass.directfb.lib = "glass-lens-dfb"

ARMV6SF.glass.fb = [:]
ARMV6SF.glass.fb.nativeSource = [
    file("modules/graphics/src/main/native-glass/lens"),
    file("modules/graphics/src/main/native-glass/lens/wm"),
    file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
    file("modules/graphics/src/main/native-glass/lens/input/udev"),
    file("modules/graphics/src/main/native-glass/lens/wm/screen/fbdevScreen.c")]
ARMV6SF.glass.fb.compiler = compiler
ARMV6SF.glass.fb.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DGRADLE_BUILD"].flatten()
ARMV6SF.glass.fb.linker = linker
ARMV6SF.glass.fb.linkFlags = [lensLFlags].flatten()
ARMV6SF.glass.fb.lib = "glass-lens-fb"
 
ARMV6SF.glass.eglx11 = [:]
ARMV6SF.glass.eglx11.nativeSource = [
    file("modules/graphics/src/main/native-glass/lens"),
    file("modules/graphics/src/main/native-glass/lens/wm"),
    file("modules/graphics/src/main/native-glass/lens/cursor/fbCursor"),
    file("modules/graphics/src/main/native-glass/lens/input/udev"),
    file("modules/graphics/src/main/native-glass/lens/wm/screen/x11ContainerScreen.c")]
ARMV6SF.glass.eglx11.compiler = compiler
ARMV6SF.glass.eglx11.ccFlags = ["-ffast-math", extraCFlags].flatten()
ARMV6SF.glass.eglx11.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DGRADLE_BUILD"].flatten()
ARMV6SF.glass.eglx11.linker = linker
ARMV6SF.glass.eglx11.linkFlags = [lensLFlags].flatten()
ARMV6SF.glass.eglx11.lib = "glass-lens-eglx11"
 
ARMV6SF.glass.gtk = [:]
ARMV6SF.glass.gtk.nativeSource = [
    file("modules/graphics/src/main/native-glass/lens"),
    file("modules/graphics/src/main/native-glass/lens/wm")]
ARMV6SF.glass.gtk.compiler = compiler
ARMV6SF.glass.gtk.ccFlags = ["-ffast-math", extraCFlags, "-DLINUX", "-DGRADLE_BUILD"].flatten()
ARMV6SF.glass.gtk.linker = linker
ARMV6SF.glass.gtk.linkFlags = [lensLFlags, "-lstdc++"].flatten()
ARMV6SF.glass.gtk.lib = "glass"

ARMV6SF.decora = [:]
ARMV6SF.decora.compiler = compiler
ARMV6SF.decora.ccFlags = extraCFlags
ARMV6SF.decora.linker = linker
ARMV6SF.decora.linkFlags = extraLFlags
ARMV6SF.decora.lib = "decora-sse"

ARMV6SF.prism = [:]
ARMV6SF.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
ARMV6SF.prism.nativeSource = file("modules/graphics/src/main/native-prism")
ARMV6SF.prism.compiler = compiler
ARMV6SF.prism.ccFlags = es2CFlags // or es2EglfbCFlags? or es2X11CFlags?
ARMV6SF.prism.linker = linker
ARMV6SF.prism.linkFlags = es2LFlags // or es2EglfbLFlags or es2X11LFlags?
ARMV6SF.prism.lib = "prism-common"

ARMV6SF.prismSW = [:]
ARMV6SF.prismSW.javahInclude = ["com/sun/pisces/**/*"]
ARMV6SF.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw")
ARMV6SF.prismSW.compiler = compiler
ARMV6SF.prismSW.ccFlags = prismSWCFlags
ARMV6SF.prismSW.linker = linker
ARMV6SF.prismSW.linkFlags = prismSWLFlags
ARMV6SF.prismSW.lib = "prism-sw"

ARMV6SF.iio = [:]
ARMV6SF.iio.javahInclude = ["com/sun/javafx/iio/**/*"]
ARMV6SF.iio.nativeSource = [
    file("modules/graphics/src/main/native-iio"),
    file("modules/graphics/src/main/native-iio/libjpeg7")]
ARMV6SF.iio.compiler = compiler
ARMV6SF.iio.ccFlags = iioCFlags
ARMV6SF.iio.linker = linker
ARMV6SF.iio.linkFlags = iioLFlags
ARMV6SF.iio.lib = "javafx-iio"

ARMV6SF.prismES2 = [:]
ARMV6SF.prismES2.variants = ["eglfb", "eglx11"]
ARMV6SF.prismES2.javahInclude = ["com/sun/prism/es2/**/*"]

ARMV6SF.prismES2.eglfb = [:]
ARMV6SF.prismES2.eglfb.nativeSource = [
    file("modules/graphics/src/main/native-prism-es2"),
    file("modules/graphics/src/main/native-prism-es2/GL"),
    file("modules/graphics/src/main/native-prism-es2/eglfb")
]
ARMV6SF.prismES2.eglfb.compiler = compiler
ARMV6SF.prismES2.eglfb.ccFlags = es2EglfbCFlags
ARMV6SF.prismES2.eglfb.linker = linker
ARMV6SF.prismES2.eglfb.linkFlags = es2EglfbLFlags
ARMV6SF.prismES2.eglfb.lib = "prism-es2-eglfb"

ARMV6SF.prismES2.eglx11 = [:]
ARMV6SF.prismES2.eglx11.nativeSource = [
    file("modules/graphics/src/main/native-prism-es2"),
    file("modules/graphics/src/main/native-prism-es2/GL"),
    file("modules/graphics/src/main/native-prism-es2/eglx11")
]
ARMV6SF.prismES2.eglx11.compiler = compiler
ARMV6SF.prismES2.eglx11.ccFlags = es2X11CFlags
ARMV6SF.prismES2.eglx11.linker = linker
ARMV6SF.prismES2.eglx11.linkFlags = es2X11LFlags
ARMV6SF.prismES2.eglx11.lib = "prism-es2-eglx11"

def closedDir = file("$projectDir/../rt-closed")
ARMV6SF.font = [:]
ARMV6SF.font.javahInclude = [
    "com/sun/javafx/font/**/*",
    "com/sun/javafx/text/**/*"]
ARMV6SF.font.nativeSource = [file("modules/graphics/src/main/native-font")]
ARMV6SF.font.compiler = compiler
ARMV6SF.font.ccFlags = fontCFlags
ARMV6SF.font.linker = linker
ARMV6SF.font.linkFlags = fontLFlags
ARMV6SF.font.lib = "javafx-font"

ARMV6SF.fontT2K = [:]
ARMV6SF.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"]
ARMV6SF.fontT2K.nativeSource = [
        file("$closedDir/javafx-font-t2k-native/src"),
        file("$closedDir/javafx-font-t2k-native/src/layout"),
        file("$closedDir/javafx-font-t2k-native/src/layoutfx")]
ARMV6SF.fontT2K.compiler = compiler
ARMV6SF.fontT2K.ccFlags = fontCFlags
ARMV6SF.fontT2K.linker = linker
ARMV6SF.fontT2K.linkFlags = fontLFlags
ARMV6SF.fontT2K.lib = "javafx-font-t2k"

ARMV6SF.fontPango = [:]
ARMV6SF.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
ARMV6SF.fontPango.nativeSource = [
    "src/main/native-font/pango.c",
    "src/main/native-font/freetype.c"]
ARMV6SF.fontPango.compiler = compiler
ARMV6SF.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
ARMV6SF.fontPango.linker = linker
ARMV6SF.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten()
ARMV6SF.fontPango.lib = "javafx-font-pango"