< prev index next >

buildSrc/linux.gradle

Print this page




  37 // Libraries end up in the sdk/rt/lib/$OS_ARCH directory for Linux
  38 LINUX.libDest = "lib/$OS_ARCH"
  39 
  40 // Lambda for naming the generated libs
  41 LINUX.library = { name -> return "lib${name}.so" as String }
  42 
  43 // A set of common parameters to use for both compiling and linking
  44 def commonFlags = [
  45         "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags
  46         "-W", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags
  47 
  48 if (!IS_64) {
  49     commonFlags += "-m32"
  50 }
  51 
  52 // Specify the compilation parameters and link parameters
  53 def ccFlags = [
  54         commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c",
  55         "-ffunction-sections", "-fdata-sections",
  56         IS_DEBUG_NATIVE ? ["-ggdb", "-DVERBOSE"] : ["-O2", "-DNDEBUG"]].flatten()

  57 //ccFlags.addAll(["-Wnon-virtual-dtor", "-Woverloaded-virtual", "-std=c++0x"])
  58 def linkFlags = ["-static-libgcc", "-static-libstdc++", "-shared", commonFlags,
  59                  "-Wl,--gc-sections"].flatten()
  60 def defaultLinkFlags = linkFlags.flatten()
  61 






  62 // Create $buildDir/linux_tools.properties file and load props from it
  63 setupTools("linux_tools",
  64     { propFile ->
  65         ByteArrayOutputStream results = new ByteArrayOutputStream();
  66         exec {
  67             commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst");
  68             setStandardOutput(results);
  69         }
  70         propFile << "cflags=" << results.toString().trim() << "\n";
  71 
  72         results = new ByteArrayOutputStream();
  73         exec {
  74             commandLine "pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst"
  75             standardOutput = results
  76         }
  77         propFile << "libs=" << results.toString().trim();

























  78     },
  79     { properties ->
  80         ccFlags.addAll(properties.getProperty("cflags").split(" "))
  81         linkFlags.addAll(properties.getProperty("libs").split(" "))







  82     }
  83 )
  84 
  85 def pangoCCFlags = ["-D_ENABLE_PANGO"];
  86 def pangoLinkFlags = [];
  87 setupTools("linux_pango_tools",
  88     { propFile ->
  89         ByteArrayOutputStream results = new ByteArrayOutputStream();
  90         exec {
  91             commandLine "pkg-config", "--cflags", "pangoft2"
  92             standardOutput = results
  93         }
  94         propFile << "cflags=" << results.toString().trim() << "\n";
  95 
  96         results = new ByteArrayOutputStream();
  97         exec {
  98             commandLine "pkg-config", "--libs", "pangoft2"
  99             standardOutput = results
 100         }
 101         propFile << "libs=" << results.toString().trim();


 118         }
 119         propFile << "cflags=" << results.toString().trim() << "\n";
 120 
 121         results = new ByteArrayOutputStream();
 122         exec {
 123             commandLine "pkg-config", "--libs", "freetype2"
 124             standardOutput = results
 125         }
 126         propFile << "libs=" << results.toString().trim();
 127     },
 128     { properties ->
 129         freetypeCCFlags.addAll(properties.getProperty("cflags").split(" "))
 130         freetypeLinkFlags.addAll(properties.getProperty("libs").split(" "))
 131     }
 132 )
 133 
 134 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc";
 135 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++";
 136 
 137 LINUX.glass = [:]

















 138 LINUX.glass.javahInclude = [
 139     "com/sun/glass/events/**",
 140     "com/sun/glass/ui/*",
 141     "com/sun/glass/ui/gtk/*"]
 142 LINUX.glass.nativeSource = file("modules/graphics/src/main/native-glass/gtk")
 143 LINUX.glass.compiler = compiler
 144 LINUX.glass.ccFlags = [ccFlags, "-Werror"].flatten()
 145 LINUX.glass.linker = linker
 146 LINUX.glass.linkFlags = [linkFlags].flatten()
 147 LINUX.glass.lib = "glass"
















 148 
 149 LINUX.decora = [:]
 150 LINUX.decora.compiler = compiler
 151 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten()
 152 LINUX.decora.linker = linker
 153 LINUX.decora.linkFlags = [linkFlags].flatten()
 154 LINUX.decora.lib = "decora_sse"
 155 
 156 LINUX.prism = [:]
 157 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
 158 LINUX.prism.nativeSource = file("modules/graphics/src/main/native-prism")
 159 LINUX.prism.compiler = compiler
 160 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten()
 161 LINUX.prism.linker = linker
 162 LINUX.prism.linkFlags = [linkFlags].flatten()
 163 LINUX.prism.lib = "prism_common"
 164 
 165 LINUX.prismSW = [:]
 166 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"]
 167 LINUX.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw")




  37 // Libraries end up in the sdk/rt/lib/$OS_ARCH directory for Linux
  38 LINUX.libDest = "lib/$OS_ARCH"
  39 
  40 // Lambda for naming the generated libs
  41 LINUX.library = { name -> return "lib${name}.so" as String }
  42 
  43 // A set of common parameters to use for both compiling and linking
  44 def commonFlags = [
  45         "-fno-strict-aliasing", "-fPIC", "-fno-omit-frame-pointer", // optimization flags
  46         "-W", "-Wall", "-Wno-unused", "-Wno-parentheses", "-Werror=implicit-function-declaration"] // warning flags
  47 
  48 if (!IS_64) {
  49     commonFlags += "-m32"
  50 }
  51 
  52 // Specify the compilation parameters and link parameters
  53 def ccFlags = [
  54         commonFlags, "-I$JDK_HOME/include", "-I$JDK_HOME/include/linux", "-c",
  55         "-ffunction-sections", "-fdata-sections",
  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 = ["-static-libgcc", "-static-libstdc++", "-shared", commonFlags,
  60                  "-Wl,--gc-sections"].flatten()
  61 def defaultLinkFlags = linkFlags.flatten()
  62 
  63 def gtk2CCFlags = [  ];
  64 def gtk3CCFlags = [ "-Wno-deprecated-declarations" ];
  65 def gtk2LinkFlags = [ ];
  66 def gtk3LinkFlags = [ ];
  67 LINUX.buildGTK3 = true
  68 
  69 // Create $buildDir/linux_tools.properties file and load props from it
  70 setupTools("linux_gtk2",
  71     { propFile ->
  72         ByteArrayOutputStream results1 = new ByteArrayOutputStream();
  73         exec {
  74             commandLine("pkg-config", "--cflags", "gtk+-2.0", "gthread-2.0", "xtst")
  75             setStandardOutput(results1);
  76         }
  77         propFile << "cflagsGTK2=" << results1.toString().trim() << "\n";
  78 
  79         ByteArrayOutputStream results3 = new ByteArrayOutputStream();
  80         exec {
  81             commandLine("pkg-config", "--libs", "gtk+-2.0", "gthread-2.0", "xtst")
  82             setStandardOutput(results3);
  83         }
  84         propFile << "libsGTK2=" << results3.toString().trim()  << "\n";
  85     },
  86     { properties ->
  87         gtk2CCFlags.addAll(properties.getProperty("cflagsGTK2").split(" "))
  88         gtk2LinkFlags.addAll(properties.getProperty("libsGTK2").split(" "))
  89     }
  90 )
  91 
  92 setupTools("linux_gtk3",
  93     { propFile ->
  94         ByteArrayOutputStream results2 = new ByteArrayOutputStream();
  95         exec {
  96             commandLine("pkg-config", "--cflags", "gtk+-3.0", "gthread-2.0", "xtst")
  97             setStandardOutput(results2);
  98             ignoreExitValue(true)
  99         }
 100         propFile << "cflagsGTK3=" << results2.toString().trim() << "\n";
 101 
 102         ByteArrayOutputStream results4 = new ByteArrayOutputStream();
 103         exec {
 104             commandLine("pkg-config", "--libs", "gtk+-3.0", "gthread-2.0", "xtst")
 105             setStandardOutput(results4);
 106             ignoreExitValue(true)
 107         }
 108         propFile << "libsGTK3=" << results4.toString().trim()  << "\n";
 109 
 110     },
 111     { properties ->
 112         String ccflags =  properties.getProperty("cflagsGTK3")
 113         String ldflags =  properties.getProperty("libsGTK3")
 114         if (ccflags != null && ! ccflags.equals("")) {
 115             gtk3CCFlags.addAll(properties.getProperty("cflagsGTK3").split(" "))
 116             gtk3LinkFlags.addAll(properties.getProperty("libsGTK3").split(" "))
 117         } else {
 118             logger.info("Warning: GTK3 development packages not found, not building GTK3 support");
 119             LINUX.buildGTK3 = false
 120         }
 121     }
 122 )
 123 
 124 def pangoCCFlags = ["-D_ENABLE_PANGO"];
 125 def pangoLinkFlags = [];
 126 setupTools("linux_pango_tools",
 127     { propFile ->
 128         ByteArrayOutputStream results = new ByteArrayOutputStream();
 129         exec {
 130             commandLine "pkg-config", "--cflags", "pangoft2"
 131             standardOutput = results
 132         }
 133         propFile << "cflags=" << results.toString().trim() << "\n";
 134 
 135         results = new ByteArrayOutputStream();
 136         exec {
 137             commandLine "pkg-config", "--libs", "pangoft2"
 138             standardOutput = results
 139         }
 140         propFile << "libs=" << results.toString().trim();


 157         }
 158         propFile << "cflags=" << results.toString().trim() << "\n";
 159 
 160         results = new ByteArrayOutputStream();
 161         exec {
 162             commandLine "pkg-config", "--libs", "freetype2"
 163             standardOutput = results
 164         }
 165         propFile << "libs=" << results.toString().trim();
 166     },
 167     { properties ->
 168         freetypeCCFlags.addAll(properties.getProperty("cflags").split(" "))
 169         freetypeLinkFlags.addAll(properties.getProperty("libs").split(" "))
 170     }
 171 )
 172 
 173 def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "gcc";
 174 def linker = IS_COMPILE_PARFAIT ? "parfait-g++" : "g++";
 175 
 176 LINUX.glass = [:]
 177 LINUX.glass.variants = ["glass", "glassgtk2"]
 178 if (LINUX.buildGTK3) {
 179     logger.info("Building libglassgtk3")
 180     LINUX.glass.variants += "glassgtk3"
 181 } else {
 182     logger.warn("NOT Building libglassgtk3")
 183 }
 184 
 185 FileTree ft_gtk_launcher = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") {
 186     include("**/launcher.c")
 187 }
 188 
 189 FileTree ft_gtk = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") {
 190     exclude("**/launcher.c")
 191 }
 192 
 193 LINUX.glass.glass = [:]
 194 LINUX.glass.javahInclude = [
 195     "com/sun/glass/events/**",
 196     "com/sun/glass/ui/*",
 197     "com/sun/glass/ui/gtk/*"]
 198 LINUX.glass.glass.nativeSource = ft_gtk_launcher.getFiles()
 199 LINUX.glass.glass.compiler = compiler
 200 LINUX.glass.glass.ccFlags = [ccFlags, gtk2CCFlags,  "-Werror"].flatten()
 201 LINUX.glass.glass.linker = linker
 202 LINUX.glass.glass.linkFlags = [linkFlags, "-lX11", "-ldl" ].flatten()
 203 LINUX.glass.glass.lib = "glass"
 204 
 205 LINUX.glass.glassgtk2 = [:]
 206 LINUX.glass.glassgtk2.nativeSource =  ft_gtk.getFiles()
 207 LINUX.glass.glassgtk2.compiler = compiler
 208 LINUX.glass.glassgtk2.ccFlags = [ccFlags, gtk2CCFlags, "-Werror"].flatten()
 209 LINUX.glass.glassgtk2.linker = linker
 210 LINUX.glass.glassgtk2.linkFlags = [linkFlags, gtk2LinkFlags ].flatten()
 211 LINUX.glass.glassgtk2.lib = "glassgtk2"
 212 
 213 LINUX.glass.glassgtk3 = [:]
 214 LINUX.glass.glassgtk3.nativeSource =  ft_gtk.getFiles()
 215 LINUX.glass.glassgtk3.compiler = compiler
 216 LINUX.glass.glassgtk3.ccFlags = [ccFlags, gtk3CCFlags, "-Werror"].flatten()
 217 LINUX.glass.glassgtk3.linker = linker
 218 LINUX.glass.glassgtk3.linkFlags = [linkFlags, gtk3LinkFlags ].flatten()
 219 LINUX.glass.glassgtk3.lib = "glassgtk3"
 220 
 221 LINUX.decora = [:]
 222 LINUX.decora.compiler = compiler
 223 LINUX.decora.ccFlags = [ccFlags, "-ffast-math"].flatten()
 224 LINUX.decora.linker = linker
 225 LINUX.decora.linkFlags = [linkFlags].flatten()
 226 LINUX.decora.lib = "decora_sse"
 227 
 228 LINUX.prism = [:]
 229 LINUX.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"]
 230 LINUX.prism.nativeSource = file("modules/graphics/src/main/native-prism")
 231 LINUX.prism.compiler = compiler
 232 LINUX.prism.ccFlags = [ccFlags, "-DINLINE=inline"].flatten()
 233 LINUX.prism.linker = linker
 234 LINUX.prism.linkFlags = [linkFlags].flatten()
 235 LINUX.prism.lib = "prism_common"
 236 
 237 LINUX.prismSW = [:]
 238 LINUX.prismSW.javahInclude = ["com/sun/pisces/**/*"]
 239 LINUX.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw")


< prev index next >