view buildSrc/ios.gradle @ 8968:eb272f8584c8

Automated merge with http://hg.openjdk.java.net/openjfx/8u40/rt
author kcr
date Fri, 06 Feb 2015 11:18:35 -0800
parents d3f5ba2e8117
children 0efae19e83e7
line wrap: on
line source
/*
 * Copyright (c) 2013, 2014, 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.IOS = [:]

if (BUILD_CLOSED) {
    fetchExternalTools('IOS', 
      ["ios-libs-08.tgz"], 
      rootProject.CROSS_TOOLS_DIR, rootProject.IS_IMPORT_CROSS_TOOLS)
}

// TODO Check for presence of iOS tools
IOS.canBuild = IS_MAC
if (!IOS.canBuild) return;

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

defineProperty("USE_LIPO", "false")
IOS.useLipo = Boolean.parseBoolean(USE_LIPO)

defineProperty("GENERATE_SYMBOLS", "false")
IOS.generateSymbols = Boolean.parseBoolean(GENERATE_SYMBOLS)

defineProperty("BUILD_IOS_TOOLS", "true")
ext.IS_BUILD_IOS_TOOLS = Boolean.parseBoolean(BUILD_IOS_TOOLS)

IOS.generateSymbolsExcludes = [
    "libprism_sw.a",
    "libdecora_sse_armv7.a"
]

defineProperty("IOS_VERSION", "7.0")

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

IOS.libDest = "lib"

IOS.jfxrtJarExcludes = [
    "**/*.hlsl",
    "com/sun/glass/ui/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/prism/es2/gl/mac",
    "com/sun/glass/ui/android",
    "com/sun/glass/ui/gtk",
    
    "com/sun/glass/ui/lens",
    "com/sun/prism/es2/gl/eglfb",
    "com/sun/prism/es2/gl/eglx11",
    "com/sun/prism/es2/gl/x11",
    
    "com/sun/glass/ui/swt", // SWT glass
    
    "javafx/embed/swing", // Swing Interop
    
    "javafx/embed/swt", // SWT Interop
]

def archArm = "armv7"
def archX86 = "i386"
def iPhoneOS = "iPhoneOS"
def iPhoneSim = "iPhoneSimulator"

String sdkPath(String platform) {
    return "/Applications/Xcode.app/Contents/Developer/Platforms/${platform}.platform/Developer/SDKs/${platform}${IOS_VERSION}.sdk";
}

def linkFlags = [
    "-static",
    "-framework", "Foundation",
    "-framework", "CoreGraphics",
    "-framework", "CoreText",
    "-framework", "UIKit",
    "-framework", "QuartzCore",
    "-framework", "OpenGLES"].flatten()

def ccFlags = [
    "-miphoneos-version-min=6.0", "-fmessage-length=0", "-std=c99", "-fno-common",
    "-Wall", "-fno-strict-aliasing", "-fwrapv", "-fpascal-strings", "-fobjc-abi-version=2", "-fobjc-legacy-dispatch",
    "-I$JDK_HOME/include", "-I$JDK_HOME/include/darwin", "-c",
    IS_DEBUG_NATIVE ? ["-O0", "-DDEBUG", "-g"] : ["-O3", "-DNDEBUG"]].flatten()

def compiler = "clang"
def linker = "libtool"

IOS.javafxPlatformProperties ="""javafx.platform=ios
ios.jfxmedia.platforms=IOSPlatform
ios.glass.platform=ios
ios.prism.allowhidpi=false
ios.prism.mintexturesize=16
ios.prism.verbose=true
ios.prism.static.libraries=true
ios.prism.useNativeIIO=false"""

IOS.glass = [:]
IOS.glass.variants = ["arm", "x86"];
IOS.glass.javahInclude = [
    "com/sun/glass/events/**",
    "com/sun/glass/ui/*",
    "com/sun/glass/ui/ios/*"]
IOS.glass.lib = "glass"

IOS.glass.arm = [:]
IOS.glass.arm.nativeSource = file("modules/graphics/src/main/native-glass/ios")
IOS.glass.arm.compiler = compiler
IOS.glass.arm.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.glass.arm.linker = linker
IOS.glass.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags, "-L${sdkPath(iPhoneOS)}/usr/lib"].flatten()
IOS.glass.arm.lib = "glass_${archArm}"

IOS.glass.x86 = [:]
IOS.glass.x86.nativeSource = file("modules/graphics/src/main/native-glass/ios")
IOS.glass.x86.compiler = compiler
IOS.glass.x86.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.glass.x86.linker = linker
IOS.glass.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags, "-L${sdkPath(iPhoneSim)}/usr/lib"].flatten()
IOS.glass.x86.lib = "glass_${archX86}"

