1 /* 2 * Copyright (c) 2013, 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 // Lambda for naming the generated libs 37 WIN.library = { name -> return "${name}.dll" as String } 38 39 WIN.libDest = "bin" 40 WIN.jfxrtJarExcludes = [ 41 "com/sun/glass/events/mac", 42 "com/sun/glass/ui/mac", 43 "com/sun/prism/es2/gl/mac", 44 //"com/sun/prism/null3d", // TODO This is used in dev builds but not the final sdk 45 46 "com/sun/glass/ui/gtk", 47 48 "com/sun/glass/ui/ios", 49 50 "com/sun/glass/ui/lens", 51 "com/sun/prism/es2/gl/eglfb", 52 "com/sun/prism/es2/gl/eglx11", 53 "com/sun/prism/es2/gl/x11", 54 "com/sun/prism/es2/EGL*", 55 "com/sun/prism/es2/IOSGL*", 56 "com/sun/prism/es2/MacGL*", 57 "com/sun/prism/es2/X11GL*", 58 ] 59 60 def ccFlags = ["/nologo", "/W3", "/EHsc", "/c", 61 "/D_STATIC_CPPLIB", "/D_DISABLE_DEPRECATE_STATIC_CPPLIB", "/DINLINE=__inline", 62 "/DUNICODE", "/D_UNICODE", "/DWIN32", "/DIAL", "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", 63 "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", 64 IS_DEBUG_NATIVE ? ["/MDd", "/Od", "/Zi", "/DDEBUG"] : ["/O2", "/MD"]].flatten(); 65 66 def linkFlags = ["/nologo", "/dll", "/manifest", "/opt:REF", "/incremental:no"]; 67 if (IS_DEBUG_NATIVE) linkFlags.add("/debug"); 68 69 setupTools("windows_tools", 70 { propFile -> 71 // Create the properties file 72 ByteArrayOutputStream results = new ByteArrayOutputStream(); 73 String winsdkDir = System.getenv().get("WINSDK_DIR"); 74 exec({ 75 environment([ 76 "WINSDKPATH" : winsdkDir == null ? "" : winsdkDir, 77 "CONF" : "/$CONF", // TODO does this mean the generated properties must be reset when in a different configuration? 78 "VCARCH" : IS_64 ? "amd64" : "x86", 79 "SDKARCH" : IS_64 ? "/x64" : "/x86", 80 ]); 81 commandLine("cmd", "/q", "/c", "buildSrc\\genVSproperties.bat"); 82 setStandardOutput(results); 83 }); 84 BufferedReader reader = new BufferedReader(new StringReader(results.toString().trim())); 85 reader.readLine(); 86 reader.readLine(); 87 String line; 88 while ((line = reader.readLine()) != null && !line.startsWith("######")) { 89 line = line.replace("\\", "/").replace("/@@ENDOFLINE@@", "").replace("@@ENDOFLINE@@", "").replace("//", "/").replace("windows.vs.", "WINDOWS_VS_"); 90 propFile << line << "\r\n"; 91 } 92 }, 93 { properties -> 94 defineProperty("WINDOWS_VS_VSINSTALLDIR", properties, "c:/Program Files (x86)/Microsoft Visual Studio 10.0"); 95 defineProperty("WINDOWS_SDK_DIR", properties, System.getenv().get("WINSDK_DIR")) 96 defineProperty("WINDOWS_VS_VCINSTALLDIR", properties, "$WINDOWS_VS_VSINSTALLDIR/VC") 97 defineProperty("WINDOWS_VS_DEVENVDIR", properties, "$WINDOWS_VS_VSINSTALLDIR/Common7/IDE") 98 defineProperty("WINDOWS_VS_DEVENVCMD", properties, "$WINDOWS_VS_DEVENVDIR/VCExpress.exe") 99 defineProperty("WINDOWS_VS_MSVCDIR", properties, WINDOWS_VS_VCINSTALLDIR) 100 defineProperty("WINDOWS_DXSDK_DIR", properties, System.getenv().get("DXSDK_DIR")) 101 defineProperty("WINDOWS_VS_INCLUDE", properties, "$WINDOWS_VS_VCINSTALLDIR/INCLUDE;" + "$WINDOWS_SDK_DIR/include;") 102 defineProperty("WINDOWS_VS_VER", properties, "70") 103 defineProperty("WINDOWS_VS_LIB", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;" + "$WINDOWS_SDK_DIR/lib;") 104 defineProperty("WINDOWS_VS_LIBPATH", properties, "$WINDOWS_VS_VCINSTALLDIR/LIB;") 105 def parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : ""; 106 defineProperty("WINDOWS_VS_PATH", properties, parfaitPath + "$WINDOWS_VS_DEVENVDIR;" + 107 "$WINDOWS_VS_VSINSTALLDIR/VC/BIN;" + 108 "$WINDOWS_VS_VSINSTALLDIR/Common7/Tools;" + 109 "$WINDOWS_VS_VCINSTALLDIR/VCPackages;" + 110 "$WINDOWS_SDK_DIR/bin/NETFX 4.0 Tools;" + 111 "$WINDOWS_SDK_DIR/bin;" + 112 System.getenv().get("PATH")) 113 } 114 ) 115 116 WINDOWS_NATIVE_COMPILE_ENVIRONMENT = [ 117 "VCINSTALLDIR" : WINDOWS_VS_VCINSTALLDIR, 118 "VSINSTALLDIR" : WINDOWS_VS_VSINSTALLDIR, 119 "DEVENVDIR" : WINDOWS_VS_DEVENVDIR, 120 "MSVCDIR" : WINDOWS_VS_MSVCDIR, 121 "PATH" : WINDOWS_VS_PATH, 122 "INCLUDE" : WINDOWS_VS_INCLUDE, 123 "LIB" : WINDOWS_VS_LIB, 124 "LIBPATH" : WINDOWS_VS_LIBPATH, 125 "DXSDK_DIR" : WINDOWS_DXSDK_DIR 126 ]; 127 128 String msvcBinDir = (IS_64 129 ? "$WINDOWS_VS_VSINSTALLDIR/VC/BIN/amd64" 130 : "$WINDOWS_VS_VSINSTALLDIR/VC/BIN") 131 def compiler = IS_COMPILE_PARFAIT ? "cl.exe" : cygpath("$msvcBinDir/cl.exe") 132 def linker = IS_COMPILE_PARFAIT ? "link.exe" : cygpath("$msvcBinDir/link.exe") 133 ext.RC = cygpath("$WINDOWS_SDK_DIR/Bin/RC.Exe") 134 def rcCompiler = cygpath("$WINDOWS_SDK_DIR/Bin/RC.Exe") 135 ext.FXC = cygpath("$WINDOWS_DXSDK_DIR/utilities/bin/x86/fxc.exe") 136 ext.MC = cygpath("$WINDOWS_SDK_DIR/Bin/mt.exe") 137 // This next line is based on a line in the ant build scripts, but doesn't seem to point to the right place 138 //ext.MSVCR = cygpath("${WINDOWS_VS_MSVCDIR}/redist/${IS_64 ? 'x64' : 'x86'}/Microsoft.VC${WINDOWS_VS_VER}.CRT/msvcr${WINDOWS_VS_VER}.dll") 139 140 def rcFlags = [ 141 "/d", "\"JFX_COMPANY=${COMPANY_NAME}\"", 142 "/d", "\"JFX_COMPONENT=${PRODUCT_NAME} ${PLATFORM_NAME} binary\"", 143 "/d", "\"JFX_NAME=${PRODUCT_NAME} ${PLATFORM_NAME} ${jfxReleaseMajorVersion}\"", 144 "/d", "\"JFX_VER=${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseMicroVersion}.${PROMOTED_BUILD_NUMBER}\"", 145 "/d", "\"JFX_BUILD_ID=${RAW_VERSION}-${RELEASE_MILESTONE}-b${PROMOTED_BUILD_NUMBER}\"", 146 "/d", "\"JFX_COPYRIGHT=Copyright \u00A9 ${Calendar.getInstance().get(Calendar.YEAR)}\"", 147 "/d", "\"JFX_FVER=${jfxReleaseMajorVersion},${jfxReleaseMinorVersion},${jfxReleaseMicroVersion},${PROMOTED_BUILD_NUMBER}\"", 148 "/d", "\"JFX_FTYPE=0x2L\"", 149 "/nologo" 150 ]; 151 152 def defaultRcSource = file("modules/graphics/src/main/resources/version.rc"); 153 154 WIN.glass = [:] 155 WIN.glass.javahInclude = [ 156 "com/sun/glass/events/**", 157 "com/sun/glass/ui/*", 158 "com/sun/glass/ui/win/*"] 159 WIN.glass.nativeSource = file("modules/graphics/src/main/native-glass/win") 160 WIN.glass.compiler = compiler 161 WIN.glass.rcCompiler = rcCompiler; 162 WIN.glass.rcSource = file("modules/graphics/src/main/native-glass/win/GlassResources.rc"); 163 WIN.glass.rcFlags = [ 164 "/I", file("modules/graphics/src/main/resources"), 165 "/d", "JFX_FNAME=glass.dll", 166 "/d", "JFX_INTERNAL_NAME=glass", 167 rcFlags].flatten(); 168 WIN.glass.ccFlags = [ccFlags, "/WX"].flatten() 169 WIN.glass.linker = linker 170 WIN.glass.linkFlags = [linkFlags, "delayimp.lib", "gdi32.lib", "urlmon.lib", "Comdlg32.lib", 171 "winmm.lib", "imm32.lib", "shell32.lib", "Uiautomationcore.lib", "dwmapi.lib", 172 "/DELAYLOAD:user32.dll", "/DELAYLOAD:urlmon.dll", "/DELAYLOAD:winmm.dll", "/DELAYLOAD:shell32.dll", 173 "/DELAYLOAD:Uiautomationcore.dll", "/DELAYLOAD:dwmapi.dll"].flatten() 174 WIN.glass.lib = "glass" 175 176 WIN.decora = [:] 177 WIN.decora.compiler = compiler 178 WIN.decora.ccFlags = ["/arch:SSE", "/fp:fast", ccFlags].flatten() 179 WIN.decora.linker = linker 180 WIN.decora.linkFlags = [linkFlags].flatten() 181 WIN.decora.lib = "decora_sse" 182 WIN.decora.rcCompiler = rcCompiler; 183 WIN.decora.rcSource = defaultRcSource 184 WIN.decora.rcFlags = ["/d", "JFX_FNAME=decora_sse.dll", "/d", "JFX_INTERNAL_NAME=decora", rcFlags].flatten() 185 186 WIN.prism = [:] 187 WIN.prism.javahInclude = ["com/sun/prism/impl/**/*", "com/sun/prism/PresentableState*"] 188 WIN.prism.nativeSource = file("modules/graphics/src/main/native-prism") 189 WIN.prism.compiler = compiler 190 WIN.prism.ccFlags = [ccFlags].flatten() 191 WIN.prism.linker = linker 192 WIN.prism.linkFlags = [linkFlags].flatten() 193 WIN.prism.lib = "prism_common" 194 WIN.prism.rcCompiler = rcCompiler; 195 WIN.prism.rcSource = defaultRcSource 196 WIN.prism.rcFlags = ["/d", "JFX_FNAME=prism_common.dll", "/d", "JFX_INTERNAL_NAME=prism", rcFlags].flatten() 197 198 WIN.prismSW = [:] 199 WIN.prismSW.javahInclude = ["com/sun/pisces/**/*"] 200 WIN.prismSW.nativeSource = file("modules/graphics/src/main/native-prism-sw") 201 WIN.prismSW.compiler = compiler 202 WIN.prismSW.ccFlags = [ccFlags].flatten() 203 WIN.prismSW.linker = linker 204 WIN.prismSW.linkFlags = [linkFlags].flatten() 205 WIN.prismSW.lib = "prism_sw" 206 WIN.prismSW.rcCompiler = rcCompiler; 207 WIN.prismSW.rcSource = defaultRcSource 208 WIN.prismSW.rcFlags = ["/d", "JFX_FNAME=prism_sw.dll", "/d", "JFX_INTERNAL_NAME=prismSW", rcFlags].flatten() 209 210 WIN.prismD3D = [:] 211 WIN.prismD3D.javahInclude = ["com/sun/prism/d3d/**/*"] 212 WIN.prismD3D.nativeSource = [ 213 file("modules/graphics/src/main/native-prism-d3d"), 214 file("modules/graphics/src/main/native-prism-d3d/hlsl")] 215 WIN.prismD3D.compiler = compiler 216 WIN.prismD3D.ccFlags = [ccFlags, "/Ibuild/headers/PrismD3D"].flatten() 217 WIN.prismD3D.linker = linker 218 WIN.prismD3D.linkFlags = [linkFlags, "user32.lib"].flatten() 219 WIN.prismD3D.lib = "prism_d3d" 220 WIN.prismD3D.rcCompiler = rcCompiler; 221 WIN.prismD3D.rcSource = defaultRcSource 222 WIN.prismD3D.rcFlags = ["/d", "JFX_FNAME=prism_d3d.dll", "/d", "JFX_INTERNAL_NAME=prismD3D", rcFlags].flatten(); 223 224 WIN.launcher = [:] 225 WIN.launcher.compiler = compiler 226 WIN.launcher.ccFlags = ["/nologo", "/W3", "/EHsc", "/D_WINDOWS", "/DUNICODE", "/D_UNICODE", "/DWIN32", 227 "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", 228 "/arch:SSE", "/fp:fast", "/O2", "/MD"]; 229 WIN.launcher.linker = linker 230 WIN.launcher.linkFlags = ["/link", "/nologo", "/SUBSYSTEM:WINDOWS", "user32.lib", "shell32.lib", "advapi32.lib"] 231 232 WIN.iconLauncher = [:] 233 WIN.iconLauncher.compiler = compiler 234 WIN.iconLauncher.ccFlags = ["/nologo", "/W3", "/EHsc", "/D_WINDOWS", "/DUNICODE", "/D_UNICODE", 235 "/arch:SSE", "/fp:fast", "/O2"] 236 WIN.iconLauncher.linker = linker 237 WIN.iconLauncher.linkFlags = ["/link", "/nologo", "/SUBSYSTEM:CONSOLE"]; 238 239 WIN.fxpackager = [:] 240 WIN.fxpackager.nativeSource = [ 241 file("modules/fxpackager/src/main/native/javapackager/win")] 242 WIN.fxpackager.compiler = compiler 243 WIN.fxpackager.ccFlags = ["/nologo", "/W3", "/EHsc", "/MT", "/GS", 244 "/DWIN32", "/D_LITTLE_ENDIAN", "/DWIN32_LEAN_AND_MEAN", 245 "/D_WIN32_WINDOWS=0X0500", "/D_WIN32_WINNT=0X0500", 246 "/I$JDK_HOME/include", "/I$JDK_HOME/include/win32", "/arch:SSE", "/fp:fast", 247 "/O2", "-c"] 248 WIN.fxpackager.linker = linker 249 250 WIN.iio = [:] 251 WIN.iio.javahInclude = ["com/sun/javafx/iio/**/*"] 252 WIN.iio.nativeSource = [ 253 file("modules/graphics/src/main/native-iio"), 254 file("modules/graphics/src/main/native-iio/libjpeg7")] 255 WIN.iio.compiler = compiler 256 WIN.iio.ccFlags = [ccFlags].flatten() 257 WIN.iio.linker = linker 258 WIN.iio.linkFlags = [linkFlags].flatten() 259 WIN.iio.lib = "javafx_iio" 260 WIN.iio.rcCompiler = rcCompiler; 261 WIN.iio.rcSource = defaultRcSource 262 WIN.iio.rcFlags = ["/d", "JFX_FNAME=javafx_iio.dll", "/d", "JFX_INTERNAL_NAME=iio", rcFlags].flatten(); 263 264 WIN.prismES2 = [:] 265 WIN.prismES2.javahInclude = ["com/sun/prism/es2/**/*"] 266 WIN.prismES2.nativeSource = [ 267 file("modules/graphics/src/main/native-prism-es2"), 268 file("modules/graphics/src/main/native-prism-es2/GL"), 269 file("modules/graphics/src/main/native-prism-es2/windows") 270 ] 271 WIN.prismES2.compiler = compiler 272 WIN.prismES2.ccFlags = ["/Ob1", "/GF", "/Gy", "/GS", "/DWIN32", ccFlags].flatten() 273 WIN.prismES2.linker = linker 274 WIN.prismES2.linkFlags = [linkFlags, "/SUBSYSTEM:WINDOWS", "opengl32.lib", "gdi32.lib", "user32.lib", "kernel32.lib"].flatten() 275 WIN.prismES2.lib = "prism_es2" 276 WIN.prismES2.rcCompiler = rcCompiler; 277 WIN.prismES2.rcSource = defaultRcSource 278 WIN.prismES2.rcFlags = ["/d", "JFX_FNAME=prism_es2.dll", "/d", "JFX_INTERNAL_NAME=prismES2", rcFlags].flatten(); 279 280 def closedDir = file("$projectDir/../rt-closed") 281 WIN.font = [:] 282 WIN.font.javahInclude = [ 283 "com/sun/javafx/font/**/*", 284 "com/sun/javafx/text/**/*"] 285 WIN.font.nativeSource = [file("modules/graphics/src/main/native-font")] 286 WIN.font.compiler = compiler 287 WIN.font.ccFlags = ["/DJFXFONT_PLUS", ccFlags].flatten() 288 WIN.font.ccFlags -= ["/DUNICODE", "/D_UNICODE"] 289 WIN.font.linker = linker 290 WIN.font.linkFlags = [linkFlags, "advapi32.lib", "gdi32.lib", "user32.lib", "dwrite.lib", "d2d1.lib", "windowscodecs.lib", "ole32.lib"].flatten() 291 WIN.font.lib = "javafx_font" 292 WIN.font.rcCompiler = rcCompiler; 293 WIN.font.rcSource = defaultRcSource 294 WIN.font.rcFlags = ["/d", "JFX_FNAME=javafx_font.dll", "/d", "JFX_INTERNAL_NAME=font", rcFlags].flatten(); 295 296 WIN.fontT2K = [:] 297 WIN.fontT2K.javahInclude = ["com/sun/javafx/font/t2k/**/*"] 298 WIN.fontT2K.nativeSource = [ 299 file("$closedDir/javafx-font-t2k-native/src"), 300 file("$closedDir/javafx-font-t2k-native/src/layout")] 301 WIN.fontT2K.compiler = compiler 302 WIN.fontT2K.ccFlags = ["/DJFXFONT_PLUS", "/DLE_STANDALONE", ccFlags].flatten() 303 WIN.fontT2K.linker = linker 304 WIN.fontT2K.linkFlags = [linkFlags, "advapi32.lib", "gdi32.lib", "user32.lib"].flatten() 305 WIN.fontT2K.lib = "javafx_font_t2k" 306 WIN.fontT2K.rcCompiler = rcCompiler; 307 WIN.fontT2K.rcSource = defaultRcSource 308 WIN.fontT2K.rcFlags = ["/d", "JFX_FNAME=javafx_font_t2k.dll", "/d", "JFX_INTERNAL_NAME=fontT2K", rcFlags].flatten(); 309 310 WIN.media = [:] 311 WIN.media.rcCompiler = rcCompiler 312 WIN.media.rcSource = defaultRcSource 313 WIN.media.glibRcFile = "glib-lite.res" 314 WIN.media.gstreamerRcFile = "gstreamer-lite.res" 315 WIN.media.fxpluginsRcFile = "fxplugins.res" 316 WIN.media.jfxmediaRcFile = "jfxmedia.res" 317 WIN.media.glibRcFlags = ["/d", "JFX_FNAME=glib-lite.dll", "/d", "JFX_INTERNAL_NAME=glib", rcFlags].flatten() 318 WIN.media.gstreamerRcFlags = ["/d", "JFX_FNAME=gstreamer-lite.dll", "/d", "JFX_INTERNAL_NAME=gstreamer", rcFlags].flatten() 319 WIN.media.fxpluginsRcFlags = ["/d", "JFX_FNAME=fxplugins.dll", "/d", "JFX_INTERNAL_NAME=fxplugins", rcFlags].flatten() 320 WIN.media.jfxmediaRcFlags = ["/d", "JFX_FNAME=jfxmedia.dll", "/d", "JFX_INTERNAL_NAME=jfxmedia", rcFlags].flatten() 321 322 WIN.webkit = [:] 323 WIN.webkit.rcCompiler = rcCompiler 324 WIN.webkit.rcSource = defaultRcSource 325 WIN.webkit.rcFlags = ["/d", "JFX_FNAME=jfxwebkit.dll", "/d", "JFX_INTERNAL_NAME=webkit", rcFlags].flatten();