1 /* 2 * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 ext.WIN = [:] 27 28 WIN.canBuild = IS_WINDOWS 29 if (!WIN.canBuild) return; 30 31 WIN.compileSwing = true; 32 WIN.compileSWT = true; 33 WIN.compileFXPackager = true; 34 WIN.compileDesignTime = true; 35 36 WIN.includeNull3d = true 37 38 // Lambda for naming the generated libs 39 WIN.library = { name -> return "${name}.dll" as String } 40 41 WIN.libDest = "bin" 42 43 def ccFlags = ["/nologo", "/W3", "/EHsc", "/c", 44 "/D_STATIC_CPPLIB", "/D_DISABLE_DEPRECATE_STATIC_CPPLIB", "/DINLINE=__inline", 45 "/DUNICODE", "/D_UNICODE", "/DWIN32", "/DIAL", "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", 46 "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", 47 IS_DEBUG_NATIVE ? ["/MDd", "/Od", "/Zi", "/FS", "/DDEBUG"] : ["/O2", "/MD", "/DNDEBUG"]].flatten(); 48 49 def linkFlags = ["/nologo", "/dll", "/manifest", "/opt:REF", "/incremental:no"]; 50 if (IS_DEBUG_NATIVE) linkFlags.add("/debug"); 51 52 setupTools("windows_tools", 53 { propFile -> 54 // Create the properties file 55 ByteArrayOutputStream results = new ByteArrayOutputStream(); 56 String winsdkDir = System.getenv().get("WINSDK_DIR"); 57 exec({ 58 environment([ 59 "WINSDKPATH" : winsdkDir == null ? "" : winsdkDir, 60 "CONF" : "/$CONF", // TODO does this mean the generated properties must be reset when in a different configuration? 61 "VCARCH" : IS_64 ? "amd64" : "x86", 62 "SDKARCH" : IS_64 ? "/x64" : "/x86", 63 ]); 64 commandLine("cmd", "/q", "/c", "buildSrc\\genVSproperties.bat"); 65 setStandardOutput(results); 66 }); 67 BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim())); 68 reader.readLine(); 69 reader.readLine(); 70 String line; 71 while ((line = reader.readLine()) != null && !line.startsWith("######")) { 72 line = line.replace("\\", "/").replace("/@@ENDOFLINE@@", "").replace("@@ENDOFLINE@@", "").replace("//", "/").replace("windows.vs.", "WINDOWS_VS_"); 73 propFile << line << "\r\n"; 74 } 75 }, 76 { properties -> 77 defineProperty("WINDOWS_VS_VSINSTALLDIR", properties, "c:/Program Files (x86)/Microsoft Visual Studio 10.0"); 78 defineProperty("WINDOWS_SDK_DIR", properties, System.getenv().get("WINSDK_DIR")) 79 defineProperty("WINDOWS_VS_VCINSTALLDIR", properties, "$WINDOWS_VS_VSINSTALLDIR/VC") 80 defineProperty("WINDOWS_VS_DEVENVDIR", properties, "$WINDOWS_VS_VSINSTALLDIR/Common7/IDE") 81 defineProperty("WINDOWS_VS_DEVENVCMD", properties, "$WINDOWS_VS_DEVENVDIR/VCExpress.exe") 82 defineProperty("WINDOWS_VS_MSVCDIR", properties, WINDOWS_VS_VCINSTALLDIR) 83 defineProperty("WINDOWS_DXSDK_DIR", properties, System.getenv().get("DXSDK_DIR")) 84 defineProperty("WINDOWS_VS_INCLUDE", properties, "$WINDOWS_VS_VCINSTALLDIR/INCLUDE;" + "$WINDOWS_SDK_DIR/include;") 85 defineProperty("WINDOWS_VS_VER", properties, "70") 86 defineProperty("WINDOWS_VS_LIB", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;" + "$WINDOWS_SDK_DIR/lib;") 87 defineProperty("WINDOWS_VS_LIBPATH", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;") 88 def parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : ""; 89 defineProperty("WINDOWS_VS_PATH", properties, parfaitPath + "$WINDOWS_VS_DEVENVDIR;" + 90 "$WINDOWS_VS_VSINSTALLDIR/VC/BIN;" + 91 "$WINDOWS_VS_VSINSTALLDIR/Common7/Tools;" + 92 "$WINDOWS_VS_VCINSTALLDIR/VCPackages;" + 93 "$WINDOWS_SDK_DIR/bin/NETFX 4.0 Tools;" + 94 "$WINDOWS_SDK_DIR/bin;" + 95 System.getenv().get("PATH")) 96 } 97 ) 98 99 // Remove C++ static linking if not on VS2010 100 if (WINDOWS_VS_VER != "100") { 101 ccFlags -= ["/D_STATIC_CPPLIB", "/D_DISABLE_DEPRECATE_STATIC_CPPLIB"] 102 } 103 104 ext.WINDOWS_NATIVE_COMPILE_ENVIRONMENT = [ 105 "VCINSTALLDIR" : WINDOWS_VS_VCINSTALLDIR, 106 "VSINSTALLDIR" : WINDOWS_VS_VSINSTALLDIR, 107 "DEVENVDIR" : WINDOWS_VS_DEVENVDIR, 108 "MSVCDIR" : WINDOWS_VS_MSVCDIR, 109 "VS_VER" : WINDOWS_VS_VER, 110 "PATH" : WINDOWS_VS_PATH, 111 "INCLUDE" : WINDOWS_VS_INCLUDE, 112 "LIB" : WINDOWS_VS_LIB, 113 "LIBPATH" : WINDOWS_VS_LIBPATH, 114 "DXSDK_DIR" : WINDOWS_DXSDK_DIR 115 ]; 116 117 String msvcBinDir = (IS_64 118 ? "$WINDOWS_VS_VSINSTALLDIR/VC/BIN/amd64" 119 : "$WINDOWS_VS_VSINSTALLDIR/VC/BIN") 120 def compiler = IS_COMPILE_PARFAIT ? "cl.exe" : cygpath("$msvcBinDir/cl.exe") 121 def linker = IS_COMPILE_PARFAIT ? "link.exe" : cygpath("$msvcBinDir/link.exe") 122 def winSdkBinDir = "$WINDOWS_SDK_DIR/Bin" 123 if (WINDOWS_VS_VER != "100") { 124 winSdkBinDir += "/" + (IS_64 ? "x64" : "x86") 125 } 126 ext.RC = cygpath("$winSdkBinDir/RC.Exe") 127 def rcCompiler = RC 128 ext.FXC = cygpath("$WINDOWS_DXSDK_DIR/utilities/bin/x86/fxc.exe") 129 ext.MC = cygpath("$winSdkBinDir/mt.exe") 130 ext.MSVCR = cygpath("${WINDOWS_VS_MSVCDIR}/redist/${IS_64 ? 'x64' : 'x86'}/Microsoft.VC${WINDOWS_VS_VER}.CRT/msvcr${WINDOWS_VS_VER}.dll") 131 ext.MSVCP = cygpath("${WINDOWS_VS_MSVCDIR}/redist/${IS_64 ? 'x64' : 'x86'}/Microsoft.VC${WINDOWS_VS_VER}.CRT/msvcp${WINDOWS_VS_VER}.dll") 132 133 if (!file(RC).exists()) throw new GradleException("FAIL: cannot find RC") 134 135 def rcFlags = [ 136 "/d", "\"JFX_COMPANY=${COMPANY_NAME}\"", 137 "/d", "\"JFX_COMPONENT=${PRODUCT_NAME} ${PLATFORM_NAME} binary\"", 138 "/d", "\"JFX_NAME=${PRODUCT_NAME} ${PLATFORM_NAME} ${jfxReleaseMajorVersion}\"", 139 "/d", "\"JFX_VER=${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseMicroVersion}.${PROMOTED_BUILD_NUMBER}\"", 140 "/d", "\"JFX_BUILD_ID=${RAW_VERSION}-${RELEASE_MILESTONE}-b${PROMOTED_BUILD_NUMBER}\"", 141 "/d", "\"JFX_COPYRIGHT=Copyright \u00A9 ${Calendar.getInstance().get(Calendar.YEAR)}\"", 142 "/d", "\"JFX_FVER=${jfxReleaseMajorVersion},${jfxReleaseMinorVersion},${jfxReleaseMicroVersion},${PROMOTED_BUILD_NUMBER}\"", 143 "/d", "\"JFX_FTYPE=0x2L\"", 144 "/nologo" 145 ]; 146 147 def defaultRcSource = file("modules/graphics/src/main/resources/version.rc"); 148 149 WIN.glass = [:] 150 WIN.glass.javahInclude = [ 151 "com/sun/glass/events/**", 152 "com/sun/glass/ui/*", 153 "com/sun/glass/ui/win/*"] 154 WIN.glass.nativeSource = file("modules/graphics/src/main/native-glass/win") 155 WIN.glass.compiler = compiler 156 WIN.glass.rcCompiler = rcCompiler; 157 WIN.glass.rcSource = file("modules/graphics/src/main/native-glass/win/GlassResources.rc"); 158 WIN.glass.rcFlags = [ 159 "/I", file("modules/graphics/src/main/resources"), 160 "/d", "JFX_FNAME=glass.dll", 161 "/d", "JFX_INTERNAL_NAME=glass", 162 rcFlags].flatten(); 163 WIN.glass.ccFlags = [ccFlags, "/WX"].flatten() 164 if (WINDOWS_VS_VER != "100") WIN.glass.ccFlags -= ["/WX"] 165 WIN.glass.linker = linker 166 WIN.glass.linkFlags = [linkFlags, "delayimp.lib", "gdi32.lib", "urlmon.lib", "Comdlg32.lib", 167 "winmm.lib", "imm32.lib", "shell32.lib", "Uiautomationcore.lib", "dwmapi.lib", 168 "/DELAYLOAD:user32.dll", "/DELAYLOAD:urlmon.dll", "/DELAYLOAD:winmm.dll", "/DELAYLOAD:shell32.dll", 169 "/DELAYLOAD:Uiautomationcore.dll", "/DELAYLOAD:dwmapi.dll"].flatten() 170 WIN.glass.lib = "glass" 171 172 WIN.decora = [:] 173 WIN.decora.compiler = compiler 174 WIN.decora.ccFlags = ["/arch:SSE", "/fp:fast", ccFlags].flatten() 175 WIN.decora.linker = linker 176 WIN.decora.linkFlags = [linkFlags].flatten() 177 WIN.decora.lib = "decora_sse" 178 WIN.decora.rcCompiler = rcCompiler; 179 WIN.decora.rcSource = defaultRcSource 180 WIN.decora.rcFlags = ["/d", "JFX_FNAME=decora_sse.dll", "/d", "JFX_INTERNAL_NAME=decora", rcFlags].flatten() 181 182 WIN.prism = [:] 183 WIN.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 184 WIN.prism.nativeSource = file("modules/graphics/src/main/native-prism") 185 WIN.prism.compiler = compiler 186 WIN.prism.ccFlags = [ccFlags].flatten() 187 WIN.prism.linker = linker 188 WIN.prism.linkFlags = [linkFlags].flatten() 189 WIN.prism.lib = "prism_common" 190 WIN.prism.rcCompiler = rcCompiler; 191 WIN.prism.rcSource = defaultRcSource 192 WIN.prism.rcFlags = ["/d", "JFX_FNAME=prism_common.dll", "/d", "JFX_INTERNAL_NAME=prism", rcFlags].flatten() 193 194 WIN.prismSW = [:] 195 WIN.prismSW.javahInclude = ["com/sun/pisces/**/*"] 196 WIN.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw") 197 WIN.prismSW.compiler = compiler 198 WIN.prismSW.ccFlags = [ccFlags].flatten() 199 WIN.prismSW.linker = linker 200 WIN.prismSW.linkFlags = [linkFlags].flatten() 201 WIN.prismSW.lib = "prism_sw" 202 WIN.prismSW.rcCompiler = rcCompiler; 203 WIN.prismSW.rcSource = defaultRcSource 204 WIN.prismSW.rcFlags = ["/d", "JFX_FNAME=prism_sw.dll", "/d", "JFX_INTERNAL_NAME=prismSW", rcFlags].flatten() 205 206 WIN.prismD3D = [:] 207 WIN.prismD3D.javahInclude = ["com/sun/prism/d3d/**/*"] 208 WIN.prismD3D.nativeSource = [ 209 file("modules/graphics/src/main/native-prism-d3d"), 210 file("modules/graphics/src/main/native-prism-d3d/hlsl")] 211 WIN.prismD3D.compiler = compiler 212 WIN.prismD3D.ccFlags = [ccFlags, "/Ibuild/headers/PrismD3D"].flatten() 213 WIN.prismD3D.linker = linker 214 WIN.prismD3D.linkFlags = [linkFlags, "user32.lib"].flatten() 215 WIN.prismD3D.lib = "prism_d3d" 216 WIN.prismD3D.rcCompiler = rcCompiler; 217 WIN.prismD3D.rcSource = defaultRcSource 218 WIN.prismD3D.rcFlags = ["/d", "JFX_FNAME=prism_d3d.dll", "/d", "JFX_INTERNAL_NAME=prismD3D", rcFlags].flatten(); 219 220 WIN.launcher = [:] 221 WIN.launcher.compiler = compiler 222 WIN.launcher.ccFlags = ["/nologo", "/W3", "/EHsc", "/D_WINDOWS", "/DUNICODE", "/D_UNICODE", "/DWIN32", 223 "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", 224 "/arch:SSE", "/fp:fast", 225 IS_DEBUG_NATIVE ? ["/MDd", "/Od", "/Zi", "/FS", "/DDEBUG"] : ["/O2", "/MD", "/DNDEBUG"]].flatten(); 226 WIN.launcher.linker = linker 227 WIN.launcher.linkFlags = ["/link", "/nologo", "/WX", "/SUBSYSTEM:WINDOWS", "user32.lib", "shell32.lib", "advapi32.lib"] 228 if (IS_DEBUG_NATIVE) WIN.launcher.linkFlags.add("/debug"); 229 230 WIN.launcherlibrary = [:] 231 WIN.launcherlibrary.compiler = compiler 232 WIN.launcherlibrary.ccFlags = ["/nologo", "/W3", 233 // "/WX", 234 "/EHsc", "/c", "/D_WINDOWS", "/DUNICODE", "/D_UNICODE", "/DWIN32", 235 "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", 236 "/arch:SSE", "/fp:fast", 237 IS_DEBUG_NATIVE ? ["/MDd", "/Od", "/Zi", "/FS", "/DDEBUG"] : ["/O2", "/MD", "/DNDEBUG"]].flatten(); 238 WIN.launcherlibrary.linker = linker 239 WIN.launcherlibrary.linkFlags = ["/nologo", "/WX", "/DLL", "/SUBSYSTEM:WINDOWS", "user32.lib", "shell32.lib", "advapi32.lib", "ole32.lib"] 240 if (IS_DEBUG_NATIVE) WIN.launcherlibrary.linkFlags.add("/debug"); 241 242 WIN.iconLauncher = [:] 243 WIN.iconLauncher.compiler = compiler 244 WIN.iconLauncher.ccFlags = ["/nologo", "/W3", "/EHsc", "/D_WINDOWS", "/DUNICODE", "/D_UNICODE", 245 "/arch:SSE", "/fp:fast", "/O2"] 246 WIN.iconLauncher.linker = linker 247 WIN.iconLauncher.linkFlags = ["/link", "/nologo", "/SUBSYSTEM:CONSOLE"]; 248 249 WIN.fxpackager = [:] 250 WIN.fxpackager.nativeSource = [ 251 file("modules/fxpackager/src/main/native/javapackager/win")] 252 WIN.fxpackager.compiler = compiler 253 WIN.fxpackager.ccFlags = ["/nologo", "/W3", "/EHsc", "/MT", "/GS", 254 "/DWIN32", "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", 255 "/D_WIN32_WINDOWS=0X0500", "/D_WIN32_WINNT=0X0500", 256 "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", "/arch:SSE", "/fp:fast", 257 "/O2", "-c"] 258 WIN.fxpackager.linker = linker 259 260 WIN.iio = [:] 261 WIN.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 262 WIN.iio.nativeSource = [ 263 file("modules/graphics/src/main/native-iio"), 264 file("modules/graphics/src/main/native-iio/libjpeg7")] 265 WIN.iio.compiler = compiler 266 WIN.iio.ccFlags = [ccFlags].flatten() 267 WIN.iio.linker = linker 268 WIN.iio.linkFlags = [linkFlags].flatten() 269 WIN.iio.lib = "javafx_iio" 270 WIN.iio.rcCompiler = rcCompiler; 271 WIN.iio.rcSource = defaultRcSource 272 WIN.iio.rcFlags = ["/d", "JFX_FNAME=javafx_iio.dll", "/d", "JFX_INTERNAL_NAME=iio", rcFlags].flatten(); 273 274 WIN.prismES2 = [:] 275 WIN.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 276 WIN.prismES2.nativeSource = [ 277 file("modules/graphics/src/main/native-prism-es2"), 278 file("modules/graphics/src/main/native-prism-es2/GL"), 279 file("modules/graphics/src/main/native-prism-es2/windows") 280 ] 281 WIN.prismES2.compiler = compiler 282 WIN.prismES2.ccFlags = ["/Ob1", "/GF", "/Gy", "/GS", "/DWIN32", ccFlags].flatten() 283 WIN.prismES2.linker = linker 284 WIN.prismES2.linkFlags = [linkFlags, "/SUBSYSTEM:WINDOWS", "opengl32.lib", "gdi32.lib", "user32.lib", "kernel32.lib"].flatten() 285 WIN.prismES2.lib = "prism_es2" 286 WIN.prismES2.rcCompiler = rcCompiler; 287 WIN.prismES2.rcSource = defaultRcSource 288 WIN.prismES2.rcFlags = ["/d", "JFX_FNAME=prism_es2.dll", "/d", "JFX_INTERNAL_NAME=prismES2", rcFlags].flatten(); 289 290 def closedDir = file("$projectDir/../rt-closed") 291 WIN.font = [:] 292 WIN.font.javahInclude = [ 293 "com/sun/javafx/font/**/*", 294 "com/sun/javafx/text/**/*"] 295 WIN.font.nativeSource = [file("modules/graphics/src/main/native-font")] 296 WIN.font.compiler = compiler 297 WIN.font.ccFlags = ["/DJFXFONT_PLUS", ccFlags].flatten() 298 WIN.font.ccFlags -= ["/DUNICODE", "/D_UNICODE"] 299 WIN.font.linker = linker 300 WIN.font.linkFlags = [linkFlags, "advapi32.lib", "gdi32.lib", "user32.lib", "dwrite.lib", "d2d1.lib", "windowscodecs.lib", "ole32.lib"].flatten() 301 WIN.font.lib = "javafx_font" 302 WIN.font.rcCompiler = rcCompiler; 303 WIN.font.rcSource = defaultRcSource 304 WIN.font.rcFlags = ["/d", "JFX_FNAME=javafx_font.dll", "/d", "JFX_INTERNAL_NAME=font", rcFlags].flatten(); 305 306 WIN.fontT2K = [:] 307 WIN.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 308 WIN.fontT2K.nativeSource = [ 309 file("$closedDir/javafx-font-t2k-native/src"), 310 file("$closedDir/javafx-font-t2k-native/src/layout")] 311 WIN.fontT2K.compiler = compiler 312 WIN.fontT2K.ccFlags = ["/DJFXFONT_PLUS", "/DLE_STANDALONE", ccFlags].flatten() 313 WIN.fontT2K.linker = linker 314 WIN.fontT2K.linkFlags = [linkFlags, "advapi32.lib", "gdi32.lib", "user32.lib"].flatten() 315 WIN.fontT2K.lib = "javafx_font_t2k" 316 WIN.fontT2K.rcCompiler = rcCompiler; 317 WIN.fontT2K.rcSource = defaultRcSource 318 WIN.fontT2K.rcFlags = ["/d", "JFX_FNAME=javafx_font_t2k.dll", "/d", "JFX_INTERNAL_NAME=fontT2K", rcFlags].flatten(); 319 320 WIN.media = [:] 321 WIN.media.rcCompiler = rcCompiler 322 WIN.media.rcSource = defaultRcSource 323 WIN.media.glibRcFile = "glib-lite.res" 324 WIN.media.gstreamerRcFile = "gstreamer-lite.res" 325 WIN.media.fxpluginsRcFile = "fxplugins.res" 326 WIN.media.jfxmediaRcFile = "jfxmedia.res" 327 WIN.media.glibRcFlags = ["/d", "JFX_FNAME=glib-lite.dll", "/d", "JFX_INTERNAL_NAME=glib", rcFlags].flatten() 328 WIN.media.gstreamerRcFlags = ["/d", "JFX_FNAME=gstreamer-lite.dll", "/d", "JFX_INTERNAL_NAME=gstreamer", rcFlags].flatten() 329 WIN.media.fxpluginsRcFlags = ["/d", "JFX_FNAME=fxplugins.dll", "/d", "JFX_INTERNAL_NAME=fxplugins", rcFlags].flatten() 330 WIN.media.jfxmediaRcFlags = ["/d", "JFX_FNAME=jfxmedia.dll", "/d", "JFX_INTERNAL_NAME=jfxmedia", rcFlags].flatten() 331 332 WIN.webkit = [:] 333 WIN.webkit.rcCompiler = rcCompiler 334 WIN.webkit.rcSource = defaultRcSource 335 WIN.webkit.rcFlags = ["/d", "JFX_FNAME=jfxwebkit.dll", "/d", "JFX_INTERNAL_NAME=webkit", rcFlags].flatten();