IOS.extensions = [:]
IOS.extensions.variants = ["arm", "x86"];
IOS.extensions.javahSource = files("modules/extensions/build/classes/ios")
IOS.extensions.javahClasspath = files("modules/extensions/build/classes/ios/")
IOS.extensions.javahInclude = ["com/sun/javafx/ext/device/ios/**/*"]
IOS.extensions.lib = "extensions_ios"

IOS.extensions.arm = [:]
IOS.extensions.arm.nativeSource = file("modules/extensions/src/ios/native-device/ios")
IOS.extensions.arm.compiler = compiler
IOS.extensions.arm.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.extensions.arm.linker = linker
IOS.extensions.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags, "-L${sdkPath(iPhoneOS)}/usr/lib"].flatten()
IOS.extensions.arm.lib = "extensions_ios_${archArm}"

IOS.extensions.x86 = [:]
IOS.extensions.x86.nativeSource = file("modules/extensions/src/ios/native-device/ios")
IOS.extensions.x86.compiler = compiler
IOS.extensions.x86.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.extensions.x86.linker = linker
IOS.extensions.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags, "-L${sdkPath(iPhoneSim)}/usr/lib"].flatten()
IOS.extensions.x86.lib = "extensions_ios_${archX86}"

IOS.decora = [:]
IOS.decora.compiler = compiler
IOS.decora.ccFlags = [ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS), "-ffast-math"].flatten()
IOS.decora.linker = linker
IOS.decora.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.decora.lib = "decora_sse_${archArm}"

IOS.prism = [:]
IOS.prism.lib = "prism_common"
IOS.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
IOS.prism.variants = ["arm", "x86"];

IOS.prism.arm = [:]
IOS.prism.arm.nativeSource = file("modules/graphics/src/main/native-prism")
IOS.prism.arm.compiler = compiler
IOS.prism.arm.ccFlags = [ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS), "-DINLINE=inline"].flatten()
IOS.prism.arm.linker = linker
IOS.prism.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.prism.arm.lib = "prism_common_${archArm}"

IOS.prism.x86 = [:]
IOS.prism.x86.nativeSource = file("modules/graphics/src/main/native-prism")
IOS.prism.x86.compiler = compiler
IOS.prism.x86.ccFlags = [ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim), "-DINLINE=inline"].flatten()
IOS.prism.x86.linker = linker
IOS.prism.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.prism.x86.lib = "prism_common_${archX86}"

IOS.prismSW = [:]
IOS.prismSW.lib = "prism_sw"
IOS.prismSW.javahInclude = ["com/sun/pisces/**/*"]
IOS.prismSW.variants = ["arm", "x86"];

IOS.prismSW.arm = [:]
IOS.prismSW.arm.nativeSource = file("modules/graphics/src/main/native-prism-sw")
IOS.prismSW.arm.compiler = compiler
IOS.prismSW.arm.ccFlags = [IOS.prism.arm.ccFlags].flatten()
IOS.prismSW.arm.linker = linker
IOS.prismSW.arm.linkFlags = [IOS.prism.arm.linkFlags].flatten()
IOS.prismSW.arm.lib = "prism_sw_${archArm}"

IOS.prismSW.x86 = [:]
IOS.prismSW.x86.nativeSource = file("modules/graphics/src/main/native-prism-sw")
IOS.prismSW.x86.compiler = compiler
IOS.prismSW.x86.ccFlags = [IOS.prism.x86.ccFlags].flatten()
IOS.prismSW.x86.linker = linker
IOS.prismSW.x86.linkFlags = [IOS.prism.x86.linkFlags].flatten()
IOS.prismSW.x86.lib = "prism_sw_${archX86}"

IOS.iio = [:]
IOS.iio.lib = "javafx_iio"
IOS.iio.javahInclude = ["com/sun/javafx/iio/**/*"]
IOS.iio.variants = ["arm", "x86"];

IOS.iio.arm = [:]
IOS.iio.arm.nativeSource = [
    file("modules/graphics/src/main/native-iio"),
    file("modules/graphics/src/main/native-iio/ios"),
    file("modules/graphics/src/main/native-iio/libjpeg7")]
IOS.iio.arm.compiler = compiler
IOS.iio.arm.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS), "-ffast-math"].flatten()
IOS.iio.arm.linker = linker
IOS.iio.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.iio.arm.lib = "javafx_iio_${archArm}"

