/* * Copyright (c) 2013, 2018, 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.MAC = [:] MAC.canBuild = IS_MAC && IS_64 if (!MAC.canBuild) return; // All desktop related packages should be built MAC.compileSwing = true; MAC.compileSWT = true; MAC.includeNull3d = true // Lambda for naming the generated libs MAC.library = { name -> return "lib${name}.dylib" as String } MAC.libDest = "lib" /* * Define settings for Mac compilation. If we don't find the preferred SDK * in the default location then we will use "xcodebuild" to locate a suitable SDK. * In extreme cases you can provide your own properties in your home dir to * override these settings or pass them on the command line. */ def prefSdkVersion = "10.11" def defaultSdkPath = "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX${prefSdkVersion}.sdk"; // Set the minimum API version that we require (developers do not need to override this) // Note that this is not necessarily the same as the preferred SDK version defineProperty("MACOSX_MIN_VERSION", "10.10"); // Create $buildDir/mac_tools.properties file and load props from it setupTools("mac_tools", { propFile -> propFile << "" if (!file(defaultSdkPath).isDirectory()) { // Get list of all macosx sdks ByteArrayOutputStream results = new ByteArrayOutputStream(); exec { commandLine("xcodebuild", "-version", "-showsdks"); setStandardOutput(results); } BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim())); // If our preferred SDK is in the list use it, else use the default String sdk = "macosx" String prefSdk = sdk + prefSdkVersion while (true) { def line = reader.readLine(); if (line == null) break; if (line.contains("-sdk ${prefSdk}")) { sdk = prefSdk break; } } results = new ByteArrayOutputStream(); exec { commandLine("xcodebuild", "-version", "-sdk", sdk, "Path"); setStandardOutput(results); } String sdkPath = results.toString().trim(); propFile << "MACOSX_SDK_PATH=" << sdkPath << "\n"; } }, { properties -> defineProperty("MACOSX_SDK_PATH", properties, defaultSdkPath) } ) println "MACOSX_MIN_VERSION = $MACOSX_MIN_VERSION" println "MACOSX_SDK_PATH = $MACOSX_SDK_PATH" if (!file(MACOSX_SDK_PATH).isDirectory()) { throw new GradleException("FAIL: Cannot find $MACOSX_SDK_PATH") } // NOTE: There is no space between -iframework and the specified path def commonParams = [ "-mmacosx-version-min=$MACOSX_MIN_VERSION", "-isysroot", "$MACOSX_SDK_PATH", "-iframework$MACOSX_SDK_PATH/System/Library/Frameworks", "-arch", "x86_64"] def ccBaseFlags = [ commonParams, "-I$JDK_HOME/include", "-I$JDK_HOME/include/darwin"].flatten() def ccFlags = [ ccBaseFlags, "-std=c99", "-c", IS_DEBUG_NATIVE ? "-DDEBUG" : ["-O3", "-DNDEBUG"]].flatten() def linkFlags = [ commonParams, "-framework", "AppKit", "-framework", "ApplicationServices", "-framework", "OpenGL", "-framework", "QuartzCore", "-framework", "Security", "-dynamiclib", "-lobjc"].flatten(); def compiler = IS_COMPILE_PARFAIT ? "parfait-clang" : "clang"; def linker = IS_COMPILE_PARFAIT ? "parfait-clang++" : "clang++"; MAC.glass = [:] MAC.glass.javahInclude = [ "com/sun/glass/events/**", "com/sun/glass/ui/*", "com/sun/glass/ui/mac/*"] MAC.glass.nativeSource = file("${project("graphics").projectDir}/src/main/native-glass/mac") MAC.glass.compiler = compiler MAC.glass.ccFlags = [ccFlags].flatten() MAC.glass.linker = linker MAC.glass.linkFlags = [linkFlags].flatten() MAC.glass.lib = "glass" MAC.decora = [:] MAC.decora.compiler = compiler MAC.decora.ccFlags = ["-O1", "-ffast-math", "-c", ccBaseFlags].flatten() MAC.decora.linker = linker MAC.decora.linkFlags = ["-dynamiclib", commonParams].flatten() MAC.decora.lib = "decora_sse" MAC.prism = [:] MAC.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] MAC.prism.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism") MAC.prism.compiler = compiler MAC.prism.ccFlags = ["-O3", "-DINLINE=inline", "-c", ccBaseFlags].flatten() MAC.prism.linker = linker MAC.prism.linkFlags = ["-dynamiclib", commonParams].flatten() MAC.prism.lib = "prism_common" MAC.prismSW = [:] MAC.prismSW.javahInclude = ["com/sun/pisces/**/*"] MAC.prismSW.nativeSource = file("${project("graphics").projectDir}/src/main/native-prism-sw") MAC.prismSW.compiler = compiler MAC.prismSW.ccFlags = [MAC.prism.ccFlags].flatten() MAC.prismSW.linker = linker MAC.prismSW.linkFlags = [MAC.prism.linkFlags].flatten() MAC.prismSW.lib = "prism_sw" MAC.iio = [:] MAC.iio.javahInclude = ["com/sun/javafx/iio/**/*"] MAC.iio.nativeSource = [ file("${project("graphics").projectDir}/src/main/native-iio"), file("${project("graphics").projectDir}/src/main/native-iio/libjpeg9c")] MAC.iio.compiler = compiler MAC.iio.ccFlags = [ccFlags].flatten() MAC.iio.linker = linker MAC.iio.linkFlags = [linkFlags].flatten() MAC.iio.lib = "javafx_iio" MAC.prismES2 = [:] MAC.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] MAC.prismES2.nativeSource = [ file("${project("graphics").projectDir}/src/main/native-prism-es2"), file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), file("${project("graphics").projectDir}/src/main/native-prism-es2/macosx") ] MAC.prismES2.compiler = compiler MAC.prismES2.ccFlags = ["-DMACOSX", ccFlags].flatten() MAC.prismES2.linker = linker MAC.prismES2.linkFlags = [linkFlags].flatten() MAC.prismES2.lib = "prism_es2" def closedDir = file("$projectDir/../rt-closed") MAC.font = [:] MAC.font.javahInclude = [ "com/sun/javafx/font/**/*", "com/sun/javafx/text/**/*"] MAC.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] MAC.font.compiler = compiler MAC.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() MAC.font.linker = linker MAC.font.linkFlags = [linkFlags].flatten() MAC.font.lib = "javafx_font" MAC.media = [:] MAC.media.compiler = "${compiler} ${ccBaseFlags.join(" ")}" //MAC.media.ccFlags = ccBaseFlags MAC.media.linker = "${linker} ${commonParams.join(" ")}" //MAC.media.linkFlags = commonParams MAC.media.ar = "libtool"