37 // Libraries end up in the lib/$OS_ARCH directory for Linux 38 LINUX.libDest = "lib/$OS_ARCH" 39 LINUX.modulesArch = "$OS_ARCH" 40 41 // Lambda for naming the generated libs 42 LINUX.library = { name -> return "lib${name}.so" as String } 43 44 // A set of common parameters to use for both compiling and linking 45 def commonFlags = [ 46 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags 47 "-Wextra", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags 48 49 if (!IS_64) { 50 commonFlags += "-m32" 51 } 52 53 // Specify the compilation parameters and link parameters 54 def ccFlags = [ 55 commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", 56 IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten() 57 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"]) 58 def linkFlags = ["-shared", commonFlags].flatten() 59 60 if (IS_DEBUG_NATIVE) { 61 linkFlags += "-g" 62 } 63 64 // Create $buildDir/linux_tools.properties file and load props from it 65 setupTools("linux_tools", 66 { propFile -> 67 ByteArrayOutputStream results = new ByteArrayOutputStream(); 68 exec { 69 commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst"); 70 setStandardOutput(results); 71 } 72 propFile << "cflags=" << results.toString().trim() << "\n"; 73 74 results = new ByteArrayOutputStream(); 75 exec { 76 commandLine "pkg-config", "--libs", "pangocairo", "gio-2.0", "gthread-2.0", "xtst" 77 standardOutput = results 78 } 79 propFile << "libs=" << results.toString().trim(); 80 }, 81 { properties -> 82 ccFlags.addAll(properties.getProperty("cflags").split(" ")) 83 linkFlags.addAll(properties.getProperty("libs").split(" ")) 84 } 85 ) 86 87 def pangoCCFlags = ["-D_ENABLE_PANGO"]; 88 def pangoLinkFlags = []; 89 setupTools("linux_pango_tools", 90 { propFile -> 91 ByteArrayOutputStream results = new ByteArrayOutputStream(); 92 exec { 93 commandLine "pkg-config", "--cflags", "pangoft2" 94 standardOutput = results 95 } 96 propFile << "cflags=" << results.toString().trim() << "\n"; 97 98 results = new ByteArrayOutputStream(); 99 exec { 100 commandLine "pkg-config", "--libs", "pangoft2" 101 standardOutput = results 102 } 103 propFile << "libs=" << results.toString().trim(); 120 } 121 propFile << "cflags=" << results.toString().trim() << "\n"; 122 123 results = new ByteArrayOutputStream(); 124 exec { 125 commandLine "pkg-config", "--libs", "freetype2" 126 standardOutput = results 127 } 128 propFile << "libs=" << results.toString().trim(); 129 }, 130 { properties -> 131 freetypeCCFlags.addAll(properties.getProperty("cflags").split(" ")) 132 freetypeLinkFlags.addAll(properties.getProperty("libs").split(" ")) 133 } 134 ) 135 136 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc"; 137 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++"; 138 139 LINUX.glass = [:] 140 LINUX.glass.javahInclude = [ 141 "com/sun/glass/events/**", 142 "com/sun/glass/ui/*", 143 "com/sun/glass/ui/gtk/*"] 144 LINUX.glass.nativeSource = file("${project(":graphics").projectDir}/src/main/native-glass/gtk") 145 LINUX.glass.compiler = compiler 146 LINUX.glass.ccFlags = [ccFlags, "-Werror"].flatten() 147 LINUX.glass.linker = linker 148 LINUX.glass.linkFlags = [linkFlags ].flatten() 149 LINUX.glass.lib = "glass" 150 151 LINUX.decora = [:] 152 LINUX.decora.compiler = compiler 153 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten() 154 LINUX.decora.linker = linker 155 LINUX.decora.linkFlags = [linkFlags].flatten() 156 LINUX.decora.lib = "decora_sse" 157 158 LINUX.prism = [:] 159 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 160 LINUX.prism.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism") 161 LINUX.prism.compiler = compiler 162 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 163 LINUX.prism.linker = linker 164 LINUX.prism.linkFlags = [linkFlags].flatten() 165 LINUX.prism.lib = "prism_common" 166 167 LINUX.prismSW = [:] 168 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"] 169 LINUX.prismSW.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism-sw") 170 LINUX.prismSW.compiler = compiler 171 LINUX.prismSW.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 172 LINUX.prismSW.linker = linker 173 LINUX.prismSW.linkFlags = [linkFlags].flatten() 174 LINUX.prismSW.lib = "prism_sw" 175 176 LINUX.launcher = [:] 177 LINUX.launcher.compiler = compiler 178 LINUX.launcher.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c"] 179 LINUX.launcher.linker = linker 180 LINUX.launcher.linkFlags = ["-ldl"] 181 if (!IS_64) { 182 LINUX.launcher.ccFlags += "-m32" 183 LINUX.launcher.linkFlags += "-m32" 184 } 185 186 LINUX.launcherlibrary = [:] 187 LINUX.launcherlibrary.compiler = compiler 188 LINUX.launcherlibrary.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC"] 189 LINUX.launcherlibrary.linker = linker 190 LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared"] 191 if (!IS_64) { 192 LINUX.launcherlibrary.ccFlags += "-m32" 193 LINUX.launcherlibrary.linkFlags += "-m32" 194 } 195 196 LINUX.iio = [:] 197 LINUX.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 198 LINUX.iio.nativeSource = [ 199 file("${project("graphics").projectDir}/src/main/native-iio"), 200 file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")] 201 LINUX.iio.compiler = compiler 202 LINUX.iio.ccFlags = [ccFlags].flatten() 203 LINUX.iio.linker = linker 204 LINUX.iio.linkFlags = [linkFlags].flatten() 205 LINUX.iio.lib = "javafx_iio" 206 207 LINUX.prismES2 = [:] 208 LINUX.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 209 LINUX.prismES2.nativeSource = [ 210 file("${project("graphics").projectDir}/src/main/native-prism-es2"), 211 file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), 212 file("${project("graphics").projectDir}/src/main/native-prism-es2/x11") 213 ] 214 LINUX.prismES2.compiler = compiler 215 LINUX.prismES2.ccFlags = ["-DLINUX", ccFlags].flatten() 216 LINUX.prismES2.linker = linker 217 LINUX.prismES2.linkFlags = [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten() 218 LINUX.prismES2.lib = "prism_es2" 219 220 def closedDir = file("$projectDir/../rt-closed") 221 LINUX.font = [:] 222 LINUX.font.javahInclude = [ 223 "com/sun/javafx/font/**/*", 224 "com/sun/javafx/text/**/*"] 225 LINUX.font.compiler = compiler 226 LINUX.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] 227 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() 228 LINUX.font.linker = linker 229 LINUX.font.linkFlags = [linkFlags].flatten() 230 LINUX.font.lib = "javafx_font" 231 232 LINUX.fontT2K = [:] 233 LINUX.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 234 LINUX.fontT2K.nativeSource = [ 235 file("$closedDir/javafx-font-t2k-native/src"), 236 file("$closedDir/javafx-font-t2k-native/src/layout")] 237 LINUX.fontT2K.compiler = compiler 238 LINUX.fontT2K.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags].flatten() 239 LINUX.fontT2K.linker = linker 240 LINUX.fontT2K.linkFlags = [linkFlags].flatten() 241 LINUX.fontT2K.lib = "javafx_font_t2k" 242 243 LINUX.fontFreetype = [:] 244 LINUX.fontFreetype.javahInclude = ["com/sun/javafx/font/freetype/OSFreetype.class"] 245 LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 246 LINUX.fontFreetype.compiler = compiler 247 LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten() 248 LINUX.fontFreetype.linker = linker 249 LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten() 250 LINUX.fontFreetype.lib = "javafx_font_freetype" 251 252 LINUX.fontPango = [:] 253 LINUX.fontPango.javahInclude = ["com/sun/javafx/font/freetype/OSPango.class"] 254 LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"] 255 LINUX.fontPango.compiler = compiler 256 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 257 LINUX.fontPango.linker = linker 258 LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 259 LINUX.fontPango.lib = "javafx_font_pango" 260 261 LINUX.media = [:] 262 LINUX.media.compiler = compiler 263 LINUX.media.linker = linker 264 LINUX.media.ar = "ar" | 37 // Libraries end up in the lib/$OS_ARCH directory for Linux 38 LINUX.libDest = "lib/$OS_ARCH" 39 LINUX.modulesArch = "$OS_ARCH" 40 41 // Lambda for naming the generated libs 42 LINUX.library = { name -> return "lib${name}.so" as String } 43 44 // A set of common parameters to use for both compiling and linking 45 def commonFlags = [ 46 "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags 47 "-Wextra", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags 48 49 if (!IS_64) { 50 commonFlags += "-m32" 51 } 52 53 // Specify the compilation parameters and link parameters 54 def ccFlags = [ 55 commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", 56 IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten() 57 def ccFlagsGTK3 = ccFlags 58 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"]) 59 def linkFlags = ["-shared", commonFlags].flatten() 60 61 if (IS_DEBUG_NATIVE) { 62 linkFlags += "-g" 63 } 64 65 def gtk2CCFlags = [ ]; 66 def gtk3CCFlags = [ "-Wno-deprecated-declarations" ]; 67 def gtk2LinkFlags = [ ]; 68 def gtk3LinkFlags = [ ]; 69 70 // Create $buildDir/linux_tools.properties file and load props from it 71 setupTools("linux_gtk", 72 { propFile -> 73 ByteArrayOutputStream results1 = new ByteArrayOutputStream(); 74 exec { 75 commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst") 76 setStandardOutput(results1); 77 } 78 propFile << "cflagsGTK2=" << results1.toString().trim() << "\n"; 79 80 ByteArrayOutputStream results2 = new ByteArrayOutputStream(); 81 exec { 82 commandLine("pkg-config", "--cflags", "gtk+-3.0", "gthread-2.0", "xtst") 83 setStandardOutput(results2); 84 } 85 propFile << "cflagsGTK3=" << results2.toString().trim() << "\n"; 86 87 ByteArrayOutputStream results3 = new ByteArrayOutputStream(); 88 exec { 89 commandLine("pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst") 90 setStandardOutput(results3); 91 } 92 propFile << "libsGTK2=" << results3.toString().trim() << "\n"; 93 94 ByteArrayOutputStream results4 = new ByteArrayOutputStream(); 95 exec { 96 commandLine("pkg-config", "--libs", "gtk+-3.0", "gthread-2.0", "xtst") 97 setStandardOutput(results4); 98 } 99 propFile << "libsGTK3=" << results4.toString().trim() << "\n"; 100 101 }, 102 { properties -> 103 gtk2CCFlags.addAll(properties.getProperty("cflagsGTK2").split(" ")) 104 gtk3CCFlags.addAll(properties.getProperty("cflagsGTK3").split(" ")) 105 gtk2LinkFlags.addAll(properties.getProperty("libsGTK2").split(" ")) 106 gtk3LinkFlags.addAll(properties.getProperty("libsGTK3").split(" ")) 107 } 108 ) 109 110 def pangoCCFlags = ["-D_ENABLE_PANGO"]; 111 def pangoLinkFlags = []; 112 setupTools("linux_pango_tools", 113 { propFile -> 114 ByteArrayOutputStream results = new ByteArrayOutputStream(); 115 exec { 116 commandLine "pkg-config", "--cflags", "pangoft2" 117 standardOutput = results 118 } 119 propFile << "cflags=" << results.toString().trim() << "\n"; 120 121 results = new ByteArrayOutputStream(); 122 exec { 123 commandLine "pkg-config", "--libs", "pangoft2" 124 standardOutput = results 125 } 126 propFile << "libs=" << results.toString().trim(); 143 } 144 propFile << "cflags=" << results.toString().trim() << "\n"; 145 146 results = new ByteArrayOutputStream(); 147 exec { 148 commandLine "pkg-config", "--libs", "freetype2" 149 standardOutput = results 150 } 151 propFile << "libs=" << results.toString().trim(); 152 }, 153 { properties -> 154 freetypeCCFlags.addAll(properties.getProperty("cflags").split(" ")) 155 freetypeLinkFlags.addAll(properties.getProperty("libs").split(" ")) 156 } 157 ) 158 159 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc"; 160 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++"; 161 162 LINUX.glass = [:] 163 LINUX.glass.variants = ["glass", "glassgtk2", "glassgtk3"] 164 //LINUX.glass.variants = ["glass", "glassgtk2"] 165 166 FileTree ft_gtk_launcher = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") { 167 //include("**/glass_general.cpp") 168 include("**/launcher.c") 169 } 170 171 FileTree ft_gtk = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") { 172 //include("**/wrapper*.c") 173 //exclude("**/glass_general.cpp") 174 exclude("**/launcher.c") 175 } 176 177 LINUX.glass.glass = [:] 178 LINUX.glass.glass.nativeSource = ft_gtk_launcher.getFiles() 179 LINUX.glass.glass.compiler = compiler 180 LINUX.glass.glass.ccFlags = [ccFlags, gtk2CCFlags, "-Werror"].flatten() 181 LINUX.glass.glass.linker = linker 182 LINUX.glass.glass.linkFlags = [linkFlags, "-lX11", "-ldl" ].flatten() 183 LINUX.glass.glass.lib = "glass" 184 185 LINUX.glass.glassgtk2 = [:] 186 LINUX.glass.glassgtk2.nativeSource = ft_gtk.getFiles() 187 LINUX.glass.glassgtk2.compiler = compiler 188 LINUX.glass.glassgtk2.ccFlags = [ccFlags, gtk2CCFlags, "-Werror"].flatten() 189 LINUX.glass.glassgtk2.linker = linker 190 LINUX.glass.glassgtk2.linkFlags = [linkFlags, gtk2LinkFlags ].flatten() 191 LINUX.glass.glassgtk2.lib = "glassgtk2" 192 193 LINUX.glass.glassgtk3 = [:] 194 LINUX.glass.glassgtk3.nativeSource = ft_gtk.getFiles() 195 LINUX.glass.glassgtk3.compiler = compiler 196 LINUX.glass.glassgtk3.ccFlags = [ccFlags, gtk3CCFlags, "-Werror"].flatten() 197 LINUX.glass.glassgtk3.linker = linker 198 LINUX.glass.glassgtk3.linkFlags = [linkFlags, gtk3LinkFlags ].flatten() 199 LINUX.glass.glassgtk3.lib = "glassgtk3" 200 201 LINUX.decora = [:] 202 LINUX.decora.compiler = compiler 203 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten() 204 LINUX.decora.linker = linker 205 LINUX.decora.linkFlags = [linkFlags].flatten() 206 LINUX.decora.lib = "decora_sse" 207 208 LINUX.prism = [:] 209 LINUX.prism.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism") 210 LINUX.prism.compiler = compiler 211 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 212 LINUX.prism.linker = linker 213 LINUX.prism.linkFlags = [linkFlags].flatten() 214 LINUX.prism.lib = "prism_common" 215 216 LINUX.prismSW = [:] 217 LINUX.prismSW.nativeSource = file("${project(":graphics").projectDir}/src/main/native-prism-sw") 218 LINUX.prismSW.compiler = compiler 219 LINUX.prismSW.ccFlags = [ccFlags, "-DINLINE=inline"].flatten() 220 LINUX.prismSW.linker = linker 221 LINUX.prismSW.linkFlags = [linkFlags].flatten() 222 LINUX.prismSW.lib = "prism_sw" 223 224 LINUX.launcher = [:] 225 LINUX.launcher.compiler = compiler 226 LINUX.launcher.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c"] 227 LINUX.launcher.linker = linker 228 LINUX.launcher.linkFlags = ["-ldl"] 229 if (!IS_64) { 230 LINUX.launcher.ccFlags += "-m32" 231 LINUX.launcher.linkFlags += "-m32" 232 } 233 234 LINUX.launcherlibrary = [:] 235 LINUX.launcherlibrary.compiler = compiler 236 LINUX.launcherlibrary.ccFlags = ["-DJAVAARCH=\"$OS_ARCH\"", "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c", "-fPIC"] 237 LINUX.launcherlibrary.linker = linker 238 LINUX.launcherlibrary.linkFlags = ["-ldl", "-lpthread", "-shared"] 239 if (!IS_64) { 240 LINUX.launcherlibrary.ccFlags += "-m32" 241 LINUX.launcherlibrary.linkFlags += "-m32" 242 } 243 244 LINUX.iio = [:] 245 LINUX.iio.nativeSource = [ 246 file("${project("graphics").projectDir}/src/main/native-iio"), 247 file("${project("graphics").projectDir}/src/main/native-iio/libjpeg7")] 248 LINUX.iio.compiler = compiler 249 LINUX.iio.ccFlags = [ccFlags].flatten() 250 LINUX.iio.linker = linker 251 LINUX.iio.linkFlags = [linkFlags].flatten() 252 LINUX.iio.lib = "javafx_iio" 253 254 LINUX.prismES2 = [:] 255 LINUX.prismES2.nativeSource = [ 256 file("${project("graphics").projectDir}/src/main/native-prism-es2"), 257 file("${project("graphics").projectDir}/src/main/native-prism-es2/GL"), 258 file("${project("graphics").projectDir}/src/main/native-prism-es2/x11") 259 ] 260 LINUX.prismES2.compiler = compiler 261 LINUX.prismES2.ccFlags = ["-DLINUX", ccFlags].flatten() 262 LINUX.prismES2.linker = linker 263 LINUX.prismES2.linkFlags = [linkFlags, "-lX11", "-lXxf86vm", "-lGL"].flatten() 264 LINUX.prismES2.lib = "prism_es2" 265 266 def closedDir = file("$projectDir/../rt-closed") 267 LINUX.font = [:] 268 LINUX.font.compiler = compiler 269 LINUX.font.nativeSource = [file("${project("graphics").projectDir}/src/main/native-font")] 270 LINUX.font.ccFlags = ["-DJFXFONT_PLUS", ccFlags].flatten() 271 LINUX.font.linker = linker 272 LINUX.font.linkFlags = [linkFlags].flatten() 273 LINUX.font.lib = "javafx_font" 274 275 LINUX.fontT2K = [:] 276 LINUX.fontT2K.nativeSource = [ 277 file("$closedDir/javafx-font-t2k-native/src"), 278 file("$closedDir/javafx-font-t2k-native/src/layout")] 279 LINUX.fontT2K.compiler = compiler 280 LINUX.fontT2K.ccFlags = ["-DJFXFONT_PLUS", "-DLE_STANDALONE", ccFlags].flatten() 281 LINUX.fontT2K.linker = linker 282 LINUX.fontT2K.linkFlags = [linkFlags].flatten() 283 LINUX.fontT2K.lib = "javafx_font_t2k" 284 285 LINUX.fontFreetype = [:] 286 LINUX.fontFreetype.nativeSource = ["src/main/native-font/freetype.c"] 287 LINUX.fontFreetype.compiler = compiler 288 LINUX.fontFreetype.ccFlags = ["-DJFXFONT_PLUS", ccFlags, freetypeCCFlags].flatten() 289 LINUX.fontFreetype.linker = linker 290 LINUX.fontFreetype.linkFlags = [linkFlags, freetypeLinkFlags].flatten() 291 LINUX.fontFreetype.lib = "javafx_font_freetype" 292 293 LINUX.fontPango = [:] 294 LINUX.fontPango.nativeSource = ["src/main/native-font/pango.c"] 295 LINUX.fontPango.compiler = compiler 296 LINUX.fontPango.ccFlags = ["-DJFXFONT_PLUS", ccFlags, pangoCCFlags].flatten() 297 LINUX.fontPango.linker = linker 298 LINUX.fontPango.linkFlags = [linkFlags, pangoLinkFlags].flatten() 299 LINUX.fontPango.lib = "javafx_font_pango" 300 301 LINUX.media = [:] 302 LINUX.media.compiler = compiler 303 LINUX.media.linker = linker 304 LINUX.media.ar = "ar" |