IOS.iio.x86 = [:]
IOS.iio.x86.nativeSource = [IOS.iio.arm.nativeSource].flatten()
IOS.iio.x86.compiler = compiler
IOS.iio.x86.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim), "-ffast-math"].flatten()
IOS.iio.x86.linker = linker
IOS.iio.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.iio.x86.lib = "javafx_iio_${archX86}"

IOS.prismES2 = [:]
IOS.prismES2.lib = "prism_es2"
IOS.prismES2.javahInclude = ["com/sun/prism/es2/**/*"]
IOS.prismES2.variants = ["arm", "x86"];

IOS.prismES2.arm = [:]
IOS.prismES2.arm.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/ios")
]
IOS.prismES2.arm.compiler = compiler
IOS.prismES2.arm.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.prismES2.arm.linker = linker
IOS.prismES2.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.prismES2.arm.lib = "prism_es2_${archArm}"

IOS.prismES2.x86 = [:]
IOS.prismES2.x86.nativeSource = [IOS.prismES2.arm.nativeSource].flatten()
IOS.prismES2.x86.compiler = compiler
IOS.prismES2.x86.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.prismES2.x86.linker = linker
IOS.prismES2.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.prismES2.x86.lib = "prism_es2_${archX86}"

def closedDir = file("$projectDir/../rt-closed")
IOS.font = [:]
IOS.font.lib = "javafx_font"
IOS.font.javahInclude = [
        "com/sun/javafx/font/**/*",
        "com/sun/javafx/text/**/*"]
IOS.font.variants = ["arm", "x86"];

