changeset 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 f853a40fed0e
children 7c166672202d
files build.gradle buildSrc/armv6hf.gradle buildSrc/armv6sf.gradle buildSrc/linux.gradle
diffstat 4 files changed, 134 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/build.gradle	Wed Jul 10 22:24:38 2013 +0300
+++ b/build.gradle	Wed Jul 10 13:32:02 2013 -0700
@@ -279,6 +279,11 @@
 if (COMPILE_WEBKIT instanceof String) ext.COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT)
 if (COMPILE_GSTREAMER instanceof String) ext.COMPILE_GSTREAMER = Boolean.parseBoolean(COMPILE_GSTREAMER)
 
+// COMPILE_PANGO specifies whether to build javafx-font-pango.
+defineProperty("COMPILE_PANGO", "false")
+if (COMPILE_PANGO instanceof String) ext.COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO)
+
+
 // Define the SWT.jar that we are going to have to download during the build process based
 // on what platform we are compiling from (not based on our target).
 ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.7.2.v3740f" :
@@ -617,18 +622,18 @@
  * @param name The name of the project, such as "prism-common". This name is used
  *        in the name of the generated task, such as ccPrismCommon, and also
  *        in the name of the final library, such as libprism-common.dylib.
- * @param libName The name of the shared library we will create. Should be
- *        something like "prism-common", which we will turn into libprism-common.dylib
- *        or whatnot depending on the platform.
+ * @param optional If the task is optional or not
  */
-void addNative(Project project, String name) {
+void addNative(Project project, String name, boolean optional = false) {
     // TODO if we want to handle 32/64 bit windows in the same build,
     // Then we will need to modify the win compile target to be win32 or win64
     def capitalName = name.split("-").collect{it.capitalize()}.join()
     def nativeTask = project.task("native$capitalName", group: "Build") {
         description = "Generates JNI headers, compiles, and builds native dynamic library for $name for all compile targets"
     }
-    project.assemble.dependsOn(nativeTask)
+    if (!optional) {
+        project.assemble.dependsOn(nativeTask)
+    }
     // Each of the different compile targets will be placed in a sub directory
     // of these root dirs, with the name of the dir being the name of the target
     def headerRootDir = project.file("$project.buildDir/generated-src/headers/$name")
@@ -955,6 +960,11 @@
     addNative(project, "iio")
     addNative(project, "prismES2")
 
+    // Currently lets not build pango by default
+    if (IS_LINUX) {
+        addNative(project, "fontPango", !COMPILE_PANGO)
+    }
+
     if (IS_WINDOWS) {
         addNative(project, "prismD3D")
         // TODO need to hook this up to be executed only if PassThroughVS.h is missing or PassThroughVS.hlsl is changed
@@ -1753,7 +1763,11 @@
             copy {
                 def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false
                 from("modules/graphics/build/libs/jsl-decora/${t.name}/${library(targetProperties.decora.lib)}")
-                ['font', 'prism', 'prismSW', 'prismES2', 'glass', 'iio'].each { lib ->
+                def libs = ['font', 'prism', 'prismSW', 'prismES2', 'glass', 'iio']
+                if (COMPILE_PANGO) {
+                    libs += 'fontPango';
+                }
+                libs.each { lib ->
                     def variants = targetProperties[lib].containsKey('variants') && !useLipo ? targetProperties[lib].variants : [null]
                     variants.each { variant ->
                         def variantProperties = variant ? targetProperties[lib][variant] : targetProperties[lib]
--- a/buildSrc/armv6hf.gradle	Wed Jul 10 22:24:38 2013 +0300
+++ b/buildSrc/armv6hf.gradle	Wed Jul 10 13:32:02 2013 -0700
@@ -214,6 +214,31 @@
 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-linux-gnueabihf-gcc").getAbsolutePath()
 def linker = file("$compilerHome/bin/arm-linux-gnueabihf-g++").getAbsolutePath()
 
@@ -365,8 +390,8 @@
 def closedDir = file("$projectDir/../rt-closed")
 ARMV6HF.font = [:]
 ARMV6HF.font.javahInclude = [
-        "com/sun/javafx/font/**/*",
-        "com/sun/javafx/text/**/*"]
+    "com/sun/javafx/font/**/*",
+    "com/sun/javafx/text/**/*"]
 ARMV6HF.font.nativeSource = [file("modules/graphics/src/main/native-font")]
 ARMV6HF.font.compiler = compiler
 ARMV6HF.font.ccFlags = fontCFlags
@@ -385,3 +410,14 @@
 ARMV6HF.fontT2K.linker = linker
 ARMV6HF.fontT2K.linkFlags = fontLFlags
 ARMV6HF.fontT2K.lib = "javafx-font-t2k"
+
+ARMV6HF.fontPango = [:]
+ARMV6HF.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
+ARMV6HF.fontPango.nativeSource = [
+    "src/main/native-font/pango.c",
+    "src/main/native-font/freetype.c"]
+ARMV6HF.fontPango.compiler = compiler
+ARMV6HF.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
+ARMV6HF.fontPango.linker = linker
+ARMV6HF.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten()
+ARMV6HF.fontPango.lib = "javafx-font-pango"
--- a/buildSrc/armv6sf.gradle	Wed Jul 10 22:24:38 2013 +0300
+++ b/buildSrc/armv6sf.gradle	Wed Jul 10 13:32:02 2013 -0700
@@ -229,6 +229,31 @@
 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()
 
@@ -377,8 +402,8 @@
 def closedDir = file("$projectDir/../rt-closed")
 ARMV6SF.font = [:]
 ARMV6SF.font.javahInclude = [
-        "com/sun/javafx/font/**/*",
-        "com/sun/javafx/text/**/*"]
+    "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
@@ -397,3 +422,14 @@
 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"
--- a/buildSrc/linux.gradle	Wed Jul 10 22:24:38 2013 +0300
+++ b/buildSrc/linux.gradle	Wed Jul 10 13:32:02 2013 -0700
@@ -104,6 +104,31 @@
     }
 )
 
+def pangoCCFlags = ["-D_ENABLE_PANGO"];
+def pangoLinkFlags = [];
+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 = "gcc"
 def linker = "g++"
 
@@ -178,8 +203,8 @@
 def closedDir = file("$projectDir/../rt-closed")
 LINUX.font = [:]
 LINUX.font.javahInclude = [
-        "com/sun/javafx/font/**/*",
-        "com/sun/javafx/text/**/*"]
+     "com/sun/javafx/font/**/*",
+     "com/sun/javafx/text/**/*"]
 LINUX.font.compiler = compiler
 LINUX.font.nativeSource = [file("modules/graphics/src/main/native-font")]
 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten()
@@ -198,3 +223,14 @@
 LINUX.fontT2K.linker = linker
 LINUX.fontT2K.linkFlags = [linkFlags].flatten()
 LINUX.fontT2K.lib = "javafx-font-t2k"
+
+LINUX.fontPango = [:]
+LINUX.fontPango.javahInclude = ["com/sun/javafx/font/pango/*"]
+LINUX.fontPango.nativeSource = [
+    "src/main/native-font/pango.c",
+    "src/main/native-font/freetype.c"]
+LINUX.fontPango.compiler = compiler
+LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten()
+LINUX.fontPango.linker = linker
+LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten()
+LINUX.fontPango.lib = "javafx-font-pango"