IOS.font.arm = [:]
IOS.font.arm.nativeSource = [file("modules/graphics/src/main/native-font")]
IOS.font.arm.compiler = compiler
IOS.font.arm.ccFlags = ["-DJFXFONT_PLUS", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.font.arm.linker = linker
IOS.font.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.font.arm.lib = "javafx_font_${archArm}"

IOS.font.x86 = [:]
IOS.font.x86.nativeSource = [IOS.font.arm.nativeSource].flatten()
IOS.font.x86.compiler = compiler
IOS.font.x86.ccFlags = ["-DJFXFONT_PLUS", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.font.x86.linker = linker
IOS.font.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.font.x86.lib = "javafx_font_${archX86}"

IOS.fontT2K = [:]
IOS.fontT2K.lib = "javafx_font_t2k"
IOS.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"]
IOS.fontT2K.variants = ["arm", "x86"];

IOS.fontT2K.arm = [:]
IOS.fontT2K.arm.nativeSource = [
        file("$closedDir/javafx-font-t2k-native/src"),
        file("$closedDir/javafx-font-t2k-native/src/layout")]
IOS.fontT2K.arm.compiler = compiler
IOS.fontT2K.arm.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.fontT2K.arm.linker = linker
IOS.fontT2K.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.fontT2K.arm.lib = "javafx_font_t2k_${archArm}"

IOS.fontT2K.x86 = [:]
IOS.fontT2K.x86.nativeSource = [IOS.fontT2K.arm.nativeSource].flatten()
IOS.fontT2K.x86.compiler = compiler
IOS.fontT2K.x86.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.fontT2K.x86.linker = linker
IOS.fontT2K.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.fontT2K.x86.lib = "javafx_font_t2k_${archX86}"

IOS.webview = [:]
IOS.webview.lib = "javafx_ios_webnode"
IOS.webview.javahInclude = ["javafx/scene/web/*"]
IOS.webview.variants = ["arm", "x86"];

IOS.webview.arm = [:]
IOS.webview.arm.nativeSource = file("modules/web/src/ios/native")
IOS.webview.arm.compiler = compiler
IOS.webview.arm.ccFlags = [ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.webview.arm.linker = linker
IOS.webview.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.webview.arm.lib = "javafx_ios_webnode_${archArm}"

IOS.webview.x86 = [:]
IOS.webview.x86.nativeSource = [IOS.webview.arm.nativeSource].flatten()
IOS.webview.x86.compiler = compiler
IOS.webview.x86.ccFlags = [ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.webview.x86.linker = linker
IOS.webview.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.webview.x86.lib = "javafx_ios_webnode_${archX86}"

project(":web") {
    apply plugin: 'java'

    compileJava {
        enabled = false
    }

    afterEvaluate {
        def compileWebJavaIos = task("compileWebJavaIos",
            type: JavaCompile, group: "Build") {

            dependsOn(project(":graphics").classes, project(":base").classes)
            description = "Task compiles web component for iOS."
            classpath = files(
                project(":controls").sourceSets.main.output.classesDir,
                project(":graphics").sourceSets.main.output.classesDir,
                project(":base").sourceSets.main.output.classesDir
            )
            destinationDir = file("modules/web/build/classes/ios")
            sourceSets.main.output.classesDir = destinationDir
            dependencyCacheDir = file("modules/web/build/dependency-cache")
            source file("modules/web/src/ios/java")
            doLast {
                copy {
                    from "modules/web/src/ios/resources"
                    into "modules/web/build/resources/ios"
                }
            }
        }

        def jarWebJavaIos = task("jarWebJavaIos",
            type: Jar, group: "Build") {
            description = "Creates web.jar for iOS."
            dependsOn(compileWebJavaIos)
            archiveName = "web.jar"
            includeEmptyDirs = false
            destinationDir = project.file("build/libs/ios")
            from("build/classes/ios")
        }

        addNative(project, "webview")
        javahIosWebview.dependsOn(compileWebJavaIos)
        javahIosWebview.classpath += files(project(":base").sourceSets.main.output.classesDir,
                             project(":graphics").sourceSets.main.output.classesDir,
                             project(":controls").sourceSets.main.output.classesDir)

        jfxrtIos {
            from ("modules/web/build/classes/ios", "modules/web/build/resources/main");
            exclude("com/sun/webkit", "com/sun/javafx/webkit");
        }

        sdkIos  {
            dependsOn(jarWebJavaIos)
            doLast {
                def props = project.ext["IOS"]
                copy {
                    if (props.useLipo) {
                        from ("modules/web/build/libs/webview/ios/${props.library(props.webview.lib)}")
                    } else {
                        from ("modules/web/build/libs/webview/ios")
                    }
                    into ("build/ios-sdk/rt/${props.libDest}")
                }
            }
        }
    }
}

IOS.media = [:]
IOS.media.lib = "jfxmedia"
IOS.media.javahSource = files("modules/media/build/classes/main")
IOS.media.javahClasspath = files("modules/media/build/classes/main")
IOS.media.javahInclude = ["com/sun/media/jfxmediaimpl/*"]
IOS.media.variants = ["arm", "x86"];

IOS.media.arm = [:]
IOS.media.arm.nativeSource = [
    file("modules/media/src/main/native/jfxmedia/platform/ios"),
    file("modules/media/src/main/native/jfxmedia/platform/ios/jni")
]
IOS.media.arm.compiler = compiler
IOS.media.arm.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archArm, "-isysroot", sdkPath(iPhoneOS)].flatten()
IOS.media.arm.linker = linker
IOS.media.arm.linkFlags = ["-arch_only", archArm, "-syslibroot", sdkPath(iPhoneOS), linkFlags].flatten()
IOS.media.arm.lib = "jfxmedia_${archArm}"

IOS.media.x86 = [:]
IOS.media.x86.nativeSource = [IOS.media.arm.nativeSource].flatten()
IOS.media.x86.compiler = compiler
IOS.media.x86.ccFlags = ["-x", "objective-c", ccFlags, "-arch", archX86, "-isysroot", sdkPath(iPhoneSim)].flatten()
IOS.media.x86.linker = linker
IOS.media.x86.linkFlags = ["-arch_only", archX86, "-syslibroot", sdkPath(iPhoneSim), linkFlags].flatten()
IOS.media.x86.lib = "jfxmedia_${archX86}"

project(":media") {
    afterEvaluate {
        addNative(project, "media")

        sdkIos  {
            doLast {
                def props = project.ext["IOS"]
                copy {
                    if (props.useLipo) {
                        from ("modules/media/build/libs/media/ios/${props.library(props.media.lib)}")
                    } else {
                        from ("modules/media/build/libs/media/ios")
                    }
                    into ("build/ios-sdk/rt/${props.libDest}")
                }
            }
        }
    }
}

project(":extensions") {
    apply plugin: 'java'

    compileJava {
        destinationDir = file("build/classes/ios")
        source file("src/ios/java")
    }
    
    jar {
        from("build/classes/ios")
    }
    
    afterEvaluate {

        addNative(project, "extensions")
        javahIosExtensions.classpath += files(project(":base").sourceSets.main.output.classesDir,
                             project(":graphics").sourceSets.main.output.classesDir)

        sdkIos  {
            doLast {
                def props = project.ext["IOS"]
                copy {
                    if (props.useLipo) {
                        from ("modules/extensions/build/libs/extensions/ios/${props.library(props.extensions.lib)}")
                    } else {
                        from ("modules/extensions/build/libs/extensions/ios")
                    }
                    into ("build/ios-sdk/rt/${props.libDest}")
                }
            }
        }
    }
}