1 // FIXME: KCR SDK 2 /* 3 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. Oracle designates this 9 * particular file as subject to the "Classpath" exception as provided 10 * by Oracle in the LICENSE file that accompanied this code. 11 * 12 * This code is distributed in the hope that it will be useful, but WITHOUT 13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15 * version 2 for more details (a copy is included in the LICENSE file that 16 * accompanied this code). 17 * 18 * You should have received a copy of the GNU General Public License version 19 * 2 along with this work; if not, write to the Free Software Foundation, 20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 21 * 22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 23 * or visit www.oracle.com if you need additional information or have any 24 * questions. 25 */ 26 27 /** 28 * The main build script for JavaFX. 29 * 30 * MUST FIX tasks to complete: 31 * - build check -- making sure the final artifact has the right bits 32 * - some things worth automatically sanity checking: 33 * - are there images in the javadocs? 34 * - are all of the expected dylibs etc there? 35 * - Perform sanity checking to make sure a JDK exists with javac, javah, etc 36 * - Support building with no known JDK location, as long as javac, javah, etc are on the path 37 * - Check all of the native flags. We're adding weight to some libs that don't need it, and so forth. 38 * 39 * Additional projects to work on as we go: 40 * - Add "developer debug". This is where the natives do not have debug symbols, but the Java code does 41 * - The genVSproperties.bat doesn't find the directory where RC.exe lives. So it is hard coded. Might be a problem. 42 * - special tasks for common needs, such as: 43 * - updating copyright headers 44 * - stripping trailing whitespace (?) 45 * - checkstyle 46 * - findbugs 47 * - re needs? 48 * - sqe testing 49 * - API change check 50 * - Pushing results to a repo? 51 * - ServiceWithSecurityManagerTest fails to complete when run from gradle. 52 * - Integrate Parfait reports for C code 53 * - FXML Project tests are not running 54 */ 55 defaultTasks = ["sdk"] 56 57 import java.util.concurrent.CountDownLatch 58 import java.util.concurrent.ExecutorService 59 import java.util.concurrent.Executors 60 import java.util.concurrent.Future 61 62 /****************************************************************************** 63 * Utility methods * 64 *****************************************************************************/ 65 66 /** 67 * If the given named property is not defined, then this method will define 68 * it with the given defaultValue. Any properties defined by this method can 69 * be substituted on the command line by using -P, or by specifying a 70 * gradle.properties file in the user home dir 71 * 72 * @param name The name of the property to define 73 * @param defaultValue The default value to assign the property 74 */ 75 void defineProperty(String name, String defaultValue) { 76 if (!project.hasProperty(name)) { 77 project.ext.set(name, defaultValue); 78 } 79 } 80 81 /** 82 * If the given named property is not defined, then this method will attempt to 83 * look up the property in the props map, and use the defaultValue if it cannot be found. 84 * 85 * @param name The name of the property to look up and/or define 86 * @param props The properties to look for the named property in, if it has not already been defined 87 * @param defaultValue The default value if the property has not been defined and the 88 * props map does not contain the named property 89 */ 90 void defineProperty(String name, Properties props, String defaultValue) { 91 if (!project.hasProperty(name)) { 92 project.ext.set(name, props.getProperty(name, defaultValue)); 93 } 94 } 95 96 /** 97 * Converts cygwin style paths to windows style paths, but with a forward slash. 98 * This method is safe to call from any platform, and will only do work if 99 * called on Windows (in all other cases it simply returns the supplied path. 100 * 101 * @param path the path to convert 102 * @return the path converted to windows style, if on windows, otherwise it 103 * is the supplied path. 104 */ 105 String cygpath(String path) { 106 if (!IS_WINDOWS) return path; 107 if (path == null || "".equals(path)) return path; 108 String ret = path.replaceAll('\\\\', '/') 109 logger.info("Converting path '$path' via cygpath to "+ret) 110 return ret 111 } 112 113 void loadProperties(String sourceFileName) { 114 def config = new Properties() 115 def propFile = new File(sourceFileName) 116 if (propFile.canRead()) { 117 config.load(new FileInputStream(propFile)) 118 for (java.util.Map.Entry property in config) { 119 def keySplit = property.key.split("\\."); 120 def key = keySplit[0]; 121 for (int i = 1; i < keySplit.length; i++) { 122 key = key + keySplit[i].capitalize(); 123 } 124 ext[key] = property.value; 125 } 126 } 127 } 128 129 /** 130 * Struct used to contain some information passed to the closure 131 * passed to compileTargets. 132 */ 133 class CompileTarget { 134 String name; 135 String upper; 136 String capital; 137 } 138 139 /** 140 * Iterates over each of the compile targets, passing the given closure 141 * a CompileTarget instance. 142 * 143 * @param c The closure to call 144 */ 145 void compileTargets(Closure c) { 146 if (COMPILE_TARGETS == "") { 147 return 148 } 149 COMPILE_TARGETS.split(",").each { target -> 150 CompileTarget ct = new CompileTarget(); 151 ct.name = target; 152 ct.upper = target.trim().toUpperCase(Locale.ROOT) 153 ct.capital = target.trim().capitalize() 154 c(ct) 155 } 156 } 157 158 /** 159 * Manages the execution of some closure which is responsible for producing 160 * content for a properties file built at build time and stored in the 161 * root project's $buildDir, and then loading that properties file and 162 * passing it to the processor closure. 163 * 164 * This is used on windows to produce a properties file containing all the 165 * windows visual studio paths and environment variables, and on Linux 166 * for storing the results of pkg-config calls. 167 * 168 * @param name the name of the file to produce 169 * @param loader a closure which is invoked, given the properties file. This 170 * closure is invoked only if the properties file needs to be created 171 * and is responsible for populating the properties file. 172 * @param processor a closure which is invoked every time this method is 173 * called and which will be given a Properties object, fully populated. 174 * The processor is then responsible for doing whatever it is that it 175 * must do with those properties (such as setting up environment 176 * variables used in subsequent native builds, or whatnot). 177 */ 178 void setupTools(String name, Closure loader, Closure processor) { 179 // Check to see whether $buildDir/$name.properties file exists. If not, 180 // then generate it. Once generated, we need to read the properties file to 181 // help us define the defaults for this block of properties 182 File propFile = file("$buildDir/${name}.properties"); 183 if (!propFile.exists()) { 184 // Create the properties file 185 propFile.getParentFile().mkdirs(); 186 propFile.createNewFile(); 187 loader(propFile); 188 } 189 190 // Try reading the properties in order to define the properties. If the property file cannot 191 // be located, then we will throw an exception because we cannot guess these values 192 InputStream propStream = null; 193 try { 194 Properties properties = new Properties(); 195 propStream = new FileInputStream(propFile); 196 properties.load(propStream); 197 processor(properties); 198 } finally { 199 try { propStream.close() } catch (Exception e) { } 200 } 201 } 202 203 String[] parseJavaVersion(String jRuntimeVersion) { 204 def jVersion = jRuntimeVersion.split("[-\\+]")[0] 205 def tmpBuildNumber = "0" 206 if (jVersion.startsWith("1.")) { 207 // This is a pre-JEP-223 version string 208 def dashbIdx = jRuntimeVersion.lastIndexOf("-b") 209 if (dashbIdx != -1) { 210 tmpBuildNumber = jRuntimeVersion.substring(dashbIdx + 2) 211 } 212 } else { 213 // This is a post-JEP-223 version string 214 def plusIdx = jRuntimeVersion.indexOf("+") 215 if (plusIdx != -1) { 216 tmpBuildNumber = jRuntimeVersion.substring(plusIdx + 1) 217 } 218 } 219 def jBuildNumber = tmpBuildNumber.split("[-\\+]")[0] 220 def versionInfo = new String[2]; 221 versionInfo[0] = jVersion 222 versionInfo[1] = jBuildNumber 223 return versionInfo 224 } 225 226 /** 227 * Fails the build with the specified error message 228 * 229 * @param msg the reason for the failure 230 */ 231 void fail(String msg) { 232 throw new GradleException("FAIL: " + msg); 233 } 234 235 /****************************************************************************** 236 * * 237 * Definition of project properties * 238 * * 239 * All properties defined using ext. are immediately available throughout * 240 * the script as variables that can be used. These variables are attached * 241 * to the root project (whereas if they were defined as def variables then * 242 * they would only be available within the root project scope). * 243 * * 244 * All properties defined using the "defineProperty" method can be replaced * 245 * on the command line by using the -P flag. For example, to override the * 246 * location of the binary plug, you would specify -PBINARY_PLUG=some/where * 247 * * 248 *****************************************************************************/ 249 250 // If the ../rt-closed directory exists, then we are doing a closed build. 251 // In this case, build and property files will be read from 252 // ../rt-closed/closed-build.gradle and ../rt-closed/closed-properties.gradle 253 // respectively 254 255 def closedDir = file("../rt-closed") 256 def buildClosed = closedDir.isDirectory() 257 ext.BUILD_CLOSED = buildClosed 258 259 ext.RUNARGSFILE = "run.args" 260 ext.COMPILEARGSFILE = "compile.args" 261 262 ext.TESTCOMPILEARGSFILE = "testcompile.args" 263 ext.TESTRUNARGSFILE = "testrun.args" 264 ext.TESTJAVAPOLICYFILE = 'test.java.policy' 265 266 ext.MODULESOURCEPATH = "modulesourcepath.args" 267 268 // These variables indicate what platform is running the build. Is 269 // this build running on a Mac, Windows, or Linux machine? 32 or 64 bit? 270 ext.OS_NAME = System.getProperty("os.name").toLowerCase() 271 ext.OS_ARCH = System.getProperty("os.arch") 272 ext.IS_64 = OS_ARCH.toLowerCase().contains("64") 273 ext.IS_MAC = OS_NAME.contains("mac") || OS_NAME.contains("darwin") 274 ext.IS_WINDOWS = OS_NAME.contains("windows") 275 ext.IS_LINUX = OS_NAME.contains("linux") 276 277 // Verify that the architecture & OS are supported configurations. Note that 278 // at present building on PI is not supported, but we would only need to make 279 // some changes on assumptions on what should be built (like SWT / Swing) and 280 // such and we could probably make it work. 281 if (!IS_MAC && !IS_WINDOWS && !IS_LINUX) fail("Unsupported build OS ${OS_NAME}") 282 if (IS_WINDOWS && OS_ARCH != "x86" && OS_ARCH != "amd64") { 283 fail("Unknown and unsupported build architecture: $OS_ARCH") 284 } else if (IS_MAC && OS_ARCH != "x86_64") { 285 fail("Unknown and unsupported build architecture: $OS_ARCH") 286 } else if (IS_LINUX && OS_ARCH != "i386" && OS_ARCH != "amd64") { 287 fail("Unknown and unsupported build architecture: $OS_ARCH") 288 } 289 290 291 // Get the JDK_HOME automatically based on the version of Java used to execute gradle. Or, if specified, 292 // use a user supplied JDK_HOME, STUB_RUNTIME, JAVAC, all of which may be specified 293 // independently (or we'll try to get the right one based on other supplied info). Sometimes the 294 // JRE might be the thing that is being used instead of the JRE embedded in the JDK, such as: 295 // c:\Program Files (x86)\Java\jdk1.8.0\jre 296 // c:\Program Files (x86)\Java\jre8\ 297 // Because of this, you may sometimes get the jdk's JRE (in which case the logic we used to have here 298 // was correct and consistent with all other platforms), or it might be the standalone JRE (for the love!). 299 def envJavaHome = cygpath(System.getenv("JDK_HOME")) 300 if (envJavaHome == null || envJavaHome.equals("")) envJavaHome = cygpath(System.getenv("JAVA_HOME")) 301 def javaHome = envJavaHome == null || envJavaHome.equals("") ? System.getProperty("java.home") : envJavaHome 302 def javaHomeFile = file(javaHome) 303 defineProperty("JDK_HOME", 304 javaHomeFile.name == "jre" ? 305 javaHomeFile.getParent().toString() : 306 javaHomeFile.name.startsWith("jre") ? 307 new File(javaHomeFile.getParent(), "jdk1.${javaHomeFile.name.substring(3)}.0").toString() : 308 javaHome) // we have to bail and set it to something and this is as good as any! 309 ext.JAVA_HOME = JDK_HOME 310 311 defineProperty("JAVA", cygpath("$JDK_HOME/bin/java${IS_WINDOWS ? '.exe' : ''}")) 312 defineProperty("JAVAC", cygpath("$JDK_HOME/bin/javac${IS_WINDOWS ? '.exe' : ''}")) 313 defineProperty("JAVAH", cygpath("$JDK_HOME/bin/javah${IS_WINDOWS ? '.exe' : ''}")) 314 defineProperty("JAVADOC", cygpath("$JDK_HOME/bin/javadoc${IS_WINDOWS ? '.exe' : ''}")) 315 defineProperty("JDK_DOCS", "https://docs.oracle.com/javase/8/docs/api/") 316 defineProperty("JDK_JMODS", cygpath(System.getenv("JDK_JMODS")) ?: cygpath(System.getenv("JDK_HOME") + "/jmods")) 317 318 defineProperty("javaRuntimeVersion", System.getProperty("java.runtime.version")) 319 def javaVersionInfo = parseJavaVersion(javaRuntimeVersion) 320 defineProperty("javaVersion", javaVersionInfo[0]) 321 defineProperty("javaBuildNumber", javaVersionInfo[1]) 322 323 loadProperties("$projectDir/build.properties") 324 325 // Look for stub runtime in either JDK or modular-sdk dir layout 326 327 def String closedCacheStubRuntime = cygpath("$projectDir") + "/../caches/modular-sdk" 328 329 def String jdkStubRuntime = cygpath("$JDK_HOME") 330 331 defineProperty("STUB_RUNTIME", BUILD_CLOSED ? closedCacheStubRuntime : jdkStubRuntime) 332 333 def cachedStub = STUB_RUNTIME.equals(closedCacheStubRuntime) 334 335 if (cachedStub) { 336 def stubModulesLib = "$STUB_RUNTIME/modules_libs" 337 def dirSuffix = (IS_MAC || IS_WINDOWS) ? "" : "/$OS_ARCH" 338 defineProperty("MEDIA_STUB", "$stubModulesLib/javafx.media$dirSuffix") 339 defineProperty("WEB_STUB", "$stubModulesLib/javafx.web$dirSuffix") 340 } else { 341 def libraryStub = IS_MAC ? "$STUB_RUNTIME/lib" : 342 IS_WINDOWS ? "$STUB_RUNTIME/bin" : 343 "$STUB_RUNTIME/lib/$OS_ARCH" 344 345 defineProperty("MEDIA_STUB", libraryStub) 346 defineProperty("WEB_STUB", libraryStub) 347 } 348 349 defineProperty("UPDATE_STUB_CACHE", (cachedStub ? 'true' : 'false')) 350 351 def supplementalPreBuildFile = file("$closedDir/closed-pre-build.gradle"); 352 def supplementalBuildFile = file("$closedDir/closed-build.gradle"); 353 354 if (BUILD_CLOSED) { 355 apply from: supplementalPreBuildFile 356 } 357 358 // GRADLE_VERSION_CHECK specifies whether to fail the build if the 359 // gradle version check fails 360 defineProperty("GRADLE_VERSION_CHECK", "true") 361 ext.IS_GRADLE_VERSION_CHECK = Boolean.parseBoolean(GRADLE_VERSION_CHECK) 362 363 // COMPILE_WEBKIT specifies whether to build all of webkit. 364 defineProperty("COMPILE_WEBKIT", "false") 365 ext.IS_COMPILE_WEBKIT = Boolean.parseBoolean(COMPILE_WEBKIT) 366 367 // COMPILE_MEDIA specifies whether to build all of media. 368 defineProperty("COMPILE_MEDIA", "false") 369 ext.IS_COMPILE_MEDIA = Boolean.parseBoolean(COMPILE_MEDIA) 370 371 // COMPILE_PANGO specifies whether to build javafx_font_pango. 372 defineProperty("COMPILE_PANGO", "${IS_LINUX}") 373 ext.IS_COMPILE_PANGO = Boolean.parseBoolean(COMPILE_PANGO) 374 375 // COMPILE_HARFBUZZ specifies whether to use Harfbuzz. 376 defineProperty("COMPILE_HARFBUZZ", "false") 377 ext.IS_COMPILE_HARFBUZZ = Boolean.parseBoolean(COMPILE_HARFBUZZ) 378 379 // COMPILE_PARFAIT specifies whether to build parfait 380 defineProperty("COMPILE_PARFAIT", "false") 381 ext.IS_COMPILE_PARFAIT = Boolean.parseBoolean(COMPILE_PARFAIT) 382 383 // FIXME: update the default when using 9 (pre-jigsaw) as boot jdk 384 // COMPILE_JFR specifies whether to build code that logs to JRockit Flight Recorder 385 defineProperty("COMPILE_JFR", Boolean.toString(file("$JDK_HOME/jre/lib/jfr.jar").exists())) 386 ext.IS_COMPILE_JFR = Boolean.parseBoolean(COMPILE_JFR) 387 388 // BUILD_FXPACKAGER enables building the packager modules and native code 389 defineProperty("BUILD_FXPACKAGER", "true") 390 ext.IS_BUILD_FXPACKAGER = Boolean.parseBoolean(BUILD_FXPACKAGER) 391 392 // RETAIN_PACKAGER_TESTS specifies whether the tests in fxpackager should 393 // keep generated files instead of attempting to automatically delete them 394 defineProperty("RETAIN_PACKAGER_TESTS", "false") 395 ext.IS_RETAIN_PACKAGER_TESTS = Boolean.parseBoolean(RETAIN_PACKAGER_TESTS) 396 397 // TEST_PACKAGER_DMG whether tests that create DMG files via hdiutil 398 // should be run. On OSX 10.7 this tends to hang automated builds 399 defineProperty("TEST_PACKAGER_DMG", "false") 400 ext.IS_TEST_PACKAGER_DMG = Boolean.parseBoolean(TEST_PACKAGER_DMG) 401 402 // Define the SWT.jar that we are going to have to download during the build process based 403 // on what platform we are compiling from (not based on our target). 404 ext.SWT_FILE_NAME = IS_MAC ? "org.eclipse.swt.cocoa.macosx.x86_64_3.7.2.v3740f" : 405 IS_WINDOWS && IS_64 ? "org.eclipse.swt.win32.win32.x86_64_3.7.2.v3740f" : 406 IS_WINDOWS && !IS_64 ? "org.eclipse.swt.win32.win32.x86_3.7.2.v3740f" : 407 IS_LINUX && IS_64 ? "org.eclipse.swt.gtk.linux.x86_64_3.7.2.v3740f" : 408 IS_LINUX && !IS_64 ? "org.eclipse.swt.gtk.linux.x86_3.7.2.v3740f" : "" 409 410 // Build javadocs only if BUILD_JAVADOC=true 411 defineProperty("BUILD_JAVADOC", "false") 412 ext.IS_BUILD_JAVADOC = Boolean.parseBoolean(BUILD_JAVADOC) 413 414 // Specifies whether to build the javafx-src bundle 415 defineProperty("BUILD_SRC_ZIP", "false") 416 ext.IS_BUILD_SRC_ZIP = Boolean.parseBoolean(BUILD_SRC_ZIP) 417 418 // Specifies whether to build the javafx-exports bundle 419 defineProperty("BUILD_MODULE_ZIP", "true") 420 ext.IS_BUILD_MODULE_ZIP = Boolean.parseBoolean(BUILD_MODULE_ZIP) 421 422 // Specifies whether to run full tests (true) or smoke tests (false) 423 defineProperty("FULL_TEST", "false") 424 ext.IS_FULL_TEST = Boolean.parseBoolean(FULL_TEST); 425 426 defineProperty("FORCE_TESTS", "false") 427 ext.IS_FORCE_TESTS = Boolean.parseBoolean(FORCE_TESTS); 428 429 // Specifies whether to run robot-based visual tests (only used when FULL_TEST is also enabled) 430 defineProperty("USE_ROBOT", "false") 431 ext.IS_USE_ROBOT = Boolean.parseBoolean(USE_ROBOT); 432 433 // Specified whether to run tests in headless mode 434 defineProperty("HEADLESS_TEST", "false") 435 ext.IS_HEADLESS_TEST = Boolean.parseBoolean(HEADLESS_TEST); 436 437 // Specifies whether to run system tests that depend on AWT (only used when FULL_TEST is also enabled) 438 defineProperty("AWT_TEST", "true") 439 ext.IS_AWT_TEST = Boolean.parseBoolean(AWT_TEST); 440 441 // Specifies whether to run system tests that depend on SWT (only used when FULL_TEST is also enabled) 442 defineProperty("SWT_TEST", "true") 443 ext.IS_SWT_TEST = Boolean.parseBoolean(SWT_TEST); 444 445 // Specifies whether to run unstable tests (true) - tests that don't run well with Hudson builds 446 // These tests should be protected with : 447 // assumeTrue(Boolean.getBoolean("unstable.test")); 448 defineProperty("UNSTABLE_TEST", "false") 449 ext.IS_UNSTABLE_TEST = Boolean.parseBoolean(UNSTABLE_TEST); 450 451 // Toggle diagnostic output from the Gradle workaround and the Sandbox test apps. 452 defineProperty("WORKER_DEBUG", "false") 453 ext.IS_WORKER_DEBUG = Boolean.parseBoolean(WORKER_DEBUG); 454 455 // Specify the build configuration (Release, Debug, or DebugNative) 456 defineProperty("CONF", "Debug") 457 ext.IS_DEBUG_JAVA = CONF == "Debug" || CONF == "DebugNative" 458 ext.IS_DEBUG_NATIVE = CONF == "DebugNative" 459 460 // Defines the compiler warning levels to use. If empty, then no warnings are generated. If 461 // not empty, then the expected syntax is as a space or comma separated list of names, such 462 // as defined in the javac documentation. 463 defineProperty("LINT", "none") 464 ext.IS_LINT = LINT != "none" 465 466 defineProperty("DOC_LINT", "none") 467 ext.IS_DOC_LINT = DOC_LINT != "none" 468 469 // Specifies whether to use the "useDepend" option when compiling Java sources 470 defineProperty("USE_DEPEND", "true") 471 ext.IS_USE_DEPEND = Boolean.parseBoolean(USE_DEPEND) 472 473 // Specifies whether to use the "incremental" option when compiling Java sources 474 defineProperty("INCREMENTAL", "false") 475 ext.IS_INCREMENTAL = Boolean.parseBoolean(INCREMENTAL) 476 477 // Specifies whether to include the Null3D pipeline (for perf debugging) 478 defineProperty("INCLUDE_NULL3D", "false") 479 ext.IS_INCLUDE_NULL3D = Boolean.parseBoolean(INCLUDE_NULL3D) 480 481 // Specifies whether to include the ES2 pipeline if available 482 defineProperty("INCLUDE_ES2", IS_WINDOWS ? "false" : "true") 483 ext.IS_INCLUDE_ES2 = Boolean.parseBoolean(INCLUDE_ES2) 484 485 // Specifies whether to generate code coverage statistics when running tests 486 defineProperty("JCOV", "false") 487 ext.DO_JCOV = Boolean.parseBoolean(JCOV) 488 489 // Define the number of threads to use when compiling (specifically for native compilation) 490 // On Mac we limit it to 1 by default due to problems running gcc in parallel 491 if (IS_MAC) { 492 defineProperty("NUM_COMPILE_THREADS", "1") 493 } else { 494 defineProperty("NUM_COMPILE_THREADS", "${Runtime.runtime.availableProcessors()}") 495 } 496 497 // 498 // The next three sections of properties are used to generate the 499 // VersionInfo class, and the Windows DLL manifest. 500 // 501 502 // The following properties should be left alone by developers and set only from Hudson. 503 defineProperty("HUDSON_JOB_NAME", "not_hudson") 504 defineProperty("HUDSON_BUILD_NUMBER","0000") 505 defineProperty("PROMOTED_BUILD_NUMBER", "0") 506 507 // The following properties define the product name for Oracle JDK and OpenJDK 508 // for VersionInfo and the DLL manifest. 509 if (BUILD_CLOSED) { 510 defineProperty("PRODUCT_NAME", "Java(TM)") 511 defineProperty("COMPANY_NAME", "Oracle Corporation") 512 defineProperty("PLATFORM_NAME", "Platform SE") 513 } else { 514 defineProperty("PRODUCT_NAME", "OpenJFX") 515 defineProperty("COMPANY_NAME", "N/A") 516 defineProperty("PLATFORM_NAME", "Platform") 517 } 518 519 // The following properties are set based on properties defined in 520 // build.properties. The release version and suffix should be updated 521 // in that file. 522 def relVer = 0 523 if (jfxReleasePatchVersion == "0") { 524 if (jfxReleaseSecurityVersion == "0") { 525 if (jfxReleaseMinorVersion == "0") { 526 relVer = "${jfxReleaseMajorVersion}" 527 } else { 528 relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}" 529 } 530 } else { 531 relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}" 532 } 533 } else { 534 relVer = "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}" 535 } 536 defineProperty("RELEASE_VERSION", relVer) 537 defineProperty("RELEASE_VERSION_PADDED", "${jfxReleaseMajorVersion}.${jfxReleaseMinorVersion}.${jfxReleaseSecurityVersion}.${jfxReleasePatchVersion}") 538 539 def buildDate = new java.util.Date() 540 def buildTimestamp = new java.text.SimpleDateFormat("yyyy-MM-dd-HHmmss").format(buildDate) 541 defineProperty("BUILD_TIMESTAMP", buildTimestamp) 542 def relSuffix = "" 543 def relOpt = "" 544 if (HUDSON_JOB_NAME == "not_hudson") { 545 relSuffix = "-internal" 546 relOpt = "-${buildTimestamp}" 547 } else { 548 relSuffix = jfxReleaseSuffix 549 } 550 defineProperty("RELEASE_SUFFIX", relSuffix) 551 defineProperty("RELEASE_VERSION_SHORT", "${RELEASE_VERSION}${RELEASE_SUFFIX}") 552 defineProperty("RELEASE_VERSION_LONG", "${RELEASE_VERSION_SHORT}+${PROMOTED_BUILD_NUMBER}${relOpt}") 553 554 // Check whether the COMPILE_TARGETS property has been specified (if so, it was done by 555 // the user and not by this script). If it has not been defined then default 556 // to building the normal desktop build for this machine 557 project.ext.set("defaultHostTarget", IS_MAC ? "mac" : IS_WINDOWS ? "win" : IS_LINUX ? "linux" : ""); 558 defineProperty("COMPILE_TARGETS", "$defaultHostTarget") 559 560 // Flag indicating whether to import cross compile tools 561 def importCrossTools = BUILD_CLOSED ? true : false; 562 if (!importCrossTools && hasProperty("IMPORT_CROSS_TOOLS")) { 563 importCrossTools = Boolean.parseBoolean(IMPORT_CROSS_TOOLS); 564 } 565 ext.IS_IMPORT_CROSS_TOOLS = importCrossTools 566 567 // Location of the cross compile tools 568 def crossToolsDir = "../crosslibs" 569 if (hasProperty("CROSS_TOOLS_DIR")) { 570 crossToolsDir = CROSS_TOOLS_DIR 571 } 572 ext.CROSS_TOOLS_DIR = file(crossToolsDir) 573 574 // Specifies whether to run tests with the existing javafx.* modules instead of compiling a new one 575 defineProperty("BUILD_SDK_FOR_TEST", "true") 576 ext.DO_BUILD_SDK_FOR_TEST = Boolean.parseBoolean(BUILD_SDK_FOR_TEST) 577 578 // All "classes" and "jar" tasks and their dependencies would be disabled 579 // when running with DO_BUILD_SDK_FOR_TEST=false as they're unneeded for running tests 580 if (!DO_BUILD_SDK_FOR_TEST) { 581 gradle.taskGraph.useFilter({ task -> !task.name.equals("classes") && !task.name.equals("jar") }) 582 } 583 584 /** 585 * Fetch/Check that external tools are present for the build. This method 586 * will conditionally download the packages from project defined ivy repositories 587 * and unpack them into the specified destdir 588 * 589 * @param configName A unique name to distinguish the configuration (ie "ARMSFV6") 590 * @param packages A list of required packages (with extensions .tgz, .zip) 591 * @param destdir where the packages should be unpacked 592 * @param doFetch if true, the named packages will be download 593 */ 594 void fetchExternalTools(String configName, List packages, File destdir, boolean doFetch) { 595 if (doFetch) { 596 // create a unique configuration for this fetch 597 def String fetchToolsConfig = "fetchTools$configName" 598 rootProject.configurations.create(fetchToolsConfig) 599 600 def List<String> fetchedPackages = [] 601 def int fetchCount = 0 602 603 packages.each { pkgname-> 604 def int dotdex = pkgname.lastIndexOf('.') 605 def int dashdex = pkgname.lastIndexOf('-') 606 def String basename = pkgname.substring(0,dashdex) 607 def String ver = pkgname.substring(dashdex+1,dotdex) 608 def String ext = pkgname.substring(dotdex+1) 609 def File pkgdir = file("$destdir/$basename-$ver") 610 611 if (!pkgdir.isDirectory()) { 612 rootProject.dependencies.add(fetchToolsConfig, "javafx:$basename:$ver", { 613 artifact { 614 name = basename 615 version = ver 616 type = ext 617 } 618 }) 619 println "adding $pkgname as a downloadable item did not find $pkgdir" 620 fetchedPackages.add(pkgname) 621 fetchCount++ 622 } 623 } 624 625 //fetch all the missing packages 626 if (fetchedPackages.size > 0) { 627 destdir.mkdirs() 628 629 logger.quiet "fetching missing packages $fetchedPackages" 630 copy { 631 from rootProject.configurations[fetchToolsConfig] 632 into destdir 633 } 634 635 // unpack the fetched packages 636 fetchedPackages.each { pkgname-> 637 logger.quiet "expanding the package $pkgname" 638 def srcball = file("${destdir}/${pkgname}") 639 640 if (!srcball.exists()) { 641 throw new GradleException("Failed to fetch $pkgname"); 642 } 643 644 def String basename = pkgname.substring(0,pkgname.lastIndexOf(".")) 645 def File pkgdir = file("$destdir/$basename") 646 647 if (pkgname.endsWith(".tgz")) { 648 if (IS_LINUX || IS_MAC) { 649 // use native tar to support symlinks 650 pkgdir.mkdirs() 651 exec { 652 workingDir pkgdir 653 commandLine "tar", "zxf", "${srcball}" 654 } 655 } else { 656 copy { 657 from tarTree(resources.gzip("${srcball}")) 658 into pkgdir 659 } 660 } 661 } else if (pkgname.endsWith(".zip")) { 662 copy { 663 from zipTree("${srcball}") 664 into pkgdir 665 } 666 } else { 667 throw new GradleException("Unhandled package type for compile package ${pkgname}") 668 } 669 srcball.deleteOnExit(); 670 } 671 } else { 672 logger.quiet "all tool packages are present $packages" 673 } 674 } else { // !doFetch - so just check they are present 675 // check that all the dirs are really there 676 def List<String> errors = [] 677 packages.each { pkgname-> 678 def String basename = pkgname.substring(0,pkgname.lastIndexOf(".")) 679 def File pkgdir = file("$destdir/$basename") 680 681 if (!pkgdir.isDirectory()) { 682 errors.add(pkgname) 683 } 684 } 685 if (errors.size > 0) { 686 throw new GradleException("Error: missing tool packages: $errors") 687 } else { 688 logger.quiet "all tool packages are present $packages" 689 } 690 } 691 } 692 693 // Make an forked ANT call. 694 // This needs to be forked so that ant can be used with the right JDK and updated modules 695 // for testing obscure things like packaging of apps 696 void ant(String conf, // platform configuration 697 String dir, // directory to run from 698 String target, // ant target 699 List<String> params // parameters (usually -Dxxx=yyy) 700 ) { 701 // Try to use ANT_HOME 702 String antHomeEnv = System.getenv("ANT_HOME") 703 String antHome = antHomeEnv != null ? cygpath(antHomeEnv) : null; 704 String ant = (antHome != null && !antHome.equals("")) ? "$antHome/bin/ant" : "ant"; 705 706 exec { 707 workingDir = dir 708 environment("JDK_HOME", JDK_HOME) 709 environment("JAVA_HOME", JDK_HOME) 710 if (IS_WINDOWS) { 711 environment([ 712 "VCINSTALLDIR" : WINDOWS_VS_VCINSTALLDIR, 713 "VSINSTALLDIR" : WINDOWS_VS_VSINSTALLDIR, 714 "DEVENVDIR" : WINDOWS_VS_DEVENVDIR, 715 "MSVCDIR" : WINDOWS_VS_MSVCDIR, 716 "INCLUDE" : WINDOWS_VS_INCLUDE, 717 "LIB" : WINDOWS_VS_LIB, 718 "LIBPATH" : WINDOWS_VS_LIBPATH, 719 "DXSDK_DIR" : WINDOWS_DXSDK_DIR 720 ]); 721 commandLine "cmd", "/c", ant, "-Dbuild.compiler=javac1.7" 722 } else { 723 commandLine ant, "-Dbuild.compiler=javac1.7" 724 } 725 if ((conf != null) && !rootProject.defaultHostTarget.equals(conf)) { 726 def targetProperties = rootProject.ext[t.trim().toUpperCase()] 727 args("-Dcross.platform=$conf") 728 if (targetProperties.containsKey('arch')) { 729 args("-Dcross.platform.arch=${targetProperties.arch}") 730 } 731 } 732 if (params != null) { 733 params.each() { s-> 734 args(s) 735 } 736 } 737 args(target); 738 } 739 } 740 741 List<String> computeLibraryPath(boolean working) { 742 List<String> lp = [] 743 List<String> modsWithNative = [ 'graphics', 'media', 'web' ] 744 745 // the build/modular-sdk area 746 def platformPrefix = "" 747 def modularSdkDirName = "${platformPrefix}modular-sdk" 748 def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}" 749 def modulesLibsDir = "${modularSdkDir}/modules_libs" 750 String suffix = "" 751 752 if (!HOST_MODULES_ARCH.equals("")) { 753 suffix = "/${HOST_MODULES_ARCH}" 754 } 755 756 757 modsWithNative.each() { m -> 758 lp << cygpath("${modulesLibsDir}/javafx.${m}${suffix}") 759 } 760 return lp 761 } 762 763 // Return list with the arguments needed for --patch-module for the provided projects 764 // used with Java executables ie. tests 765 List<String> computePatchModuleArgs(List<String> deps, boolean test) { 766 List<String> pma = [] 767 768 deps.each {String projname -> 769 def proj = project(projname) 770 if (proj.hasProperty("moduleName")) { 771 File dir = proj.sourceSets.main.output.classesDir 772 if (test && proj.sourceSets.hasProperty('shims')) { 773 dir = proj.sourceSets.shims.output.classesDir 774 } 775 String moduleName = proj.ext.moduleName 776 String dirpath = cygpath("${dir}/${moduleName}") 777 pma += "--patch-module=${moduleName}=${dirpath}" 778 } 779 } 780 781 pma += "-Djava.library.path=" + computeLibraryPath(true).join(File.pathSeparator) 782 783 return pma 784 } 785 786 // Return a list containing the --upgrade-module-path 787 // used with Javac 788 List<String> computeModulePathArgs(String pname, List<String> deps, boolean test) { 789 List<String> mpa = [ '--upgrade-module-path' ] 790 String mp = null 791 deps.each {String projname -> 792 def proj = project(projname) 793 // for a non test set of args, we don't want the current module in the list 794 // for a test test, we do need it to update what we built 795 796 if (proj.hasProperty("moduleName") && 797 proj.buildModule && 798 !(!test && proj.name.equals(pname))) { 799 File dir; 800 if (test && proj.sourceSets.hasProperty('shims')) { 801 dir = new File(proj.sourceSets.shims.output.classesDir, proj.ext.moduleName); 802 } else { 803 dir = new File(proj.sourceSets.main.output.classesDir, proj.ext.moduleName); 804 } 805 if (mp == null) { 806 mp = dir.path 807 } else { 808 mp = mp + File.pathSeparator + dir.path 809 } 810 } 811 } 812 813 // in some cases like base we could end up with an empty 814 // path... make sure we don't pass one back 815 if (mp == null) { 816 return null 817 } 818 819 mpa += mp 820 return mpa 821 } 822 823 void writeCompileArgsFile(File dest, List<String>path) { 824 dest.delete() 825 826 logger.info("Creating file ${dest.path}") 827 dest << "--upgrade-module-path\n" 828 829 dest << "\"\\\n" 830 path.each() { e-> 831 dest << " " 832 dest << cygpath(e) 833 dest << File.pathSeparator 834 dest << "\\\n" 835 } 836 dest << "\"\n" 837 } 838 839 void writeRunArgsFile(File dest, List<String> libpath, List<String> modpath) { 840 841 dest.delete() 842 843 logger.info("Creating file ${dest.path}") 844 845 dest << "-Djava.library.path=\"\\\n" 846 libpath.each() { e-> 847 dest << " " 848 dest << e 849 dest << File.pathSeparator 850 dest << "\\\n" 851 } 852 dest << " \"\n" 853 854 modpath.each { e -> 855 dest << "--patch-module \"" 856 dest << e 857 dest << "\"\n" 858 } 859 } 860 861 // perform common project manipulation for modules 862 void commonModuleSetup(Project p, List<String> moduleChain) { 863 864 p.ext.moduleChain = moduleChain 865 866 if (p.hasProperty("moduleName")) { 867 p.ext.moduleDir = new File (p.sourceSets.main.output.classesDir, "${p.moduleName}") 868 } 869 870 def mpa = computeModulePathArgs(p.name, moduleChain, false) 871 if (mpa != null) { 872 p.ext.modulePathArgs = mpa 873 } 874 875 p.ext.testModulePathArgs = computeModulePathArgs(p.name, moduleChain, true) 876 p.ext.patchModuleArgs = computePatchModuleArgs(moduleChain ,false) 877 p.ext.testPatchModuleArgs = computePatchModuleArgs(moduleChain, true) 878 879 moduleChain.each() {e -> 880 if (!e.equals(p.name)) { 881 p.compileJava.dependsOn(project(e).classes) 882 p.compileTestJava.dependsOn(project(e).testClasses) 883 } 884 } 885 886 // read in any addExports file 887 File addExportsFile = new File(p.projectDir,"src/test/addExports") 888 if (addExportsFile.exists()) { 889 List<String> ae = [] 890 addExportsFile.eachLine { line -> 891 line = line.trim() 892 if (!(line.startsWith("#") || line.equals(""))) { 893 // one line arguments are a bit easier to debug 894 //if (line.startsWith('--add-exports ')) { 895 // line = line.replaceFirst('--add-exports ', '--add-exports=') 896 //} 897 line = line.replace('--add-exports *', '--add-exports=') 898 ae += line.split(' ') 899 } 900 } 901 p.ext.addExports = ae.flatten() 902 } 903 } 904 905 // Now we need to define the native compilation tasks. The set of parameters to 906 // native compilation depends on the target platform (and also to some extent what platform 907 // you are compiling on). These settings are contained in various gradle files 908 // such as mac.gradle and linux.gradle and armhf.gradle. Additionally, the developer 909 // can specify COMPILE_FLAGS_FILE to be a URL or path to a different gradle file 910 // that will contain the appropriate flags. 911 defineProperty("COMPILE_FLAGS_FILES", COMPILE_TARGETS.split(",").collect {"buildSrc/${it.trim()}.gradle"}.join(",")) 912 if (COMPILE_TARGETS == "all") { 913 def tmp = [] 914 File buildSrcDir = file("buildSrc") 915 buildSrcDir.listFiles().each { File f -> 916 if (f.isFile() && f.name.endsWith(".gradle") && !f.name.equals("build.gradle")) { 917 def target = f.name.substring(0, f.name.lastIndexOf('.gradle')).toUpperCase(Locale.ROOT) 918 apply from: f 919 if (project.ext["${target}"].canBuild) { 920 tmp.add(target) 921 } 922 } 923 } 924 COMPILE_FLAGS_FILES = tmp.collect { "buildSrc/${it}.gradle"}.join(",") 925 COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",") 926 } else { 927 COMPILE_FLAGS_FILES.split(",").each { 928 logger.info("Applying COMPILE_FLAGS_FILE '$it'") 929 apply from: it 930 } 931 } 932 933 if (COMPILE_TARGETS != "") { 934 def tmp = [] 935 COMPILE_TARGETS.split(",").each {target -> 936 if (project.ext["${target.toUpperCase(Locale.ROOT)}"].canBuild) { 937 tmp.add(target) 938 } 939 } 940 COMPILE_TARGETS = tmp.collect { "${it.toLowerCase()}"}.join(",") 941 } 942 943 // Sanity check the expected properties all exist 944 compileTargets { t -> 945 // Every platform must define these variables 946 if (!project.hasProperty(t.upper)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${t.name} property") 947 def props = project.ext[t.upper]; 948 // FIXME: KCR -- remove libDest in favor of modLibDest 949 ["compileSwing", "compileSWT", "compileFXPackager", "libDest"].each { prop -> 950 if (!props.containsKey(prop)) throw new Exception("ERROR: Incorrectly configured compile flags file, missing ${prop} property on ${t.name}") 951 } 952 } 953 954 // Various build flags may be set by the different target files, such as 955 // whether to build Swing, SWT, FXPackager, etc. We iterate over all 956 // compile targets and look for these settings in our properties. Note that 957 // these properties cannot be set from the command line, but are set by 958 // the target build files such as armv6hf.gradle or mac.gradle. 959 ext.COMPILE_SWING = false; 960 ext.COMPILE_SWT = false; 961 ext.COMPILE_FXPACKAGER = false; 962 compileTargets { t -> 963 def targetProperties = project.rootProject.ext[t.upper] 964 965 if (targetProperties.compileSwing) COMPILE_SWING = true 966 if (targetProperties.compileSWT) COMPILE_SWT = true 967 if (IS_BUILD_FXPACKAGER && targetProperties.compileFXPackager) COMPILE_FXPACKAGER = true 968 969 if (!targetProperties.containsKey('compileWebnodeNative')) { 970 // unless specified otherwise, we will compile native Webnode if IS_COMPILE_WEBKIT 971 targetProperties.compileWebnodeNative = true 972 } 973 974 if (!targetProperties.containsKey('compileMediaNative')) { 975 // unless specified otherwise, we will compile native Media if IS_COMPILE_MEDIA 976 targetProperties.compileMediaNative = true 977 } 978 979 if (!targetProperties.containsKey('includeSWT')) targetProperties.includeSWT = true 980 if (!targetProperties.containsKey('includeSwing')) targetProperties.includeSwing = true 981 if (!targetProperties.containsKey('includeNull3d')) targetProperties.includeNull3d = true 982 if (!targetProperties.containsKey('includeLens')) targetProperties.includeLens = false 983 if (!targetProperties.containsKey('includeMonocle')) targetProperties.includeMonocle = false 984 if (!targetProperties.containsKey('includeEGL')) targetProperties.includeEGL = false 985 986 if (!targetProperties.containsKey('includeGTK')) targetProperties.includeGTK = IS_LINUX 987 988 if (!targetProperties.containsKey('modLibDest')) targetProperties.modLibDest = targetProperties.libDest 989 990 if (!targetProperties.containsKey('modulesArch')) targetProperties.modulesArch = "" 991 992 // This value is used as a prefix for various directories under ./build, 993 // such as sdk, to allow for a common name for the hosted build 994 // (for use when building apps) and a unique name for cross builds. 995 if (rootProject.defaultHostTarget.equals(t.name)) { 996 // use a simple common default for the "host" build 997 targetProperties.platformPrefix="" 998 rootProject.ext.HOST_MODULES_ARCH = targetProperties.modulesArch 999 } else { 1000 // and a more complex one for cross builds 1001 targetProperties.platformPrefix="${t.name}-" 1002 } 1003 } 1004 1005 /****************************************************************************** 1006 * * 1007 * Build Setup Sanity Checks * 1008 * * 1009 * Here we do a variety of checks so that if the version of Java you are * 1010 * building with is misconfigured, or you are using the wrong version of * 1011 * gradle, etc you will get some kind of helpful error / warning message * 1012 * * 1013 *****************************************************************************/ 1014 1015 // Sanity check that we actually have a list of compile targets to execute 1016 if (COMPILE_TARGETS == null || COMPILE_TARGETS == "") { 1017 throw new Exception("Unable to determine compilation platform, must specify valid COMPILE_TARGETS!") 1018 } 1019 1020 // Make sure JDK_HOME/bin/java exists 1021 if (!file(JAVA).exists()) throw new Exception("Missing or incorrect path to 'java': '$JAVA'. Perhaps bad JDK_HOME? $JDK_HOME") 1022 if (!file(JAVAC).exists()) throw new Exception("Missing or incorrect path to 'javac': '$JAVAC'. Perhaps bad JDK_HOME? $JDK_HOME") 1023 if (!file(JAVAH).exists()) throw new Exception("Missing or incorrect path to 'javah': '$JAVAH'. Perhaps bad JDK_HOME? $JDK_HOME") 1024 if (!file(JAVADOC).exists()) throw new Exception("Missing or incorrect path to 'javadoc': '$JAVADOC'. Perhaps bad JDK_HOME? $JDK_HOME") 1025 1026 // Determine the verion of Java in JDK_HOME. It looks like this: 1027 // 1028 // $ java -version 1029 // java version "1.7.0_45" 1030 // Java(TM) SE Runtime Environment (build 1.7.0_45-b18) 1031 // Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) 1032 // 1033 // We need to parse the second line 1034 def inStream = new java.io.BufferedReader(new java.io.InputStreamReader(new java.lang.ProcessBuilder(JAVA, "-fullversion").start().getErrorStream())); 1035 try { 1036 String v = inStream.readLine().trim(); 1037 if (v != null) { 1038 int ib = v.indexOf("full version \""); 1039 if (ib != -1) { 1040 String str = v.substring(ib); 1041 String ver = str.substring(str.indexOf("\"") + 1, str.size() - 1); 1042 1043 defineProperty("jdkRuntimeVersion", ver) 1044 def jdkVersionInfo = parseJavaVersion(ver) 1045 defineProperty("jdkVersion", jdkVersionInfo[0]) 1046 defineProperty("jdkBuildNumber", jdkVersionInfo[1]) 1047 } 1048 } 1049 } finally { 1050 inStream.close(); 1051 } 1052 if (!project.hasProperty("jdkRuntimeVersion")) throw new Exception("Unable to determine the version of Java in JDK_HOME at $JDK_HOME"); 1053 1054 1055 1056 // Verify that CONF is something useful 1057 if (CONF != "Release" && CONF != "Debug" && CONF != "DebugNative") { 1058 logger.warn("Unknown configuration CONF='$CONF'. Treating as 'Release'") 1059 } 1060 1061 // If the number of compile threads is less than 1 then we have a problem! 1062 if (Integer.parseInt(NUM_COMPILE_THREADS.toString()) < 1) { 1063 logger.warn("NUM_COMPILE_THREADS was specified as '$NUM_COMPILE_THREADS' which is less than the minimum value of 1. " + 1064 "Building with a value of 1 instead.") 1065 NUM_COMPILE_THREADS = 1 1066 } 1067 1068 // Check for Gradle 3.1, error if < 3.0. 1069 if (gradle.gradleVersion != "3.1") { 1070 def ver = gradle.gradleVersion.split("[\\.]"); 1071 def gradleMajor = Integer.parseInt(ver[0]); 1072 def gradleMinor = Integer.parseInt(ver[1]); 1073 def err = ""; 1074 if (gradleMajor < 3) { 1075 err = "Gradle version too old: ${gradle.gradleVersion}; must be at least 3.0" 1076 } 1077 1078 if (IS_GRADLE_VERSION_CHECK && err != "") { 1079 fail(err); 1080 } 1081 1082 logger.warn("*****************************************************************"); 1083 logger.warn("Unsupported gradle version $gradle.gradleVersion in use."); 1084 logger.warn("Only version 3.1 is supported. Use this version at your own risk"); 1085 if ( err != "") logger.warn(err); 1086 logger.warn("*****************************************************************"); 1087 } 1088 1089 /****************************************************************************** 1090 * * 1091 * Logging of Properties and Settings * 1092 * * 1093 * Log some of the settings we've determined. We could log more here, it * 1094 * doesn't really hurt. * 1095 * * 1096 *****************************************************************************/ 1097 1098 logger.quiet("gradle.gradleVersion: $gradle.gradleVersion") 1099 logger.quiet("OS_NAME: $OS_NAME") 1100 logger.quiet("OS_ARCH: $OS_ARCH") 1101 logger.quiet("JAVA_HOME: $JAVA_HOME") 1102 logger.quiet("JDK_HOME: $JDK_HOME") 1103 logger.quiet("java.runtime.version: ${javaRuntimeVersion}") 1104 logger.quiet("java version: ${javaVersion}") 1105 logger.quiet("java build number: ${javaBuildNumber}") 1106 logger.quiet("jdk.runtime.version: ${jdkRuntimeVersion}") 1107 logger.quiet("jdk version: ${jdkVersion}") 1108 logger.quiet("jdk build number: ${jdkBuildNumber}") 1109 logger.quiet("minimum jdk version: ${jfxBuildJdkVersionMin}") 1110 logger.quiet("minimum jdk build number: ${jfxBuildJdkBuildnumMin}") 1111 logger.quiet("STUB_RUNTIME: $STUB_RUNTIME") 1112 logger.quiet("CONF: $CONF") 1113 logger.quiet("NUM_COMPILE_THREADS: $NUM_COMPILE_THREADS") 1114 logger.quiet("COMPILE_TARGETS: $COMPILE_TARGETS") 1115 logger.quiet("COMPILE_FLAGS_FILES: $COMPILE_FLAGS_FILES") 1116 logger.quiet("HUDSON_JOB_NAME: $HUDSON_JOB_NAME") 1117 logger.quiet("HUDSON_BUILD_NUMBER: $HUDSON_BUILD_NUMBER") 1118 logger.quiet("PROMOTED_BUILD_NUMBER: $PROMOTED_BUILD_NUMBER") 1119 logger.quiet("PRODUCT_NAME: $PRODUCT_NAME") 1120 logger.quiet("RELEASE_VERSION: $RELEASE_VERSION") 1121 logger.quiet("RELEASE_SUFFIX: $RELEASE_SUFFIX") 1122 logger.quiet("RELEASE_VERSION_SHORT: $RELEASE_VERSION_SHORT") 1123 logger.quiet("RELEASE_VERSION_LONG: $RELEASE_VERSION_LONG") 1124 logger.quiet("RELEASE_VERSION_PADDED: $RELEASE_VERSION_PADDED") 1125 1126 if (UPDATE_STUB_CACHE) { 1127 logger.quiet("UPDATE_STUB_CACHE: $UPDATE_STUB_CACHE") 1128 } 1129 1130 /****************************************************************************** 1131 * * 1132 * Definition of Native Code Compilation Tasks * 1133 * * 1134 * - JavaHeaderTask is used to run javah. The JAVAH property will point at * 1135 * the version of javah to be used (i.e.: a path to javah) * 1136 * - CCTask compiles native code. Specifically it will compile .m, .c, * 1137 * .cpp, or .cc files. It uses the headers provided by the * 1138 * JavaHeaderTask plus additional platform specific headers. It will * 1139 * compile into .obj files. * 1140 * - LinkTask will perform native linking and create the .dll / .so / * 1141 * .dylib as necessary. * 1142 * * 1143 *****************************************************************************/ 1144 1145 // Save a reference to the buildSrc.jar file because we need it for actually 1146 // compiling things, not just for the sake of this build script 1147 // (such as generating the JSL files, etc) 1148 ext.BUILD_SRC = rootProject.files("buildSrc/build/libs/buildSrc.jar") 1149 1150 /** 1151 * Convenience method for creating javah, cc, link, and "native" tasks in the given project. These 1152 * tasks are parameterized by name, so that we can produce, for example, javahGlass, ccGlass, etc 1153 * named tasks. 1154 * 1155 * @param project The project to add tasks to 1156 * @param name The name of the project, such as "prism-common". This name is used 1157 * in the name of the generated task, such as ccPrismCommon, and also 1158 * in the name of the final library, such as libprism-common.dylib. 1159 */ 1160 void addNative(Project project, String name) { 1161 // TODO if we want to handle 32/64 bit windows in the same build, 1162 // Then we will need to modify the win compile target to be win32 or win64 1163 def capitalName = name.split("-").collect{it.capitalize()}.join() 1164 def nativeTask = project.task("native$capitalName", group: "Build") { 1165 description = "Generates JNI headers, compiles, and builds native dynamic library for $name for all compile targets" 1166 } 1167 def cleanTask = project.task("cleanNative$capitalName", type: Delete, group: "Build") { 1168 description = "Clean native objects for $name" 1169 } 1170 if (project.hasProperty("nativeAllTask")) project.nativeAllTask.dependsOn nativeTask 1171 project.assemble.dependsOn(nativeTask) 1172 if (project.hasProperty("cleanNativeAllTask")) project.cleanNativeAllTask.dependsOn cleanTask 1173 1174 // Each of the different compile targets will be placed in a sub directory 1175 // of these root dirs, with the name of the dir being the name of the target 1176 def nativeRootDir = project.file("$project.buildDir/native/$name") 1177 def libRootDir = project.file("$project.buildDir/libs/$name") 1178 // For each compile target, create a javah / cc / link triplet 1179 compileTargets { t -> 1180 def targetProperties = project.rootProject.ext[t.upper] 1181 def library = targetProperties.library 1182 def properties = targetProperties.get(name) 1183 def nativeDir = file("$nativeRootDir/${t.name}") 1184 def headerDir = file("${project.buildDir}/gensrc/headers/${project.moduleName}") 1185 1186 // If there is not a library clause in the properties, assume it is not wanted 1187 if (!targetProperties.containsKey(name)) { 1188 println("Ignoring native library ${name}. Not defined in ${t.name} project properties"); 1189 return 1190 } 1191 1192 // check for the property disable${name} = true 1193 def String disableKey = "disable${name}" 1194 def boolean disabled = targetProperties.containsKey(disableKey) ? targetProperties.get(disableKey) : false 1195 if (disabled) { 1196 println("Native library ${name} disabled in ${t.name} project properties"); 1197 return 1198 } 1199 1200 def variants = properties.containsKey("variants") ? properties.variants : [""]; 1201 variants.each { variant -> 1202 def variantProperties = variant == "" ? properties : properties.get(variant) 1203 def capitalVariant = variant.capitalize() 1204 def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant") 1205 def ccTask = project.task("cc${t.capital}$capitalName$capitalVariant", type: CCTask, group: "Build") { 1206 description = "Compiles native sources for ${name} for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}" 1207 matches = ".*\\.c|.*\\.cpp|.*\\.m|.*\\.cc" 1208 headers = headerDir 1209 output(ccOutput) 1210 params.addAll(variantProperties.ccFlags) 1211 compiler = variantProperties.compiler 1212 source(variantProperties.nativeSource) 1213 cleanTask.delete ccOutput 1214 } 1215 def linkTask = project.task("link${t.capital}$capitalName$capitalVariant", type: LinkTask, dependsOn: ccTask, group: "Build") { 1216 description = "Creates native dynamic library for $name for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}" 1217 objectDir = ccOutput 1218 linkParams.addAll(variantProperties.linkFlags) 1219 lib = file("$libRootDir/${t.name}/${variant == '' ? library(properties.lib) : library(variantProperties.lib)}") 1220 linker = variantProperties.linker 1221 cleanTask.delete "$libRootDir/${t.name}" 1222 } 1223 nativeTask.dependsOn(linkTask) 1224 if (IS_WINDOWS && t.name == "win") { 1225 def rcTask = project.task("rc$capitalName$capitalVariant", type: CompileResourceTask, group: "Build") { 1226 description = "Compiles native sources for $name" 1227 matches = ".*\\.rc" 1228 compiler = variantProperties.rcCompiler 1229 source(variantProperties.rcSource) 1230 if (variantProperties.rcFlags) { 1231 rcParams.addAll(variantProperties.rcFlags) 1232 } 1233 output(ccOutput) 1234 } 1235 linkTask.dependsOn rcTask; 1236 } 1237 } 1238 1239 def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false 1240 if (useLipo) { 1241 def lipoTask = project.task("lipo${t.capital}$capitalName", type: LipoTask, group: "Build") { 1242 description = "Creates native fat library for $name for ${t.name}" 1243 libDir = file("$libRootDir/${t.name}") 1244 lib = file("$libRootDir/${t.name}/${library(properties.lib)}") 1245 } 1246 nativeTask.dependsOn(lipoTask) 1247 } 1248 } 1249 } 1250 1251 void addJSL(Project project, String name, String pkg, List<String> addExports, Closure compile) { 1252 def lowerName = name.toLowerCase() 1253 1254 def compileCompilers = project.task("compile${name}Compilers", 1255 type: JavaCompile, 1256 dependsOn: project.compileJava) { 1257 description = "Compile the $name JSL Compilers" 1258 1259 classpath = project.files(project.sourceSets.main.output.classesDir) + 1260 project.files(project.sourceSets.jslc.output.classesDir) + 1261 project.configurations.antlr 1262 source = [project.file("src/main/jsl-$lowerName")] 1263 destinationDir = project.file("$project.buildDir/classes/jsl-compilers/$lowerName") 1264 1265 if (addExports != null) { 1266 options.compilerArgs.addAll(addExports) 1267 } 1268 } 1269 1270 def generateShaders = project.task("generate${name}Shaders", 1271 dependsOn: compileCompilers) { 1272 description = "Generate $name shaders from JSL" 1273 def sourceDir = project.file("src/main/jsl-$lowerName") 1274 def destinationDir = project.file("$project.buildDir/gensrc/jsl-$lowerName") 1275 inputs.dir sourceDir 1276 outputs.dir destinationDir 1277 doLast { 1278 compile(sourceDir, destinationDir) 1279 } 1280 } 1281 1282 def compileHLSLShaders = project.task("compile${name}HLSLShaders", 1283 dependsOn: generateShaders, 1284 type: CompileHLSLTask) { 1285 enabled = IS_WINDOWS 1286 description = "Compile $name HLSL files into .obj files" 1287 matches = ".*\\.hlsl" 1288 output project.file("$project.buildDir/hlsl/$name/$pkg") 1289 source project.file("$project.buildDir/gensrc/jsl-$lowerName/$pkg") 1290 } 1291 1292 def processShaders = project.task("process${name}Shaders", 1293 dependsOn: [generateShaders, compileHLSLShaders], 1294 type: Copy, 1295 description: "Copy hlsl / frag shaders to build/resources/jsl-$lowerName") { 1296 from("$project.buildDir/hlsl/$name") { 1297 include "**/*.obj" 1298 } 1299 from("$project.buildDir/gensrc/jsl-$lowerName") { 1300 include("**/*.frag") 1301 } 1302 //into project.sourceSets.main.output.resourcesDir 1303 into project.moduleDir 1304 } 1305 1306 project.processShaders.dependsOn(processShaders) 1307 project.sourceSets.shaders.output.dir("$project.buildDir/gensrc/jsl-$lowerName", builtBy: processShaders ) 1308 1309 } 1310 1311 /** 1312 * Parses a JDK version string. The string must be in one of the following 1313 * two formats: 1314 * 1315 * major.minor.subminor 1316 * or 1317 * major.minor.subminor_update 1318 * 1319 * In both cases a list of 4 integers is returned, with element 3 set to 1320 * 0 in the former case. 1321 */ 1322 List parseJdkVersion(String version) { 1323 def arr = version.split("[_\\.]"); 1324 def intArr = []; 1325 arr.each { s -> intArr += Integer.parseInt(s); } 1326 while (intArr.size() < 4) intArr += 0; 1327 return intArr; 1328 } 1329 1330 /** 1331 * Returns -1, 0, or 1 depending on whether JDK version "a" is less than, 1332 * equal to, or grater than version "b". 1333 */ 1334 int compareJdkVersion(String a, String b) { 1335 def aIntArr = parseJdkVersion(a); 1336 def bIntArr = parseJdkVersion(b); 1337 1338 for (int i = 0; i < 4; i++) { 1339 if (aIntArr[i] < bIntArr[i]) return -1; 1340 if (aIntArr[i] > bIntArr[i]) return 1; 1341 } 1342 return 0; 1343 } 1344 1345 // Task to verify the minimum level of Java needed to build JavaFX 1346 task verifyJava() { 1347 doLast { 1348 def status = compareJdkVersion(jdkVersion, jfxBuildJdkVersionMin); 1349 if (status < 0) { 1350 fail("java version mismatch: JDK version (${jdkVersion}) < minimum version (${jfxBuildJdkVersionMin})") 1351 } else if (status == 0) { 1352 def buildNum = Integer.parseInt(jdkBuildNumber) 1353 def minBuildNum = Integer.parseInt(jfxBuildJdkBuildnumMin) 1354 if (buildNum != 0 && buildNum < minBuildNum) { 1355 fail("JDK build number ($buildNum) < minimum build number ($minBuildNum)") 1356 } 1357 } 1358 } 1359 } 1360 1361 task updateCacheIfNeeded() { 1362 // an empty task we can add to as needed for UPDATE_STUB_CACHE 1363 } 1364 1365 task createTestArgfiles { 1366 // an empty task we can add to as needed 1367 } 1368 1369 1370 /***************************************************************************** 1371 * Project definitions (dependencies, etc) * 1372 *****************************************************************************/ 1373 1374 void addJCov(p, test) { 1375 test.doFirst { 1376 def jcovJVMArgument = 1377 "include=javafx," + 1378 "include=com.sun.javafx," + 1379 "include=com.sun.glass," + 1380 "include=com.sun.openpisces," + 1381 "include=com.sun.pisces," + 1382 "include=com.sun.prism," + 1383 "include=com.sun.scenario," + 1384 "include=com.sun.webkit," + 1385 "exclude=com," + 1386 "exclude=java," + 1387 "exclude=javax," + 1388 "exclude=\"**.test\"," + 1389 "exclude=\"**.*Test\"," + 1390 "file=build/reports/jcov/report.xml," + 1391 "merge=merge"; 1392 test.jvmArgs("-javaagent:${p.configurations.testCompile.files.find { it.name.startsWith('jcov') }}=$jcovJVMArgument"); 1393 p.mkdir p.file("build/reports/jcov") 1394 } 1395 test.doLast { 1396 def reportFile = p.file("build/reports/jcov/report.xml") 1397 if (reportFile.exists()) { 1398 p.javaexec { 1399 workingDir = p.file("build/reports/jcov") 1400 classpath = p.files(p.configurations.testCompile.files.find { it.name.startsWith('jcov') }) 1401 main = "com.sun.tdk.jcov.Helper" 1402 args = [ 1403 "RepGen", 1404 "-exclude", "\"**.test\"", 1405 "-exclude", "\"**.*Test\"", 1406 "-output", ".", 1407 "-source", p.sourceSets.main.java.srcDirs.collect{p.file(it)}.join(":"), 1408 "report.xml" 1409 ] 1410 } 1411 } 1412 } 1413 } 1414 1415 allprojects { 1416 // We want to configure all projects as java projects and use the same compile settings 1417 // etc, except for the root project which we just want to ignore (and for now media) 1418 if (project == rootProject) { 1419 return 1420 } 1421 if (project.path.startsWith(":apps")) { 1422 // Lets handle the apps tree differently, as it is a collection of ant builds, 1423 // and the ant importer collides with the 'apply plugin:java' 1424 return 1425 } 1426 1427 // All of our projects are java projects 1428 1429 apply plugin: "java" 1430 sourceCompatibility = 1.9 1431 1432 // Setup the repositories that we'll download libraries from. Maven Central is 1433 // just easy for most things. The custom "ivy" repo is for downloading SWT. The way it 1434 // works is to setup the download URL such that it will resolve to the actual jar file 1435 // to download. See SWT_FILE_NAME for the name of the jar that will be used as the 1436 // "artifact" in the pattern below. Note that the closed builds use different repositories 1437 // so if you are debugging a closed-build artifact related build issue, check out the 1438 // closed gradle file instead. 1439 if (!BUILD_CLOSED) { 1440 repositories { 1441 mavenCentral() 1442 ivy { 1443 url "http://download.eclipse.org/eclipse/updates/3.7/R-3.7.2-201202080800/plugins/" 1444 layout "pattern", { 1445 artifact "[artifact].[ext]" 1446 } 1447 } 1448 } 1449 } 1450 1451 // By default all of our projects require junit for testing so we can just 1452 // setup this dependency here. 1453 dependencies { 1454 testCompile group: "junit", name: "junit", version: "4.8.2" 1455 if (BUILD_CLOSED && DO_JCOV) { 1456 testCompile name: "jcov" 1457 } 1458 } 1459 1460 compileJava.dependsOn verifyJava 1461 1462 // At the moment the ASM library shipped with Gradle that is used to 1463 // discover the different test classes fails on Java 8, so in order 1464 // to have sourceCompatibility set to 1.8 I have to also turn scanForClasses off 1465 // and manually specify the includes / excludes. At the moment we use 1466 // Java 7 but when we switch to 8 this will be needed, and probably again when 1467 // we start building with Java 9. 1468 test { 1469 executable = JAVA; 1470 enableAssertions = true; 1471 testLogging.exceptionFormat = "full"; 1472 scanForTestClasses = false; 1473 include("**/*Test.*"); 1474 if (BUILD_CLOSED && DO_JCOV) { 1475 addJCov(project, test) 1476 } 1477 1478 if (IS_HEADLESS_TEST) { 1479 systemProperty 'glass.platform', 'Monocle' 1480 systemProperty 'monocle.platform', 'Headless' 1481 systemProperty 'prism.order', 'sw' 1482 systemProperty 'com.sun.javafx.gestures.zoom', 'true' 1483 systemProperty 'com.sun.javafx.gestures.rotate', 'true' 1484 systemProperty 'com.sun.javafx.gestures.scroll', 'true' 1485 } 1486 1487 systemProperty 'unstable.test', IS_UNSTABLE_TEST 1488 } 1489 1490 compileTestJava { 1491 } 1492 } 1493 1494 // These strings define the module-source-path to be used in compilation. 1495 // They need to contain the full paths to the sources and the * will be 1496 // used to infer the module name that is used. 1497 project.ext.defaultModuleSourcePath = 1498 cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') + 1499 File.pathSeparator + 1500 cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}') 1501 1502 // graphics pass one 1503 project.ext.defaultModuleSourcePath_GraphicsOne = 1504 cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') + 1505 File.pathSeparator + 1506 cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}') 1507 1508 // web pass one 1509 project.ext.defaultModuleSourcePath_WebOne = 1510 cygpath(rootProject.projectDir.path + '/modules/*/src/main/java') 1511 1512 // Compiling the test shim files too. 1513 project.ext.defaultModuleSourcePathShim = 1514 cygpath(rootProject.projectDir.path + '/modules/*/src/{main,shims}/java') + 1515 File.pathSeparator + 1516 cygpath(rootProject.projectDir.path + '/modules/*/build/gensrc/{java,jsl-decora,jsl-prism}') 1517 1518 // The "base" project is our first module and the most basic one required for 1519 // all other modules. It is useful even for non-GUI applications. 1520 project(":base") { 1521 project.ext.buildModule = true 1522 project.ext.moduleRuntime = true 1523 project.ext.moduleName = "javafx.base" 1524 1525 sourceSets { 1526 main 1527 shims 1528 test 1529 } 1530 1531 dependencies { 1532 testCompile group: "junit", name: "junit", version: "4.8.2" 1533 } 1534 1535 commonModuleSetup(project, [ 'base' ]) 1536 1537 project.ext.moduleSourcePath = defaultModuleSourcePath 1538 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 1539 1540 // We need to take the VersionInfo.java file and replace the various 1541 // properties within it 1542 def replacements = [ 1543 "BUILD_TIMESTAMP": BUILD_TIMESTAMP, 1544 "HUDSON_JOB_NAME": HUDSON_JOB_NAME, 1545 "HUDSON_BUILD_NUMBER": HUDSON_BUILD_NUMBER, 1546 "PROMOTED_BUILD_NUMBER": PROMOTED_BUILD_NUMBER, 1547 "PRODUCT_NAME": PRODUCT_NAME, 1548 "RELEASE_VERSION": RELEASE_VERSION, 1549 "RELEASE_SUFFIX": RELEASE_SUFFIX]; 1550 task processVersionInfo(type: Copy, description: "Replace params in VersionInfo and copy file to destination") { 1551 doFirst { mkdir "$buildDir/gensrc/java" } 1552 from "src/main/version-info" 1553 into "$buildDir/gensrc/java/com/sun/javafx/runtime" 1554 filter {line-> 1555 replacements.each() {k, v -> 1556 line = line.replace("@$k@", v.toString()); 1557 } 1558 line 1559 } 1560 } 1561 1562 // if (IS_COMPILE_JFR) { 1563 // sourceSets.main.java.srcDirs += "src/main/java-jfr" 1564 // } 1565 1566 // Make sure to include $buildDir/gensrc/java that we previously created. 1567 // We DO NOT want to include src/main/version-info 1568 1569 sourceSets.main.java.srcDirs += "$buildDir/gensrc/java" 1570 1571 compileJava.dependsOn processVersionInfo 1572 } 1573 1574 // The graphics module is needed for any graphical JavaFX application. It requires 1575 // the base module and includes the scene graph, layout, css, prism, windowing, etc. 1576 // This is a fairly complicated module. There are many different types of native components 1577 // that all need to be compiled. 1578 project(":graphics") { 1579 1580 project.ext.buildModule = true 1581 project.ext.moduleRuntime = true 1582 project.ext.moduleName = "javafx.graphics" 1583 1584 getConfigurations().create("antlr"); 1585 1586 sourceSets { 1587 jslc // JSLC gramar subset 1588 main 1589 shims 1590 shaders // generated shaders (prism & decora) 1591 test 1592 stub 1593 } 1594 1595 dependencies { 1596 stubCompile group: "junit", name: "junit", version: "4.8.2" 1597 1598 antlr group: "org.antlr", name: "antlr-complete", version: "3.5.2" 1599 } 1600 1601 project.ext.moduleSourcePath = defaultModuleSourcePath_GraphicsOne 1602 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 1603 1604 commonModuleSetup(project, [ 'base', 'graphics' ]) 1605 1606 List<String> decoraAddExports = [ 1607 '--add-exports=javafx.graphics/com.sun.scenario.effect=ALL-UNNAMED', 1608 '--add-exports=javafx.graphics/com.sun.scenario.effect.light=ALL-UNNAMED', 1609 '--add-exports=javafx.graphics/com.sun.scenario.effect.impl.state=ALL-UNNAMED' 1610 ] 1611 /* 1612 Graphics compilation is "complicated" by the generated shaders. 1613 1614 We have two shader groups - Decora and Prism. 1615 1616 The shader groups each will generate a custom compiler that 1617 then genarates the shader code. These compilers rely on the JSLC 1618 gramar parser which is antlr generated and compile separately. 1619 1620 The decora compiler relies on compileJava - which is sourceSet.main.java 1621 It also accesses module private packages, so will need add-exports 1622 1623 Once the shader java code is generated, we can compileFullJava 1624 1625 After that, we can generate the required native header and then build the native code 1626 */ 1627 1628 project.task("processShaders") { 1629 // an empty task to hang the prism and decora shaders on 1630 } 1631 1632 // Generate the JSLC support grammar 1633 project.task("generateGrammarSource", type: JavaExec) { 1634 // use antlr to generate our grammar. 1635 // note: the antlr plugin creates some issues with the other compiles 1636 // so we will do this by hand 1637 1638 File wd = file(project.projectDir.path + "/src/jslc/antlr") 1639 1640 executable = JAVA 1641 classpath = project.configurations.antlr 1642 workingDir = wd 1643 main = "org.antlr.Tool" 1644 1645 args = [ 1646 "-o", 1647 "$buildDir/gensrc/antlr", 1648 "com/sun/scenario/effect/compiler/JSL.g" ] 1649 1650 inputs.dir wd 1651 outputs.dir file("$buildDir/gensrc/antlr") 1652 } 1653 sourceSets.jslc.java.srcDirs += "$buildDir/gensrc/antlr" 1654 1655 // and compile the JSLC support classes 1656 compileJslcJava.dependsOn(generateGrammarSource) 1657 compileJslcJava.classpath = project.configurations.antlr 1658 1659 compileJava.dependsOn(compileJslcJava) 1660 1661 // this task is the "second pass" compile of all of the module classes 1662 project.task("compileFullJava", type: JavaCompile, dependsOn: processShaders) { 1663 description = "Compile all of the graphics java classes - main and shaders" 1664 1665 classpath = configurations.compile 1666 1667 source = project.sourceSets.main.java.srcDirs 1668 source += "$buildDir/gensrc/java" 1669 source += project.sourceSets.shaders.output 1670 1671 project.sourceSets.shims.java.srcDirs += project.sourceSets.shaders.output 1672 1673 destinationDir = project.sourceSets.main.output.classesDir 1674 options.compilerArgs.addAll([ 1675 '-h', "$buildDir/gensrc/headers/", // Note: this creates the native headers 1676 '-implicit:none', 1677 '--module-source-path', defaultModuleSourcePath 1678 ] ) 1679 } 1680 classes.dependsOn(compileFullJava) 1681 1682 // Create a single "native" task which will depend on all the individual native tasks for graphics 1683 project.ext.nativeAllTask = task("native", group: "Build", description: "Compiles and Builds all native libraries for Graphics"); 1684 project.ext.cleanNativeAllTask = task("cleanNative", group: "Build", description: "Clean all native libraries and objects for Graphics"); 1685 1686 // Add tasks for native compilation 1687 addNative(project, "glass"); 1688 addNative(project, "prism") 1689 addNative(project, "prismSW") 1690 addNative(project, "font") 1691 addNative(project, "iio") 1692 addNative(project, "prismES2") 1693 1694 if (IS_COMPILE_PANGO) { 1695 addNative(project, "fontFreetype") 1696 addNative(project, "fontPango") 1697 } 1698 1699 if (IS_WINDOWS) { 1700 addNative(project, "prismD3D") 1701 // TODO need to hook this up to be executed only if PassThroughVS.h is missing or PassThroughVS.hlsl is changed 1702 task generateD3DHeaders(group: "Build") { 1703 enabled = IS_WINDOWS 1704 inputs.file "src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl" 1705 inputs.file "src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl" 1706 inputs.file "src/main/native-prism-d3d/PassThroughVS.hlsl" 1707 outputs.dir "$buildDir/headers/PrismD3D/" 1708 outputs.dir "$buildDir/headers/PrismD3D/hlsl/" 1709 description = "Generate headers by compiling hlsl files" 1710 doLast { 1711 mkdir file("$buildDir/headers/PrismD3D/hlsl") 1712 def PS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1PS.hlsl") 1713 def VS_3D_SRC = file("src/main/native-prism-d3d/hlsl/Mtl1VS.hlsl") 1714 def PASSTHROUGH_VS_SRC = file("src/main/native-prism-d3d/PassThroughVS.hlsl") 1715 def jobs = [ 1716 ["$FXC", "/nologo", "/T", "vs_3_0", "/Fh", "$buildDir/headers/PrismD3D/PassThroughVS.h", "/E", "passThrough", "$PASSTHROUGH_VS_SRC"], 1717 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS.h", "/DSpec=0", "/DSType=0", "$PS_3D_SRC"], 1718 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_i.h", "/DSpec=0", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"], 1719 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1n.h", "/DSpec=1", "/DSType=0", "$PS_3D_SRC"], 1720 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2n.h", "/DSpec=2", "/DSType=0", "$PS_3D_SRC"], 1721 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3n.h", "/DSpec=3", "/DSType=0", "$PS_3D_SRC"], 1722 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1t.h", "/DSpec=1", "/DSType=1", "$PS_3D_SRC"], 1723 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2t.h", "/DSpec=2", "/DSType=1", "$PS_3D_SRC"], 1724 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3t.h", "/DSpec=3", "/DSType=1", "$PS_3D_SRC"], 1725 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1c.h", "/DSpec=1", "/DSType=2", "$PS_3D_SRC"], 1726 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2c.h", "/DSpec=2", "/DSType=2", "$PS_3D_SRC"], 1727 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3c.h", "/DSpec=3", "/DSType=2", "$PS_3D_SRC"], 1728 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1m.h", "/DSpec=1", "/DSType=3", "$PS_3D_SRC"], 1729 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2m.h", "/DSpec=2", "/DSType=3", "$PS_3D_SRC"], 1730 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3m.h", "/DSpec=3", "/DSType=3", "$PS_3D_SRC"], 1731 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1n.h", "/DSpec=1", "/DSType=0", "/DBump=1", "$PS_3D_SRC"], 1732 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2n.h", "/DSpec=2", "/DSType=0", "/DBump=1", "$PS_3D_SRC"], 1733 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3n.h", "/DSpec=3", "/DSType=0", "/DBump=1", "$PS_3D_SRC"], 1734 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1t.h", "/DSpec=1", "/DSType=1", "/DBump=1", "$PS_3D_SRC"], 1735 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2t.h", "/DSpec=2", "/DSType=1", "/DBump=1", "$PS_3D_SRC"], 1736 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3t.h", "/DSpec=3", "/DSType=1", "/DBump=1", "$PS_3D_SRC"], 1737 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1c.h", "/DSpec=1", "/DSType=2", "/DBump=1", "$PS_3D_SRC"], 1738 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2c.h", "/DSpec=2", "/DSType=2", "/DBump=1", "$PS_3D_SRC"], 1739 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3c.h", "/DSpec=3", "/DSType=2", "/DBump=1", "$PS_3D_SRC"], 1740 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1m.h", "/DSpec=1", "/DSType=3", "/DBump=1", "$PS_3D_SRC"], 1741 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2m.h", "/DSpec=2", "/DSType=3", "/DBump=1", "$PS_3D_SRC"], 1742 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3m.h", "/DSpec=3", "/DSType=3", "/DBump=1", "$PS_3D_SRC"], 1743 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1ni.h", "/DSpec=1", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"], 1744 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2ni.h", "/DSpec=2", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"], 1745 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3ni.h", "/DSpec=3", "/DSType=0", "/DIllumMap=1", "$PS_3D_SRC"], 1746 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1ti.h", "/DSpec=1", "/DSType=1", "/DIllumMap=1", "$PS_3D_SRC"], 1747 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2ti.h", "/DSpec=2", "/DSType=1", "/DIllumMap=1", "$PS_3D_SRC"], 1748 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3ti.h", "/DSpec=3", "/DSType=1", "/DIllumMap=1", "$PS_3D_SRC"], 1749 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1ci.h", "/DSpec=1", "/DSType=2", "/DIllumMap=1", "$PS_3D_SRC"], 1750 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2ci.h", "/DSpec=2", "/DSType=2", "/DIllumMap=1", "$PS_3D_SRC"], 1751 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3ci.h", "/DSpec=3", "/DSType=2", "/DIllumMap=1", "$PS_3D_SRC"], 1752 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s1mi.h", "/DSpec=1", "/DSType=3", "/DIllumMap=1", "$PS_3D_SRC"], 1753 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s2mi.h", "/DSpec=2", "/DSType=3", "/DIllumMap=1", "$PS_3D_SRC"], 1754 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_s3mi.h", "/DSpec=3", "/DSType=3", "/DIllumMap=1", "$PS_3D_SRC"], 1755 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1ni.h", "/DSpec=1", "/DSType=0", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1756 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2ni.h", "/DSpec=2", "/DSType=0", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1757 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3ni.h", "/DSpec=3", "/DSType=0", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1758 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1ti.h", "/DSpec=1", "/DSType=1", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1759 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2ti.h", "/DSpec=2", "/DSType=1", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1760 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3ti.h", "/DSpec=3", "/DSType=1", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1761 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1ci.h", "/DSpec=1", "/DSType=2", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1762 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2ci.h", "/DSpec=2", "/DSType=2", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1763 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3ci.h", "/DSpec=3", "/DSType=2", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1764 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b1mi.h", "/DSpec=1", "/DSType=3", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1765 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b2mi.h", "/DSpec=2", "/DSType=3", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1766 ["$FXC", "/nologo", "/T", "ps_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1PS_b3mi.h", "/DSpec=3", "/DSType=3", "/DBump=1", "/DIllumMap=1", "$PS_3D_SRC"], 1767 ["$FXC", "/nologo", "/T", "vs_2_0", "/Fh", "$buildDir/headers/PrismD3D/hlsl/Mtl1VS_Obj.h", "/DVertexType=ObjVertex", "$VS_3D_SRC"] 1768 ] 1769 final ExecutorService executor = Executors.newFixedThreadPool(Integer.parseInt(project.NUM_COMPILE_THREADS.toString())); 1770 final CountDownLatch latch = new CountDownLatch(jobs.size()); 1771 List futures = new ArrayList<Future>(); 1772 jobs.each { cmd -> 1773 futures.add(executor.submit(new Runnable() { 1774 @Override public void run() { 1775 try { 1776 exec { 1777 commandLine cmd 1778 } 1779 } finally { 1780 latch.countDown(); 1781 } 1782 } 1783 })); 1784 } 1785 latch.await(); 1786 // Looking for whether an exception occurred while executing any of the futures. 1787 // By calling "get()" on each future an exception will be thrown if one had occurred 1788 // on the background thread. 1789 futures.each {it.get();} 1790 } 1791 } 1792 1793 ccWinPrismD3D.dependsOn generateD3DHeaders 1794 } 1795 1796 // The Decora and Prism JSL files have to be generated in a very specific set of steps. 1797 // 1) Compile the *Compile.java classes. These live in src/main/jsl-* and will be 1798 // output to $buildDir/classes/jsl-compilers/* (where * == decora or prism). 1799 // 2) Generate source files from the JSL files contained in src/main/jsl-*. These 1800 // will be output to $buildDir/gensrc/jsl-* 1801 // 3) Compile the JSL Java sources in $buildDir/gensrc/jsl-* and put the output 1802 // into classes/jsl-* 1803 // 4) Compile the native JSL sources in $buildDir/gensrc/jsl-* and put the obj 1804 // files into native/jsl-* and the resulting library into libs/jsl-*.dll|so|dylib 1805 // 5) Modify the jar step to include classes/jsl-* 1806 // The native library must be copied over during SDK creation time in the "sdk" task. In 1807 // addition to these steps, the clean task is created. Note that I didn't bother to create 1808 // a new task for each of the decora files, preferring instead just to create a rule?? Also 1809 // need "clean" tasks for each compile task. 1810 1811 addJSL(project, "Decora", "com/sun/scenario/effect/impl/hw/d3d/hlsl", decoraAddExports) { sourceDir, destinationDir -> 1812 [[fileName: "ColorAdjust", generator: "CompileJSL", outputs: "-all"], 1813 [fileName: "Brightpass", generator: "CompileJSL", outputs: "-all"], 1814 [fileName: "SepiaTone", generator: "CompileJSL", outputs: "-all"], 1815 [fileName: "PerspectiveTransform", generator: "CompileJSL", outputs: "-all"], 1816 [fileName: "DisplacementMap", generator: "CompileJSL", outputs: "-all"], 1817 [fileName: "InvertMask", generator: "CompileJSL", outputs: "-all"], 1818 [fileName: "Blend", generator: "CompileBlend", outputs: "-all"], 1819 [fileName: "PhongLighting", generator: "CompilePhong", outputs: "-all"], 1820 [fileName: "LinearConvolve", generator: "CompileLinearConvolve", outputs: "-hw"], 1821 [fileName: "LinearConvolveShadow", generator: "CompileLinearConvolve", outputs: "-hw"]].each { settings -> 1822 javaexec { 1823 executable = JAVA 1824 workingDir = project.projectDir 1825 main = settings.generator 1826 classpath = configurations.compile + configurations.antlr 1827 classpath += files(project.sourceSets.jslc.output.classesDir) 1828 1829 //classpath += files(project.sourceSets.jslc.resources) // not quite right.. 1830 classpath += files("${project.projectDir}/src/jslc/resources") 1831 1832 classpath += files("$buildDir/classes/main") 1833 classpath += files("$buildDir/classes/jsl-compilers/decora") 1834 jvmArgs += decoraAddExports 1835 args += ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/scenario/effect", "$settings.outputs", "$settings.fileName"] 1836 } 1837 } 1838 } 1839 1840 1841 task nativeDecora(dependsOn: compileDecoraHLSLShaders, group: "Build") { 1842 description = "Generates JNI headers, compiles, and builds native dynamic library for Decora" 1843 } 1844 task cleanNativeDecora(type: Delete, group: "Build") { 1845 description = "Clean native objects for Decora" 1846 } 1847 1848 def headerDir = file("$buildDir/gensrc/headers/javafx.graphics") 1849 def nativeRootDir = project.file("$project.buildDir/native/jsl-decora") 1850 def libRootDir = project.file("$project.buildDir/libs/jsl-decora") 1851 // For each compile target, create cc and link tasks 1852 compileTargets { t -> 1853 def target = t.name 1854 def upperTarget = t.upper 1855 def capitalTarget = t.capital 1856 def targetProperties = rootProject.ext[upperTarget]; 1857 def library = targetProperties.library 1858 def properties = targetProperties.get('decora') 1859 def nativeDir = file("$nativeRootDir/$target"); 1860 1861 def variants = properties.containsKey("variants") ? properties.variants : [""]; 1862 variants.each { variant -> 1863 def variantProperties = variant == "" ? properties : properties.get(variant) 1864 def capitalVariant = variant.capitalize() 1865 def ccOutput = variant == "" ? nativeDir : file("$nativeDir/$variant") 1866 1867 def ccTask = task("compileDecoraNativeShaders$capitalTarget$capitalVariant", type: CCTask ) { 1868 description = "Compiles Decora SSE natives for ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}" 1869 matches = ".*\\.cc" 1870 source file("$buildDir/gensrc/jsl-decora") 1871 source file(project.projectDir.path + "/src/main/native-decora") 1872 headers = headerDir 1873 params.addAll(variantProperties.ccFlags) 1874 output(ccOutput) 1875 compiler = variantProperties.compiler 1876 cleanNativeDecora.delete ccOutput 1877 } 1878 1879 def linkTask = task("linkDecoraNativeShaders$capitalTarget$capitalVariant", type: LinkTask, dependsOn: ccTask) { 1880 description = "Creates native dynamic library for Decora SSE ${t.name}${capitalVariant != '' ? ' for variant ' + capitalVariant : ''}" 1881 objectDir = ccOutput 1882 linkParams.addAll(variantProperties.linkFlags) 1883 lib = file("$libRootDir/$t.name/${library(variantProperties.lib)}") 1884 linker = variantProperties.linker 1885 cleanNativeDecora.delete "$libRootDir/$t.name/" 1886 } 1887 1888 if (IS_WINDOWS && target == "win") { 1889 def rcTask = project.task("rcDecoraNativeShaders$capitalTarget$capitalVariant", type: CompileResourceTask) { 1890 description = "Compiles native sources for Decora SSE" 1891 matches = ".*\\.rc" 1892 compiler = variantProperties.rcCompiler 1893 source(variantProperties.rcSource) 1894 if (variantProperties.rcFlags) { 1895 rcParams.addAll(variantProperties.rcFlags) 1896 } 1897 output(ccOutput) 1898 } 1899 linkTask.dependsOn rcTask; 1900 } 1901 1902 nativeDecora.dependsOn(linkTask) 1903 } 1904 } 1905 1906 // Prism JSL 1907 addJSL(project, "Prism", "com/sun/prism/d3d/hlsl", null) { sourceDir, destinationDir -> 1908 def inputFiles = fileTree(dir: sourceDir) 1909 inputFiles.include "**/*.jsl" 1910 inputFiles.each { file -> 1911 javaexec { 1912 executable = JAVA 1913 workingDir = project.projectDir 1914 main = "CompileJSL" 1915 classpath = configurations.compile + configurations.antlr 1916 classpath += files(project.sourceSets.jslc.output.classesDir) 1917 classpath += files(project.sourceSets.jslc.resources) 1918 classpath += files("$buildDir/classes/jsl-compilers/prism", 1919 project.projectDir.path + "/src/main/jsl-prism") // for the .stg 1920 args = ["-i", sourceDir, "-o", destinationDir, "-t", "-pkg", "com/sun/prism", "-d3d", "-es2", "-name", "$file"] 1921 } 1922 } 1923 } 1924 1925 nativePrism.dependsOn compilePrismHLSLShaders; 1926 1927 project.nativeAllTask.dependsOn nativeDecora 1928 project.cleanNativeAllTask.dependsOn cleanNativeDecora 1929 assemble.dependsOn nativeDecora 1930 processResources.dependsOn processDecoraShaders, processPrismShaders 1931 1932 test { 1933 def cssDir = file("$buildDir/classes/main/javafx") 1934 jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit", 1935 "-DCSS_META_DATA_TEST_DIR=$cssDir" 1936 enableAssertions = true 1937 testLogging.exceptionFormat = "full" 1938 scanForTestClasses = false 1939 include "**/*Test.*" 1940 if (BUILD_CLOSED && DO_JCOV) { 1941 addJCov(project, test) 1942 } 1943 } 1944 1945 // To enable the IDEs to all be happy (no red squiggles) we need to have the libraries 1946 // available in some known location. Maybe in the future the Gradle plugins to each 1947 // of the IDEs will be good enough that we won't need this hack anymore. 1948 classes << { 1949 // Copy all of the download libraries to the libs directory for the sake of the IDEs 1950 File libsDir = rootProject.file("build/libs"); 1951 1952 // In some IDEs (Eclipse for example), touching these libraries 1953 // cauese a full build within the IDE. When gradle is used 1954 // outside of the IDE, for example to build the native code, 1955 // a full rebuild is caused within the IDE. The fix is to check 1956 // for the presence of the target files in the lib directory 1957 // and not copy the files if all are present. 1958 1959 libsDir.mkdirs(); 1960 1961 def allLibsPresent = true 1962 def libNames = ["antlr-3.1.3.jar", "stringtemplate-3.2.jar", "antlr-runtime-3.1.3.jar"] 1963 libNames.each { name -> 1964 File f = new File(libsDir, name) 1965 if (!f.exists()) allLibsPresent = false 1966 } 1967 if (allLibsPresent) return; 1968 1969 for (File f : [configurations.compile.files, configurations.antlr.files].flatten()) { 1970 copy { 1971 into libsDir 1972 from f.getParentFile() 1973 include "**/antlr-complete-3.5.2.jar" 1974 includeEmptyDirs = false 1975 } 1976 } 1977 } 1978 } 1979 1980 project(":controls") { 1981 project.ext.buildModule = true 1982 project.ext.moduleRuntime = true 1983 project.ext.moduleName = "javafx.controls" 1984 1985 sourceSets { 1986 main 1987 shims 1988 test 1989 } 1990 1991 project.ext.moduleSourcePath = defaultModuleSourcePath 1992 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 1993 1994 commonModuleSetup(project, [ 'base', 'graphics', 'controls' ]) 1995 1996 dependencies { 1997 testCompile project(":graphics").sourceSets.test.output 1998 testCompile project(":base").sourceSets.test.output 1999 } 2000 2001 test { 2002 def cssDir = file("$buildDir/classes/main/javafx") 2003 jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit", 2004 "-DCSS_META_DATA_TEST_DIR=$cssDir" 2005 } 2006 2007 // TODO Css2Bin really should be moved out and put into buildSrc if it can be 2008 // TODO could change script to dynamically locate all .css files and create bss for them, probably better 2009 // TODO also not sure there is any benefit to having css files in the the runtime modules at all 2010 processResources << { 2011 ["$moduleDir/com/sun/javafx/scene/control/skin/caspian/caspian.css", 2012 "$moduleDir/com/sun/javafx/scene/control/skin/caspian/caspian-no-transparency.css", 2013 "$moduleDir/com/sun/javafx/scene/control/skin/caspian/embedded-qvga.css", 2014 "$moduleDir/com/sun/javafx/scene/control/skin/caspian/embedded.css", 2015 "$moduleDir/com/sun/javafx/scene/control/skin/caspian/fxvk.css", 2016 "$moduleDir/com/sun/javafx/scene/control/skin/caspian/highcontrast.css", 2017 "$moduleDir/com/sun/javafx/scene/control/skin/modena/modena.css", 2018 "$moduleDir/com/sun/javafx/scene/control/skin/modena/modena-no-transparency.css", 2019 "$moduleDir/com/sun/javafx/scene/control/skin/modena/touch.css"].each { css -> 2020 javaexec { 2021 executable = JAVA 2022 workingDir = project.projectDir 2023 jvmArgs += patchModuleArgs 2024 main = "com.sun.javafx.css.parser.Css2Bin" 2025 args css 2026 } 2027 } 2028 } 2029 } 2030 2031 project(":swing") { 2032 /* should not be built, but needed in JMX 2033 tasks.all { 2034 if (!COMPILE_SWING) it.enabled = false 2035 } 2036 */ 2037 project.ext.buildModule = COMPILE_SWING 2038 project.ext.moduleRuntime = true 2039 project.ext.moduleName = "javafx.swing" 2040 2041 sourceSets { 2042 main 2043 //shims // no test shims needed 2044 test 2045 } 2046 2047 project.ext.moduleSourcePath = defaultModuleSourcePath 2048 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 2049 2050 commonModuleSetup(project, [ 'base', 'graphics', 'swing' ]) 2051 2052 dependencies { 2053 } 2054 2055 test { 2056 enabled = IS_FULL_TEST && IS_AWT_TEST 2057 } 2058 } 2059 2060 project(":swt") { 2061 tasks.all { 2062 if (!COMPILE_SWT) it.enabled = false 2063 } 2064 2065 // javafx.swt is an automatic module 2066 project.ext.buildModule = false 2067 2068 commonModuleSetup(project, [ 'base', 'graphics' ]) 2069 2070 dependencies { 2071 compile name: SWT_FILE_NAME 2072 } 2073 2074 classes << { 2075 // Copy all of the download libraries to libs directory for the sake of the IDEs 2076 File libsDir = rootProject.file("build/libs"); 2077 File swtLib = new File(libsDir, "swt-debug.jar") 2078 libsDir.mkdirs(); 2079 2080 // Skip copy if file is present. 2081 if (swtLib.exists()) return; 2082 2083 for (File f : configurations.compile.files) { 2084 // Have to rename the swt jar because it is some platform specific name but 2085 // for the sake of the IDEs we need to have a single stable name that works 2086 // on every platform 2087 copy { 2088 into libsDir 2089 from f.getParentFile() 2090 include "**/*swt*.jar" 2091 includeEmptyDirs = false 2092 rename ".*swt.*jar", "swt-debug\\.jar" 2093 } 2094 } 2095 } 2096 2097 compileJava.options.compilerArgs.addAll([ 2098 "--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED", 2099 "--add-exports=javafx.graphics/com.sun.javafx.cursor=ALL-UNNAMED", 2100 "--add-exports=javafx.graphics/com.sun.javafx.embed=ALL-UNNAMED", 2101 "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED", 2102 "--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED", 2103 ]) 2104 2105 test { 2106 enabled = IS_FULL_TEST && IS_SWT_TEST 2107 2108 enabled = false // FIXME: JIGSAW -- support this with modules 2109 logger.info("JIGSAW Testing disabled for swt") 2110 2111 if (IS_MAC) { 2112 enabled = false 2113 logger.info("SWT tests are disabled on MAC, because Gradle test runner does not handle -XstartOnFirstThread properly (https://issues.gradle.org/browse/GRADLE-3290).") 2114 } 2115 } 2116 } 2117 2118 project(":fxml") { 2119 project.ext.buildModule = true 2120 project.ext.moduleRuntime = true 2121 project.ext.moduleName = "javafx.fxml" 2122 2123 sourceSets { 2124 main 2125 shims 2126 test 2127 } 2128 2129 project.ext.moduleSourcePath = defaultModuleSourcePath 2130 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 2131 2132 commonModuleSetup(project, [ 'base', 'graphics', 'swing', 'controls', 'fxml' ]) 2133 2134 2135 dependencies { 2136 testCompile project(":graphics").sourceSets.test.output 2137 testCompile project(":base").sourceSets.test.output 2138 } 2139 2140 test { 2141 // StubToolkit is not *really* needed here, but because some code inadvertently invokes performance 2142 // tracker and this attempts to fire up the toolkit and this looks for native libraries and fails, 2143 // we have to use the stub toolkit for now. 2144 jvmArgs "-Djavafx.toolkit=test.com.sun.javafx.pgstub.StubToolkit" 2145 // FIXME: change this to also allow JDK 9 boot jdk 2146 classpath += files("$JDK_HOME/jre/lib/ext/nashorn.jar") 2147 } 2148 } 2149 2150 project(":jmx") { 2151 project.ext.buildModule = false 2152 project.ext.moduleRuntime = false 2153 project.ext.moduleName = "javafx.jmx" 2154 2155 commonModuleSetup(project, [ 'base', 'graphics', 'swing', 'controls', 'media', 'jmx' ]) 2156 2157 dependencies { 2158 } 2159 2160 // Tests are permanently disabled 2161 test.enabled = false 2162 2163 compileJava.options.compilerArgs.addAll([ 2164 "--add-exports=javafx.graphics/com.sun.javafx.jmx=ALL-UNNAMED", 2165 "--add-exports=javafx.graphics/com.sun.scenario.animation=ALL-UNNAMED", 2166 "--add-exports=javafx.graphics/com.sun.scenario.animation.jmx=ALL-UNNAMED", 2167 "--add-exports=javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED", 2168 "--add-exports=javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED", 2169 "--add-exports=javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED", 2170 "--add-exports=javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED", 2171 "--add-exports=javafx.media/com.sun.media.jfxmedia.events=ALL-UNNAMED", 2172 ]) 2173 } 2174 2175 project(":fxpackagerservices") { 2176 project.ext.buildModule = COMPILE_FXPACKAGER 2177 project.ext.moduleRuntime = false 2178 project.ext.moduleName = "jdk.packager.services" 2179 2180 sourceSets { 2181 main 2182 //shims // no test shims needed 2183 test 2184 } 2185 2186 project.ext.moduleSourcePath = defaultModuleSourcePath 2187 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 2188 2189 commonModuleSetup(project, [ 'base', 'graphics', 'controls' ]) 2190 2191 tasks.all { 2192 if (!COMPILE_FXPACKAGER) it.enabled = false 2193 } 2194 2195 2196 compileTestJava.enabled = false // FIXME: JIGSAW -- support this with modules 2197 2198 test { 2199 enabled = false // FIXME: JIGSAW -- support this with modules 2200 logger.info("JIGSAW Testing disabled for fxpackagerservices") 2201 } 2202 } 2203 2204 project(":fxpackager") { 2205 project.ext.buildModule = COMPILE_FXPACKAGER 2206 project.ext.moduleRuntime = false 2207 project.ext.moduleName = "jdk.packager" 2208 2209 sourceSets { 2210 main 2211 //shims // no test shims needed 2212 test 2213 } 2214 2215 project.ext.moduleSourcePath = defaultModuleSourcePath 2216 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 2217 2218 commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'fxpackagerservices', 'fxpackager' ]) 2219 2220 manifest { 2221 attributes( 2222 "Main-Class": "com.sun.javafx.tools.packager.Main" 2223 ) 2224 } 2225 2226 tasks.all { 2227 if (!COMPILE_FXPACKAGER) it.enabled = false 2228 } 2229 2230 sourceSets { 2231 main 2232 antplugin { 2233 java { 2234 compileClasspath += main.output 2235 runtimeClasspath += main.output 2236 } 2237 } 2238 test 2239 } 2240 2241 // fxpackager has a dependency on ant in order to build the ant jar, 2242 // and as such needs to point to the apache binary repository 2243 if (!BUILD_CLOSED) { 2244 repositories { 2245 maven { 2246 url "https://repository.apache.org" 2247 } 2248 } 2249 } 2250 2251 dependencies { 2252 antpluginCompile group: "org.apache.ant", name: "ant", version: "1.8.2" 2253 2254 testCompile project(":controls"), 2255 group: "org.apache.ant", name: "ant", version: "1.8.2", 2256 sourceSets.antplugin.output 2257 } 2258 2259 //Note: these should be reflected in the module-info additions passed to the JDK 2260 compileJava.options.compilerArgs.addAll([ 2261 "--add-exports=java.base/sun.security.timestamp=jdk.packager", 2262 "--add-exports=java.base/sun.security.x509=jdk.packager", 2263 "--add-exports=jdk.jdeps/com.sun.tools.jdeps=jdk.packager", 2264 "--add-exports=jdk.jlink/jdk.tools.jlink.internal.packager=jdk.packager", 2265 2266 // Note: not in extras... 2267 "--add-exports=java.base/sun.security.pkcs=jdk.packager", 2268 "--add-exports=java.logging/java.util.logging=jdk.packager", 2269 ]) 2270 2271 compileAntpluginJava.dependsOn([ compileJava, processResources ]) 2272 compileAntpluginJava.options.compilerArgs.addAll( 2273 computeModulePathArgs("antlib", project.moduleChain, false)) 2274 2275 task buildVersionFile() { 2276 File dir = new File("${project.projectDir}/build/resources/antplugin/resources"); 2277 dir.mkdirs() 2278 File versionFile = new File(dir, "/version.properties"); 2279 if (!versionFile.exists()) { 2280 versionFile << "version=$RELEASE_VERSION\n" 2281 } 2282 outputs.file(versionFile) 2283 } 2284 2285 // When producing the ant-javafx.jar, we need to relocate a few class files 2286 // from their normal location to a resources/classes or resources/web-files 2287 // location 2288 task antpluginJar(type: Jar, dependsOn: [ compileJava, jar, compileAntpluginJava, buildVersionFile ]) { 2289 includeEmptyDirs = false 2290 archiveName = "ant-javafx.jar" 2291 2292 from (sourceSets.antplugin.output) { 2293 eachFile { FileCopyDetails details -> 2294 if (details.path.startsWith("com/javafx/main")) { 2295 details.path = "resources/classes/$details.path" 2296 } 2297 } 2298 } 2299 2300 from (sourceSets.main.resources) { 2301 includes = [ "com/sun/javafx/tools/ant/antlib.xml" ] 2302 } 2303 2304 from (sourceSets.main.output.resourcesDir) { 2305 includes = [ "resources/web-files/**" ] 2306 } 2307 } 2308 2309 assemble.dependsOn(antpluginJar) 2310 2311 // The "man" task will create a $buildDir/man containing the man 2312 // files for the system being built 2313 task man(type: Copy) { 2314 includeEmptyDirs = false 2315 enabled = (IS_LINUX || IS_MAC) && COMPILE_FXPACKAGER 2316 from "src/main/man" 2317 into "$buildDir/man" 2318 exclude "**/*.html" 2319 if (IS_MAC) exclude "**/ja_JP.UTF-8/**" 2320 } 2321 processResources.dependsOn man 2322 2323 String buildClassesDir = "${sourceSets.main.output.classesDir}/${moduleName}" 2324 2325 // Compile the native launchers. These are included in jdk.packager.jmod. 2326 if (IS_WINDOWS && COMPILE_FXPACKAGER) { 2327 task buildWinLauncher(type: CCTask, group: "Build") { 2328 description = "Compiles native sources for the application co-bundle launcher"; 2329 matches = "WinLauncher\\.cpp"; 2330 params.addAll(WIN.launcher.ccFlags); 2331 output(file("$buildDir/native/WinLauncher")); 2332 source(file("src/main/native/launcher/win")); 2333 compiler = WIN.launcher.compiler 2334 exe = true; 2335 linkerOptions.addAll(WIN.launcher.linkFlags); 2336 doLast { 2337 copy { 2338 from "$buildDir/native/WinLauncher/WinLauncher.exe" 2339 from "$MSVCR" 2340 from "$MSVCP" 2341 into "${buildClassesDir}/main/com/oracle/tools/packager/windows" 2342 } 2343 } 2344 } 2345 task compileWinLibrary(type: CCTask, group: "Build") { 2346 description = "Compiles native sources for the application co-bundle launcher library"; 2347 matches = ".*\\.cpp" 2348 source(file("src/main/native/library/common")); 2349 params.addAll(WIN.launcherlibrary.ccFlags) 2350 output(file("$buildDir/native/WinLauncher/obj")); 2351 compiler = WIN.launcherlibrary.compiler 2352 } 2353 task linkWinLibrary(type: LinkTask, group: "Build", dependsOn: compileWinLibrary) { 2354 description = "Links native sources for the application co-bundle launcher library"; 2355 objectDir = file("$buildDir/native/WinLauncher/obj") 2356 linkParams.addAll(WIN.launcherlibrary.linkFlags); 2357 lib = file("$buildDir/native/WinLauncher/packager.dll") 2358 linker = WIN.launcherlibrary.linker 2359 doLast { 2360 copy { 2361 from "$buildDir/native/WinLauncher/packager.dll" 2362 into "${buildClassesDir}/com/oracle/tools/packager/windows" 2363 } 2364 } 2365 } 2366 task buildWinLauncherSvc(type: CCTask, group: "Build") { 2367 description = "Compiles native sources for the application co-bundle launcher"; 2368 matches = "WinLauncherSvc\\.cpp"; 2369 params.addAll(WIN.launcher.ccFlags); 2370 output(file("$buildDir/native/WinLauncherSvc")); 2371 source(file("src/main/native/service/win")); 2372 compiler = WIN.launcher.compiler 2373 exe = true; 2374 linkerOptions.addAll(WIN.launcher.linkFlags); 2375 doLast { 2376 copy { 2377 from "$buildDir/native/WinLauncherSvc/WinLauncherSvc.exe" 2378 into "${buildClassesDir}/com/oracle/tools/packager/windows" 2379 } 2380 } 2381 } 2382 task buildIconSwap(type: CCTask, group: "Build") { 2383 description = "Compiles native sources for the application co-bundle launcher" 2384 matches = "IconSwap\\.cpp" 2385 params.addAll(WIN.iconLauncher.ccFlags) 2386 output(file("$buildDir/native/IconSwap")) 2387 source file("src/main/native/tools/win/iconswap") 2388 compiler = WIN.launcher.compiler 2389 exe = true 2390 linkerOptions.addAll(WIN.iconLauncher.linkFlags) 2391 doLast { 2392 copy { 2393 from "$buildDir/native/IconSwap/IconSwap.exe" 2394 into "${buildClassesDir}/com/oracle/tools/packager/windows" 2395 } 2396 } 2397 } 2398 task compileVersionInfoSwap(type: CCTask, group: "Build") { 2399 description = "Compiles native sources for the VersionInfoSwap tool"; 2400 matches = ".*\\.cpp" 2401 source(file("src/main/native/tools/win/versioninfoswap")); 2402 params.addAll(WIN.versionInfoLauncher.ccFlags) 2403 output(file("$buildDir/native/VersionInfoSwap/obj")); 2404 compiler = WIN.versionInfoLauncher.compiler 2405 } 2406 task linkVersionInfoSwap(type: LinkTask, group: "Build", dependsOn: compileVersionInfoSwap) { 2407 description = "Links native sources for the VersionInfoSwap tool"; 2408 objectDir = file("$buildDir/native/VersionInfoSwap/obj") 2409 linkParams.addAll(WIN.versionInfoLauncher.linkFlags); 2410 lib = file("$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe") 2411 linker = WIN.versionInfoLauncher.linker 2412 doLast { 2413 copy { 2414 from "$buildDir/native/VersionInfoSwap/VersionInfoSwap.exe" 2415 into "${buildClassesDir}/com/oracle/tools/packager/windows" 2416 } 2417 } 2418 } 2419 task compileLauncher(dependsOn: [buildWinLauncher, linkWinLibrary, buildWinLauncherSvc, buildIconSwap, linkVersionInfoSwap]) 2420 } else if (IS_MAC && COMPILE_FXPACKAGER) { 2421 task buildMacLauncher(type: CCTask, group: "Build") { 2422 description = "Compiles native sources for the application co-bundle launcher" 2423 matches = ".*\\.m" 2424 source file("src/main/native/launcher/mac") 2425 params.addAll(MAC.launcher.ccFlags) 2426 compiler = MAC.launcher.compiler 2427 output(file("${buildClassesDir}/com/oracle/tools/packager/mac")) 2428 outputs.file(file("${buildClassesDir}/main/com/oracle/tools/packager/mac/JavaAppLauncher")) 2429 eachOutputFile = { f -> 2430 return new File(f.getParent(), "JavaAppLauncher") 2431 } 2432 } 2433 task compileMacLibrary(type: CCTask, group: "Build") { 2434 description = "Compiles native sources for the application co-bundle launcher library" 2435 matches = ".*\\.cpp|.*\\.mm" 2436 source file("src/main/native/library/common"); 2437 params.addAll(MAC.launcherlibrary.ccFlags) 2438 compiler = MAC.launcherlibrary.compiler 2439 output(file("$buildDir/native/maclauncher/obj")) 2440 } 2441 task linkMacLibrary(type: LinkTask, group: "Build", dependsOn: compileMacLibrary) { 2442 description = "Links native sources for the application co-bundle launcher library" 2443 objectDir = file("$buildDir/native/maclauncher/obj") 2444 linkParams.addAll(MAC.launcherlibrary.linkFlags) 2445 linker = MAC.launcherlibrary.linker 2446 lib = file("${buildClassesDir}/com/oracle/tools/packager/mac/libpackager.dylib") 2447 } 2448 task compileLauncher(dependsOn: [buildMacLauncher, linkMacLibrary]) 2449 } else if (IS_LINUX && COMPILE_FXPACKAGER) { 2450 task compileLinuxLauncher(type: CCTask, group: "Build") { 2451 description = "Compiles native sources for the application co-bundle launcher" 2452 matches = ".*\\.cpp" 2453 source file("src/main/native/launcher/linux") 2454 params.addAll(LINUX.launcher.ccFlags) 2455 compiler = LINUX.launcher.compiler 2456 output(file("$buildDir/native/linuxlauncher/launcherobj")) 2457 } 2458 task linkLinuxLauncher(type: LinkTask, dependsOn: compileLinuxLauncher, group: "Build") { 2459 description = "Links native dynamic library for the application co-bundle launcher" 2460 objectDir = file("$buildDir/native/linuxlauncher/launcherobj") 2461 linkParams.addAll(LINUX.launcher.linkFlags) 2462 linker = LINUX.launcher.linker 2463 lib = file("${buildClassesDir}/com/oracle/tools/packager/linux/JavaAppLauncher") 2464 } 2465 task compileLinuxLibrary(type: CCTask, group: "Build") { 2466 description = "Compiles native sources for the application co-bundle launcher library" 2467 matches = ".*\\.cpp" 2468 source file("src/main/native/library/common") 2469 params.addAll(LINUX.launcherlibrary.ccFlags) 2470 compiler = LINUX.launcherlibrary.compiler 2471 output(file("$buildDir/native/linuxlauncher/obj")) 2472 } 2473 task linkLinuxLibrary(type: LinkTask, dependsOn: compileLinuxLibrary, group: "Build") { 2474 description = "Links native dynamic library for the application co-bundle launcher library" 2475 objectDir = file("$buildDir/native/linuxlauncher/obj") 2476 linkParams.addAll(LINUX.launcherlibrary.linkFlags) 2477 linker = LINUX.launcherlibrary.linker 2478 lib = file("${buildClassesDir}/com/oracle/tools/packager/linux/libpackager.so") 2479 } 2480 task compileLauncher(dependsOn: [linkLinuxLauncher, linkLinuxLibrary]) 2481 } 2482 2483 // Builds the javapackager executable. For everything other than windows, 2484 // this is simply moving the existing shell script and ensuring it has proper 2485 // permissions. For Windows, this includes compiling the native executable 2486 if (IS_WINDOWS && COMPILE_FXPACKAGER){ 2487 task buildJavaPackager(type: CCTask, group: "Build") { 2488 description = "Compiles native sources for javapackager.exe" 2489 matches = "javapackager\\.cpp" 2490 params.addAll(WIN.fxpackager.ccFlags) 2491 compiler = WIN.fxpackager.compiler 2492 output(file("$buildDir/native/javapackager")) 2493 source WIN.fxpackager.nativeSource 2494 doFirst { 2495 copy { 2496 mkdir "$buildDir/native" 2497 mkdir "$buildDir/native/javapackager" 2498 from file("src/main/native/javapackager/win/javapackager.manifest") 2499 into file("$buildDir/native/javapackager") 2500 filter { line-> 2501 line = line.replace("FXVERSION", RELEASE_VERSION_PADDED) 2502 } 2503 } 2504 } 2505 doLast { 2506 mkdir "$buildDir/native" 2507 exec { 2508 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2509 commandLine(WIN.fxpackager.rcCompiler) 2510 args(WIN.fxpackager.rcFlags) 2511 args("/fo$buildDir/native/javapackager/javapackager.res") 2512 args(WIN.fxpackager.rcSource) 2513 } 2514 } 2515 doLast { 2516 mkdir "$buildDir/javapackager" 2517 exec({ 2518 commandLine("$WIN.fxpackager.linker", "/nologo", "/opt:REF", "/incremental:no", "/manifest", "kernel32.lib", "advapi32.lib", 2519 "/out:$buildDir/native/javapackager/javapackager.exe", 2520 "$buildDir/native/javapackager/javapackager.obj", 2521 "$buildDir/native/javapackager/javapackager.res") 2522 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2523 }) 2524 } 2525 doLast { 2526 exec({ 2527 commandLine("$MC", "-manifest", 2528 "$buildDir/native/javapackager/javapackager.manifest", 2529 "-outputresource:$buildDir/native/javapackager/javapackager.exe") 2530 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2531 }) 2532 copy { 2533 from file("$buildDir/native/javapackager/javapackager.exe") 2534 into file("$buildDir/javapackager") 2535 } 2536 } 2537 } 2538 } else { 2539 task buildJavaPackager(group: "Build") { 2540 enabled = COMPILE_FXPACKAGER 2541 doLast { 2542 copy { 2543 from "src/main/native/javapackager/shell" 2544 into "$buildDir/javapackager" 2545 fileMode = 0755 2546 } 2547 } 2548 } 2549 } 2550 2551 assemble.dependsOn compileLauncher; 2552 assemble.dependsOn buildJavaPackager 2553 2554 classes << { 2555 // Copy all of the download libraries to libs directory for the sake of the IDEs 2556 File libsDir = rootProject.file("build/libs"); 2557 File antLib = new File(libsDir, "ant-1.8.2.jar") 2558 libsDir.mkdirs(); 2559 2560 // Skip copy if file is present. 2561 if (antLib.exists()) return; 2562 2563 for (File f : configurations.compile.files) { 2564 copy { 2565 into libsDir 2566 from f.getParentFile() 2567 include "**/ant-1.8.2.jar" 2568 includeEmptyDirs = false 2569 } 2570 } 2571 } 2572 2573 task packagerFakeJar(type: Jar) { 2574 dependsOn compileTestJava 2575 from compileTestJava.destinationDir 2576 include "hello/**" 2577 2578 destinationDir project.file("build/tmp/tests/appResources") 2579 archiveName "mainApp.jar" 2580 2581 manifest { 2582 attributes( 2583 "Main-Class": "hello.HelloRectangle", 2584 "Custom-Attribute": " Is it stripped?" 2585 ) 2586 } 2587 2588 doFirst { 2589 copy { 2590 from "$projectDir/src/main/resources/com/oracle/tools/packager/linux/javalogo_white_48.png" 2591 from "$projectDir/src/main/resources/com/oracle/tools/packager/mac/GenericAppHiDPI.icns" 2592 from "$projectDir/src/main/resources/com/oracle/tools/packager/windows/javalogo_white_48.ico" 2593 from "$projectDir/src/test/resources/hello/java-logo2.gif" 2594 from "$projectDir/src/test/resources/hello/small.ico" 2595 from "$projectDir/src/test/resources/hello/test.icns" 2596 from "$projectDir/src/test/resources/hello/LICENSE-RTF.rtf" 2597 from "$projectDir/../../LICENSE" 2598 into project.file("$projectDir/build/tmp/tests/appResources") 2599 } 2600 copy { 2601 from "$projectDir/../../LICENSE" 2602 into project.file("$projectDir/build/tmp/tests/appResources") 2603 rename '(.*)LICENSE', '$1LICENSE2' 2604 } 2605 } 2606 } 2607 2608 task packagerFXPackagedJar(type: Jar) { 2609 dependsOn packagerFakeJar 2610 from compileTestJava.destinationDir 2611 include "hello/**" 2612 2613 destinationDir project.file("build/tmp/tests/appResources") 2614 archiveName "packagedMainApp.jar" 2615 2616 manifest { 2617 attributes( 2618 "JavaFX-Application-Class": "hello.TestPackager", 2619 ) 2620 } 2621 } 2622 2623 if (!DO_BUILD_SDK_FOR_TEST) { 2624 def antJavafxJar = new File(TEST_SDK_DIR, "lib/ant-javafx.jar") 2625 [compileTestJava, test].each { 2626 it.classpath = files(antJavafxJar) + it.classpath 2627 } 2628 } 2629 2630 compileTestJava.enabled = false // FIXME: JIGSAW -- support this with modules 2631 test { 2632 enabled = false // FIXME: JIGSAW -- support this with modules 2633 logger.info("JIGSAW Testing disabled for fxpackager") 2634 2635 dependsOn packagerFXPackagedJar 2636 systemProperty "RETAIN_PACKAGER_TESTS", RETAIN_PACKAGER_TESTS 2637 systemProperty "TEST_PACKAGER_DMG", TEST_PACKAGER_DMG 2638 systemProperty "FULL_TEST", FULL_TEST 2639 executable = JAVA; 2640 } 2641 2642 def packagerDevOpts = [] 2643 try { 2644 packagerDevOpts.addAll(PACKAGER_DEV_OPTS.split(' ')) 2645 } catch (MissingPropertyException ignore) { 2646 packagerDevOpts.addAll("image") 2647 } 2648 2649 task packagerDev(dependsOn: [jar, testClasses, packagerFakeJar], type:JavaExec) { 2650 workingDir = project.file("build/tmp/tests/appResources/") 2651 executable = JAVA 2652 classpath = project.files("build/libs/ant-javafx.jar", "build/classes/test", "build/resources/test") 2653 main = "hello.SimpleBundle" 2654 args = [ 2655 '--module-path', JDK_JMODS, 2656 '-o', "$projectDir/build/dev", 2657 '-all', 2658 packagerDevOpts 2659 ].flatten() 2660 } 2661 2662 task buildRedistributableFiles() { 2663 def projectDir = "tools/java/redistributable-files" 2664 def sourceDir = "src/$projectDir" 2665 def buildDir = "build/$projectDir" 2666 2667 doLast { 2668 exec { 2669 commandLine(JAVAC) 2670 args("-d") 2671 args("$buildDir") 2672 args("$sourceDir/RedistributableFiles.java") 2673 } 2674 } 2675 } 2676 2677 task runRedistributableFiles() { 2678 def projectDir = "tools/java/redistributable-files" 2679 def sourceDir = "src/$projectDir" 2680 def buildDir = "build/$projectDir" 2681 def resourceDir = "build/resources/main/jdk/packager/internal/resources/tools/redistributable-files" 2682 2683 doLast { 2684 def fxmodules = "" 2685 2686 if (!file("$JDK_JMODS/jdk.packager.jmod").exists()) { 2687 moduleProjList.each { project -> 2688 if (fxmodules.isEmpty()) { 2689 fxmodules = project.ext.moduleName 2690 } 2691 else { 2692 fxmodules += "," + project.ext.moduleName 2693 } 2694 } 2695 } 2696 2697 exec { 2698 commandLine(JAVA) 2699 args("-classpath") 2700 args("$buildDir") 2701 args("RedistributableFiles") 2702 args("--module-path") 2703 args("$JDK_JMODS") 2704 args("--exclude-filelist") 2705 args("$sourceDir/exclude_modules.list") 2706 args("--out-file") 2707 args("$resourceDir/redistributable.list") 2708 2709 if (!fxmodules.isEmpty()) { 2710 args("--add-modules") 2711 args("$fxmodules") 2712 } 2713 } 2714 } 2715 } 2716 2717 runRedistributableFiles.dependsOn buildRedistributableFiles 2718 processResources.dependsOn runRedistributableFiles 2719 } 2720 2721 project(":media") { 2722 configurations { 2723 media 2724 } 2725 2726 project.ext.buildModule = true 2727 project.ext.moduleRuntime = true 2728 project.ext.moduleName = "javafx.media" 2729 2730 sourceSets { 2731 main 2732 //shims // no test shims needed 2733 test 2734 tools { 2735 java.srcDir "src/tools/java" 2736 } 2737 } 2738 2739 project.ext.moduleSourcePath = defaultModuleSourcePath 2740 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 2741 2742 commonModuleSetup(project, [ 'base', 'graphics', 'media' ]) 2743 2744 dependencies { 2745 } 2746 2747 compileJava.dependsOn updateCacheIfNeeded 2748 2749 compileJava { 2750 // generate the native headers during compile 2751 options.compilerArgs.addAll([ 2752 '-h', "${project.buildDir}/gensrc/headers" 2753 ]) 2754 } 2755 2756 compileToolsJava { 2757 enabled = IS_COMPILE_MEDIA 2758 options.compilerArgs.addAll(project.modulePathArgs) 2759 options.compilerArgs.addAll([ 2760 '--add-exports', 'javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED', 2761 ]) 2762 } 2763 2764 project.ext.makeJobsFlag = IS_WINDOWS && IS_DEBUG_NATIVE ? "-j1" : "-j5"; 2765 project.ext.buildType = IS_DEBUG_NATIVE ? "Debug" : "Release"; 2766 2767 def nativeSrcDir = file("${projectDir}/src/main/native") 2768 def generatedHeadersDir = file("${buildDir}/gensrc/headers/${project.moduleName}") 2769 2770 task generateMediaErrorHeader(dependsOn: [compileToolsJava, compileJava]) { 2771 enabled = IS_COMPILE_MEDIA 2772 def headerpath = file("$generatedHeadersDir/jfxmedia_errors.h"); 2773 doLast { 2774 def classpath = files(sourceSets.tools.output); 2775 def sourcepath = sourceSets.main.java.srcDirs; 2776 def srcRoot = (sourcepath.toArray())[0]; 2777 2778 mkdir generatedHeadersDir; 2779 2780 exec { 2781 commandLine("$JAVA"); 2782 args += patchModuleArgs 2783 args += [ '--add-exports=javafx.media/com.sun.media.jfxmedia=ALL-UNNAMED' ] 2784 args += [ '-classpath', "${classpath.asPath}" ] 2785 args += [ "headergen.HeaderGen", "$headerpath", "$srcRoot" ] 2786 } 2787 } 2788 outputs.file(project.file("$headerpath")) 2789 } 2790 2791 task buildNativeTargets { 2792 enabled = IS_COMPILE_MEDIA 2793 } 2794 2795 compileTargets { t-> 2796 def targetProperties = project.rootProject.ext[t.upper] 2797 def nativeOutputDir = file("${buildDir}/native/${t.name}") 2798 def projectDir = t.name.startsWith("arm") ? "linux" : t.name 2799 def mediaProperties = targetProperties.media 2800 // Makefile for OSX needs to know if we're building for parfait 2801 def compileParfait = IS_COMPILE_PARFAIT ? "true" : "false" 2802 2803 def buildNative = task("build${t.capital}Native", dependsOn: [generateMediaErrorHeader]) { 2804 enabled = targetProperties.compileMediaNative 2805 if (!targetProperties.compileMediaNative) { 2806 println("Not compiling native Media for ${t.name} per configuration request"); 2807 } 2808 2809 doLast { 2810 exec { 2811 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/jfxmedia/projects/${projectDir}") 2812 args("JAVA_HOME=${JDK_HOME}", "GENERATED_HEADERS_DIR=${generatedHeadersDir}", 2813 "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=jfxmedia", 2814 "COMPILE_PARFAIT=${compileParfait}", 2815 IS_64 ? "ARCH=x64" : "ARCH=x32", 2816 "CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}") 2817 2818 if (t.name == "win") { 2819 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2820 args( "RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.jfxmediaRcFile}") 2821 } else { 2822 if (t.name.startsWith("arm")) { 2823 args("EXTRA_CFLAGS=${mediaProperties.extra_cflags}", "EXTRA_LDFLAGS=${mediaProperties.extra_ldflags}") 2824 } else { 2825 args("HOST_COMPILE=1") 2826 } 2827 } 2828 } 2829 } 2830 } 2831 2832 // check for the property disable${name} = true 2833 def boolean disabled = targetProperties.containsKey('disableMedia') ? targetProperties.get('disableMedia') : false 2834 if (!disabled) { 2835 // Building GStreamer 2836 def buildGStreamer = task("build${t.capital}GStreamer") { 2837 enabled = IS_COMPILE_MEDIA 2838 doLast { 2839 exec { 2840 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/${projectDir}/gstreamer-lite") 2841 args("OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=gstreamer-lite", 2842 IS_64 ? "ARCH=x64" : "ARCH=x32", "CC=${mediaProperties.compiler}", 2843 "AR=${mediaProperties.ar}", "LINKER=${mediaProperties.linker}") 2844 2845 if (t.name == "win") { 2846 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2847 args("RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.gstreamerRcFile}") 2848 } 2849 } 2850 } 2851 } 2852 2853 def buildPlugins = task("build${t.capital}Plugins", dependsOn: buildGStreamer) { 2854 enabled = IS_COMPILE_MEDIA 2855 2856 if (!project.ext.properties.containsKey("ON2_SRCDIR")) { 2857 project.ext.ON2_SRCDIR = ""; 2858 } 2859 2860 if (!project.ext.properties.containsKey("ON2_LIB")) { 2861 project.ext.ON2_LIB = ""; 2862 } 2863 2864 doLast { 2865 exec { 2866 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/${projectDir}/fxplugins") 2867 args("OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=fxplugins", 2868 "ON2_SRCDIR=${project.ext.ON2_SRCDIR}", "ON2_LIB=${project.ext.ON2_LIB}", 2869 IS_64 ? "ARCH=x64" : "ARCH=x32", 2870 "CC=${mediaProperties.compiler}", "AR=${mediaProperties.ar}", "LINKER=${mediaProperties.linker}") 2871 2872 if (t.name == "win") { 2873 Map winEnv = new HashMap(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2874 2875 String sdkDir = System.getenv("BASECLASSES_SDK_DIR"); 2876 if (sdkDir == null) { 2877 sdkDir = "C:/Program Files/Microsoft SDKs/Windows/v7.1" // Default value 2878 winEnv["BASECLASSES_SDK_DIR"] = sdkDir 2879 } 2880 environment(winEnv) 2881 2882 args("RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.fxpluginsRcFile}") 2883 } 2884 } 2885 } 2886 } 2887 2888 buildNative.dependsOn buildPlugins 2889 2890 if (t.name == "linux") { 2891 def buildAVPlugin = task( "buildAVPlugin", dependsOn: [buildPlugins]) { 2892 enabled = IS_COMPILE_MEDIA 2893 2894 doLast { 2895 if (project.ext.properties.containsKey("libav")) { 2896 project.ext.libav.versions.each { version -> 2897 def libavDir = "${project.ext.libav.basedir}-${version}" 2898 File dir = file(libavDir) 2899 if (dir.exists()) { 2900 exec { 2901 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin") 2902 args("CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}", 2903 "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 2904 "BASE_NAME=avplugin", "VERSION=${version}", "LIBAV_DIR=${libavDir}", 2905 "SUFFIX=", IS_64 ? "ARCH=x64" : "ARCH=x32") 2906 } 2907 } 2908 } 2909 2910 project.ext.libav.ffmpeg.versions.each { version -> 2911 def libavDir = "${project.ext.libav.ffmpeg.basedir}-${version}" 2912 File dir = file(libavDir) 2913 if (dir.exists()) { 2914 exec { 2915 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin") 2916 args("CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}", 2917 "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 2918 "BASE_NAME=avplugin", "VERSION=${version}", "LIBAV_DIR=${libavDir}", 2919 "SUFFIX=-ffmpeg", IS_64 ? "ARCH=x64" : "ARCH=x32") 2920 } 2921 } 2922 } 2923 } else { 2924 // Building fxavcodec plugin (libav plugin) 2925 exec { 2926 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/linux/avplugin") 2927 args("CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}", 2928 "OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", 2929 "BASE_NAME=avplugin", IS_64 ? "ARCH=x64" : "ARCH=x32") 2930 } 2931 } 2932 } 2933 } 2934 buildNative.dependsOn buildAVPlugin 2935 } 2936 2937 if (t.name == "win") { 2938 def buildResources = task("buildResources") << { 2939 def rcOutputDir = "${nativeOutputDir}/${buildType}" 2940 mkdir rcOutputDir 2941 exec { 2942 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2943 commandLine (WIN.media.rcCompiler) 2944 args(WIN.media.glibRcFlags) 2945 args("/Fo${rcOutputDir}/${WIN.media.glibRcFile}", WIN.media.rcSource) 2946 } 2947 2948 exec { 2949 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2950 commandLine (WIN.media.rcCompiler) 2951 args(WIN.media.gstreamerRcFlags) 2952 args("/Fo${rcOutputDir}/${WIN.media.gstreamerRcFile}", WIN.media.rcSource) 2953 } 2954 2955 exec { 2956 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2957 commandLine (WIN.media.rcCompiler) 2958 args(WIN.media.fxpluginsRcFlags) 2959 args("/Fo${rcOutputDir}/${WIN.media.fxpluginsRcFile}", WIN.media.rcSource) 2960 } 2961 2962 exec { 2963 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2964 commandLine (WIN.media.rcCompiler) 2965 args(WIN.media.jfxmediaRcFlags) 2966 args("/Fo${rcOutputDir}/${WIN.media.jfxmediaRcFile}", WIN.media.rcSource) 2967 } 2968 } 2969 2970 def buildGlib = task("build${t.capital}Glib", dependsOn: [buildResources]) { 2971 enabled = IS_COMPILE_MEDIA 2972 doLast { 2973 exec { 2974 environment(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 2975 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/${projectDir}/glib-lite") 2976 args("OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=glib-lite", 2977 IS_64 ? "ARCH=x64" : "ARCH=x32", "RESOURCE=${nativeOutputDir}/${buildType}/${WIN.media.glibRcFile}", 2978 "CC=${mediaProperties.compiler}", "AR=${mediaProperties.ar}", "LINKER=${mediaProperties.linker}") 2979 } 2980 } 2981 } 2982 buildGStreamer.dependsOn buildGlib 2983 2984 } else if (t.name == "mac") { 2985 def buildGlib = task("build${t.capital}Glib") { 2986 enabled = IS_COMPILE_MEDIA 2987 doLast { 2988 exec { 2989 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/${projectDir}/libffi") 2990 args("OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=ffi") 2991 args ("CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}", "AR=${mediaProperties.ar}") 2992 } 2993 2994 exec { 2995 commandLine ("make", "${makeJobsFlag}", "-C", "${nativeSrcDir}/gstreamer/projects/${projectDir}/glib-lite") 2996 args("OUTPUT_DIR=${nativeOutputDir}", "BUILD_TYPE=${buildType}", "BASE_NAME=glib-lite") 2997 args ("CC=${mediaProperties.compiler}", "LINKER=${mediaProperties.linker}") 2998 } 2999 } 3000 } 3001 buildGStreamer.dependsOn buildGlib 3002 } 3003 } 3004 3005 buildNativeTargets.dependsOn buildNative 3006 } 3007 3008 jar { 3009 exclude("headergen/**") 3010 3011 dependsOn compileJava 3012 if (IS_COMPILE_MEDIA) { 3013 dependsOn buildNativeTargets 3014 } 3015 } 3016 } 3017 3018 project(":web") { 3019 configurations { 3020 webkit 3021 } 3022 project.ext.buildModule = true 3023 project.ext.moduleRuntime = true 3024 project.ext.moduleName = "javafx.web" 3025 3026 sourceSets { 3027 main 3028 shims 3029 test 3030 } 3031 3032 project.ext.moduleSourcePath = defaultModuleSourcePath 3033 project.ext.moduleSourcePathShim = defaultModuleSourcePathShim 3034 3035 commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'media', 'web' ]) 3036 3037 dependencies { 3038 } 3039 3040 compileJava.dependsOn updateCacheIfNeeded 3041 3042 task webArchiveJar(type: Jar) { 3043 from (project.file("$projectDir/src/test/resources/test/html")) { 3044 include "**/archive-*.*" 3045 } 3046 archiveName = "webArchiveJar.jar" 3047 destinationDir = file("$buildDir/testing/resources") 3048 } 3049 3050 def gensrcDir = "${buildDir}/gensrc/java" 3051 3052 // add in the wrappers to the compile 3053 sourceSets.main.java.srcDirs += "${gensrcDir}" 3054 3055 if (IS_COMPILE_WEBKIT) { 3056 compileJava { 3057 // generate the native headers during compile 3058 // only needed if we are doing the native compile 3059 options.compilerArgs.addAll([ 3060 '-h', "${project.buildDir}/gensrc/headers" 3061 ]) 3062 } 3063 } else { 3064 // Instead of compiling native wrappers, use a pre-generated version 3065 3066 // Copy these to a common location in the moduleSourcePath 3067 def copyWrappers = project.task("copyPreGeneratedWrappers", type: Copy) { 3068 enabled = (!IS_COMPILE_WEBKIT) 3069 3070 from "src/main/java-wrappers" 3071 into "${gensrcDir}" 3072 } 3073 3074 compileJava.dependsOn(copyWrappers); 3075 } 3076 3077 test { 3078 /* 3079 if (!IS_JIGSAW_TEST) { 3080 //TODO: support this in Jake 3081 // Run web tests in headless mode 3082 systemProperty 'glass.platform', 'Monocle' 3083 systemProperty 'monocle.platform', 'Headless' 3084 systemProperty 'prism.order', 'sw' 3085 } 3086 */ 3087 dependsOn webArchiveJar 3088 def testResourceDir = file("$buildDir/testing/resources") 3089 jvmArgs "-DWEB_ARCHIVE_JAR_TEST_DIR=$testResourceDir" 3090 } 3091 3092 // generate some headers that are not part of our build 3093 task generateHeaders(dependsOn: compileJava) { 3094 doLast { 3095 def dest = file("$buildDir/gensrc/headers/${project.moduleName}"); 3096 mkdir dest; 3097 exec { 3098 commandLine("$JAVAH", "-d", "$dest",); 3099 args("java.lang.Character", 3100 "java.net.IDN", 3101 ); 3102 } 3103 } 3104 } 3105 3106 task compileGenerated() 3107 3108 compileTargets { t -> 3109 def targetProperties = project.rootProject.ext[t.upper] 3110 def classifier = (t.name != "linux" && t.name != "win") ? t.name : 3111 IS_64 ? "${t.name}-amd64" : "${t.name}-i586" 3112 dependencies { 3113 webkit group: "com.sun.webkit", name: "webview-deps", 3114 version: "1.3.1", classifier: "$classifier", ext: "zip" 3115 } 3116 3117 def webkitOutputDir = cygpath("$buildDir/${t.name}") 3118 def webkitConfig = IS_DEBUG_NATIVE ? "Debug" : "Release" 3119 3120 def compileNativeTask = task("compileNative${t.capital}", dependsOn: [generateHeaders, compileJava]) { 3121 println "Building Webkit configuration /$webkitConfig/ into $webkitOutputDir" 3122 enabled = (IS_COMPILE_WEBKIT) 3123 3124 outputs.dir("$webkitOutputDir/$webkitConfig/DerivedSources/WebCore/nativeJava/java") 3125 3126 doLast { 3127 def dependencyFile = configurations.webkit.filter( 3128 { File f -> f.getName().contains(classifier) } 3129 ).getSingleFile() 3130 ant.unzip(src: dependencyFile, 3131 dest: webkitOutputDir) 3132 3133 exec { 3134 workingDir("$projectDir/src/main/native") 3135 commandLine("perl", "Tools/Scripts/set-webkit-configuration", "--$webkitConfig") 3136 environment(["WEBKIT_OUTPUTDIR" : webkitOutputDir]) 3137 } 3138 3139 exec { 3140 workingDir("$projectDir/src/main/native") 3141 def cmakeArgs = "-DENABLE_TOOLS=1" 3142 if (t.name == "win") { 3143 String parfaitPath = IS_COMPILE_PARFAIT ? System.getenv().get("PARFAIT_PATH") + ";" : ""; 3144 Map environmentSettings = new HashMap(WINDOWS_NATIVE_COMPILE_ENVIRONMENT) 3145 environmentSettings["PATH"] = parfaitPath + "$WINDOWS_VS_PATH" 3146 /* To build with ICU: 3147 1. Download http://javaweb.us.oracle.com/jcg/fx-webrevs/RT-17164/WebKitLibrariesICU.zip 3148 and unzip it to WebKitLibraries folder. 3149 2. Copy DLLs from 3150 WebKitLibrariesICU.zip\WebKitLibraries\import\runtime 3151 to %windir%\system32 3152 3. Uncomment the line below 3153 */ 3154 // args("--icu-unicode") 3155 } else if (t.name == "mac") { 3156 // Add any osx specific flags. 3157 } else if (t.name == "linux") { 3158 if (!IS_64) { 3159 cmakeArgs = "-DCMAKE_C_FLAGS=-m32 -DCMAKE_CXX_FLAGS=-m32" 3160 } 3161 } else if (t.name.startsWith("arm")) { 3162 fail("ARM target is not supported as of now.") 3163 } 3164 3165 if (IS_COMPILE_PARFAIT) { 3166 environment([ 3167 "COMPILE_PARFAIT" : "true" 3168 ]) 3169 cmakeArgs = "-DCMAKE_C_COMPILER=parfait-gcc -DCMAKE_CXX_COMPILER=parfait-g++" 3170 } 3171 3172 environment([ 3173 "JAVA_HOME" : JDK_HOME, 3174 "WEBKIT_OUTPUTDIR" : webkitOutputDir, 3175 ]) 3176 3177 def targetCpuBitDepthSwitch = "" 3178 if (IS_64) { 3179 targetCpuBitDepthSwitch = "--64-bit" 3180 } else { 3181 targetCpuBitDepthSwitch = "--32-bit" 3182 } 3183 3184 commandLine("perl", "Tools/Scripts/build-webkit", 3185 "--java", "--icu-unicode", targetCpuBitDepthSwitch, 3186 "--cmakeargs=${cmakeArgs}") 3187 } 3188 3189 def library = rootProject.ext[t.upper].library 3190 copy { 3191 from "$webkitOutputDir/$webkitConfig/lib/${library('jfxwebkit')}" 3192 into "$buildDir/libs/${t.name}" 3193 } 3194 copy { 3195 from "$webkitOutputDir/$webkitConfig/lib/${library('DumpRenderTreeJava')}" 3196 into "$buildDir/test/${t.name}" 3197 } 3198 3199 } 3200 } 3201 3202 if (IS_WINDOWS && t.name == "win") { 3203 def webkitProperties = project.rootProject.ext[t.upper].webkit 3204 def rcTask = project.task("rc${t.capital}", type: CompileResourceTask) { 3205 compiler = webkitProperties.rcCompiler 3206 source(webkitProperties.rcSource) 3207 if (webkitProperties.rcFlags) { 3208 rcParams.addAll(webkitProperties.rcFlags) 3209 } 3210 output(file("$webkitOutputDir/$webkitConfig/WebCore/obj")) 3211 } 3212 compileNativeTask.dependsOn rcTask 3213 } 3214 3215 def copyGeneratedTask = task("copyGenerated${t.capital}", dependsOn: [compileJava, compileNativeTask]) { 3216 enabled = (IS_COMPILE_WEBKIT) 3217 3218 outputs.dir "${gensrcDir}" 3219 3220 doLast{ 3221 copy { 3222 from "$projectDir/src/main/java-wrappers/com/sun/webkit/dom/EventListenerImpl.java" 3223 into "${gensrcDir}/com/sun/webkit/dom" 3224 } 3225 copy { 3226 from "$webkitOutputDir/$webkitConfig/DerivedSources/WebCore/nativeJava/java" 3227 into "${gensrcDir}" 3228 } 3229 } 3230 } 3231 3232 def compileGeneratedTask = task("compileGenerated${t.capital}", type: JavaCompile, dependsOn: copyGeneratedTask) { 3233 destinationDir = file("$buildDir/classes/main") 3234 classpath = configurations.compile 3235 source = project.sourceSets.main.java.srcDirs 3236 options.compilerArgs.addAll([ 3237 '-implicit:none', 3238 '--module-source-path', defaultModuleSourcePath 3239 ]) 3240 } 3241 3242 compileGenerated.dependsOn compileGeneratedTask 3243 3244 if (!targetProperties.compileWebnodeNative) { 3245 println("Not compiling native Webkit for ${t.name} per configuration request"); 3246 compileNativeTask.enabled = false 3247 } 3248 } 3249 3250 def drtClasses = "com/sun/javafx/webkit/drt/**" 3251 jar.exclude(drtClasses) 3252 task drtJar(type: Jar, dependsOn: compileJava) { 3253 archiveName = "drt.jar" 3254 destinationDir = file("$buildDir/test") 3255 from "$buildDir/classes/main" 3256 include drtClasses 3257 } 3258 3259 if (IS_COMPILE_WEBKIT) { 3260 assemble.dependsOn compileGenerated, drtJar 3261 } 3262 } 3263 3264 // This project is for system tests that need to run with a full SDK. 3265 // Most of them display a stage or do other things that preclude running 3266 // them in a shared JVM or as part of the "smoke test" run (which must 3267 // not pop up any windows or use audio). As such, they are only enabled 3268 // when FULL_TEST is specified, and each test runs in its own JVM 3269 project(":systemTests") { 3270 3271 project.ext.buildModule = false 3272 project.ext.moduleRuntime = false 3273 project.ext.moduleName = "systemTests" 3274 3275 dependencies { 3276 testCompile project(":graphics").sourceSets.test.output 3277 testCompile project(":base").sourceSets.test.output 3278 testCompile project(":controls").sourceSets.test.output 3279 testCompile project(":swing").sourceSets.test.output 3280 } 3281 3282 commonModuleSetup(project, [ 'base', 'graphics', 'controls', 'media', 'web', 'swing', 'fxml' ]) 3283 3284 File patchPolicyFile = new File(project.buildDir, TESTJAVAPOLICYFILE); 3285 File runArgsFile = new File(project.buildDir,RUNARGSFILE); 3286 3287 def sts = task("systemTestSetup") { 3288 outputs.file(patchPolicyFile) 3289 outputs.file(runArgsFile) 3290 3291 doLast() { 3292 runArgsFile.delete() 3293 patchPolicyFile.delete() 3294 3295 logger.info("Creating patchmodule.args file ${runArgsFile}") 3296 3297 // Create an argfile with the information needed to launch 3298 // the stand alone system unit tests. 3299 3300 //First add in all of the patch-module args we use for the 3301 //normal unit tests 3302 testPatchModuleArgs.each { str -> 3303 runArgsFile << "${str}\n" 3304 } 3305 3306 // Now add in the working classpath elements (junit, test classes...) 3307 runArgsFile << "-cp \"\\\n" 3308 test.classpath.each() { elem -> 3309 def e = cygpath("${elem}") 3310 runArgsFile << " ${e}${File.pathSeparator}\\\n" 3311 } 3312 runArgsFile << "\"\n" 3313 3314 // Now create a policy file with full paths matching the patched modules 3315 // we have provided. This needs to be in sync with testPatchModuleArgs 3316 moduleProjList.each { project -> 3317 if (project.hasProperty("moduleName") && project.buildModule) { 3318 File dir; 3319 if (test && project.sourceSets.hasProperty('shims')) { 3320 dir = new File(project.sourceSets.shims.output.classesDir, project.ext.moduleName); 3321 } else { 3322 dir = new File(project.sourceSets.main.output.classesDir, project.ext.moduleName); 3323 } 3324 3325 String themod = dir.toURI() 3326 patchPolicyFile << "grant codeBase \"${themod}\" {\n" + 3327 " permission java.security.AllPermission;\n" + 3328 "};\n" 3329 } 3330 } 3331 } 3332 } 3333 3334 test.dependsOn(sts) 3335 test.dependsOn(createTestArgfiles); 3336 3337 test { 3338 enabled = IS_FULL_TEST 3339 3340 // Properties passed to test.util.Util 3341 systemProperties 'worker.debug': IS_WORKER_DEBUG 3342 systemProperties 'worker.patchmodule.file': cygpath(runArgsFile.path) 3343 systemProperties 'worker.patch.policy': cygpath(patchPolicyFile.path) 3344 systemProperties 'worker.java.cmd': JAVA 3345 3346 if (!IS_USE_ROBOT) { 3347 // Disable all robot-based visual tests 3348 exclude("test/robot/**"); 3349 } 3350 if (!IS_AWT_TEST) { 3351 // Disable all AWT-based tests 3352 exclude("**/javafx/embed/swing/*.*"); 3353 exclude("**/com/sun/javafx/application/Swing*.*"); 3354 } 3355 3356 forkEvery = 1 3357 } 3358 } 3359 3360 allprojects { 3361 // The following block is a workaround for the fact that presently Gradle 3362 // can't set the -XDignore.symbol.file flag, because it appears that the 3363 // javac API is lacking support for it. So what we'll do is find any Compile 3364 // task and manually provide the options necessary to fire up the 3365 // compiler with the right settings. 3366 tasks.withType(JavaCompile) { compile -> 3367 if (compile.options.hasProperty("useAnt")) { 3368 compile.options.useAnt = true 3369 compile.options.useDepend = IS_USE_DEPEND 3370 } else if (compile.options.hasProperty("incremental")) { 3371 compile.options.incremental = IS_INCREMENTAL 3372 } 3373 compile.options.debug = true // we always generate debugging info in the class files 3374 compile.options.debugOptions.debugLevel = IS_DEBUG_JAVA ? "source,lines,vars" : "source,lines" 3375 compile.options.fork = true 3376 3377 compile.options.forkOptions.executable = JAVAC 3378 3379 compile.options.warnings = IS_LINT 3380 3381 compile.options.compilerArgs += ["-XDignore.symbol.file", "-encoding", "UTF-8"] 3382 3383 // If I am a module.... 3384 if (project.hasProperty('moduleSourcePath') && 3385 (project.hasProperty('buildModule') && project.buildModule)) { 3386 project.compileJava { 3387 options.compilerArgs.addAll([ 3388 '-implicit:none', 3389 '--module-source-path', project.moduleSourcePath 3390 ]) 3391 } 3392 // no jars needed for modules 3393 project.jar.enabled = false 3394 3395 // and redirect the resources into the module 3396 project.processResources.destinationDir = project.moduleDir 3397 } 3398 3399 // Add in the -Xlint options 3400 if (IS_LINT) { 3401 LINT.split("[, ]").each { s -> 3402 compile.options.compilerArgs += "-Xlint:$s" 3403 } 3404 } 3405 } // tasks with javaCompile 3406 3407 if (project.hasProperty('moduleSourcePathShim') && 3408 project.sourceSets.hasProperty('shims')) { 3409 3410 // sync up the obvious source directories with the shims 3411 // others (like the shaders in graphics) should be added in there 3412 project.sourceSets.shims.java.srcDirs += project.sourceSets.main.java.srcDirs 3413 project.sourceSets.shims.java.srcDirs += "$buildDir/gensrc/java" 3414 3415 project.compileShimsJava { 3416 options.compilerArgs.addAll([ 3417 '-implicit:none', 3418 '--module-source-path', project.moduleSourcePathShim 3419 ]) 3420 } 3421 3422 compileTestJava.dependsOn(compileShimsJava) 3423 } 3424 3425 if (project.hasProperty('modulePathArgs')) { 3426 project.compileJava.options.compilerArgs.addAll(modulePathArgs) 3427 } 3428 3429 if (project.hasProperty('testModulePathArgs')) { 3430 project.compileTestJava.options.compilerArgs.addAll(testModulePathArgs) 3431 } 3432 3433 if (project.hasProperty('testPatchModuleArgs')) { 3434 project.test.jvmArgs += testPatchModuleArgs 3435 } 3436 3437 if (project.hasProperty('addExports')) { 3438 project.compileTestJava.options.compilerArgs.addAll(addExports); 3439 project.test.jvmArgs += addExports 3440 } 3441 3442 if (rootProject.hasProperty("EXTRA_TEST_ARGS") && project.hasProperty('test')) { 3443 EXTRA_TEST_ARGS.split(' ').each() { e -> 3444 project.test.jvmArgs += e 3445 } 3446 } 3447 3448 if (rootProject.hasProperty("EXTRA_COMPILE_ARGS") && project.hasProperty('compileJava')) { 3449 project.compileJava.options.compilerArgs.addAll(EXTRA_COMPILE_ARGS.split(' ')) 3450 } 3451 3452 if (rootProject.hasProperty("EXTRA_COMPILE_ARGS") && project.hasProperty('compileTestJava')) { 3453 project.compileTestJava.options.compilerArgs.addAll(EXTRA_COMPILE_ARGS.split(' ')) 3454 } 3455 3456 } 3457 3458 /****************************************************************************** 3459 * * 3460 * Top Level Tasks * 3461 * * 3462 * These are the tasks which are defined only for the top level project and * 3463 * not for any sub projects. These are generally the entry point that is * 3464 * used by Hudson and by the continuous build system. * 3465 * * 3466 *****************************************************************************/ 3467 3468 task clean() { 3469 group = "Basic" 3470 description = "Deletes the build directory and the build directory of all sub projects" 3471 getSubprojects().each { subProject -> 3472 dependsOn(subProject.getTasksByName("clean", true)); 3473 } 3474 doLast { 3475 delete(buildDir); 3476 } 3477 } 3478 3479 task cleanAll() { 3480 group = "Basic" 3481 description = "Scrubs the repo of build artifacts" 3482 dependsOn(clean) 3483 doLast { 3484 //delete(".gradle"); This causes problems on windows. 3485 delete("buildSrc/build"); 3486 } 3487 } 3488 3489 task createMSPfile() { 3490 group = "Build" 3491 File mspFile = new File(rootProject.buildDir,MODULESOURCEPATH) 3492 outputs.file(mspFile) 3493 3494 doLast { 3495 mspFile.delete() 3496 mspFile << "--module-source-path\n" 3497 mspFile << defaultModuleSourcePath 3498 mspFile << "\n" 3499 } 3500 } 3501 3502 task javadoc(type: Javadoc, dependsOn: createMSPfile) { 3503 enabled = IS_BUILD_JAVADOC 3504 group = "Basic" 3505 description = "Generates the JavaDoc for all the public API" 3506 executable = JAVADOC 3507 def projectsToDocument = [ 3508 project(":base"), project(":graphics"), project(":controls"), project(":media"), 3509 project(":swing"), /*project(":swt"),*/ project(":fxml"), project(":web")] 3510 source(projectsToDocument.collect({ 3511 [it.sourceSets.main.java] 3512 })); 3513 setDestinationDir(new File(buildDir, 'javadoc')); 3514 3515 exclude("com/**/*", "Compile*", "javafx/builder/**/*", "javafx/scene/accessibility/**/*"); 3516 options.windowTitle("${javadocTitle}") 3517 options.header("${javadocHeader}") 3518 options.bottom("${javadocBottom}") 3519 if (BUILD_CLOSED) { 3520 options.linksOffline(JDK_DOCS, JDK_DOCS_CLOSED); 3521 } else { 3522 options.links(JDK_DOCS); 3523 } 3524 options.addBooleanOption("XDignore.symbol.file").setValue(true); 3525 options.addBooleanOption("Xdoclint:none").setValue(!IS_DOC_LINT); 3526 options.addBooleanOption("javafx").setValue(true); 3527 options.addBooleanOption("use").setValue(true); 3528 3529 options.setOptionFiles([ 3530 new File("${rootProject.buildDir}/${COMPILEARGSFILE}"), 3531 new File(rootProject.buildDir,MODULESOURCEPATH) 3532 ]); 3533 3534 doLast { 3535 projectsToDocument.each { p -> 3536 copy { 3537 from "$p.projectDir/src/main/docs" 3538 into "$buildDir/javadoc" 3539 } 3540 } 3541 } 3542 3543 dependsOn(projectsToDocument.collect { project -> project.getTasksByName("classes", true)}); 3544 } 3545 3546 task sdk() { 3547 if (DO_BUILD_SDK_FOR_TEST) { 3548 rootProject.getTasksByName("test", true).each { t -> 3549 if (t.enabled) t.dependsOn(sdk) 3550 } 3551 } 3552 } 3553 3554 task appsjar() { 3555 dependsOn(sdk) 3556 // Note: the jar dependencies get added elsewhere see project(":apps") 3557 } 3558 3559 // these are empty tasks, allowing us to depend on the task, which may have other 3560 // real work items added later. 3561 task copyAppsArtifacts() { 3562 dependsOn(appsjar) 3563 } 3564 3565 task apps() { 3566 dependsOn(sdk) 3567 dependsOn(appsjar) 3568 dependsOn(copyAppsArtifacts) 3569 } 3570 3571 task findbugs() { 3572 dependsOn(sdk) 3573 3574 doLast { 3575 if (!BUILD_CLOSED) { 3576 println "findbugs task is only run for a closed build" 3577 } 3578 } 3579 } 3580 3581 // The following tasks are for the closed build only. They are a no-op for the open build 3582 3583 task checkCache() { 3584 dependsOn(updateCacheIfNeeded) 3585 } 3586 3587 // TODO: consider moving the "public-sdk" portion of this task here 3588 task publicExports() { 3589 doFirst { 3590 if (BUILD_CLOSED && !IS_BUILD_JAVADOC) { 3591 fail("publicExports task requires: -PBUILD_JAVADOC=true") 3592 } 3593 } 3594 dependsOn(sdk) 3595 } 3596 3597 task perf() { 3598 dependsOn(sdk,apps) 3599 doLast { 3600 if (!BUILD_CLOSED) { 3601 println "perf task is only run for a closed build" 3602 } 3603 } 3604 } 3605 3606 task zips() { 3607 doFirst { 3608 if (BUILD_CLOSED && !IS_BUILD_JAVADOC) { 3609 fail("zips task requires: -PBUILD_JAVADOC=true") 3610 } 3611 } 3612 dependsOn(sdk,publicExports,apps,perf) 3613 } 3614 3615 task copySources(type: Copy) { 3616 enabled = IS_BUILD_SRC_ZIP 3617 def projectsToCopy = [ 3618 project(":base"), project(":graphics"), project(":controls"), 3619 project(":swing"), project(":swt"), project(":fxml"), 3620 project(":media"), project(":web")] 3621 from(projectsToCopy.collect({ proj -> 3622 files(proj.sourceSets.main.java.srcDirs) 3623 })) 3624 include "**/*.java" 3625 into "${buildDir}/javafx-src" 3626 } 3627 3628 task zipSources(type: Zip) { 3629 enabled = IS_BUILD_SRC_ZIP 3630 dependsOn(copySources) 3631 archiveName = "javafx-src.zip" 3632 destinationDir = file("$buildDir") 3633 includeEmptyDirs = false 3634 from "${buildDir}/javafx-src" 3635 } 3636 3637 task src { 3638 enabled = IS_BUILD_SRC_ZIP 3639 description = "Created the javafx-src.zip bundle" 3640 dependsOn(zipSources) 3641 } 3642 3643 task all() { 3644 dependsOn(sdk,publicExports,apps,perf,zips) 3645 } 3646 3647 3648 // Construct list of subprojects that are modules 3649 ext.moduleProjList = [] 3650 subprojects { 3651 if (project.hasProperty("buildModule") && project.ext.buildModule) { 3652 rootProject.ext.moduleProjList += project 3653 println "module: $project (buildModule=YES)" 3654 } else { 3655 println "module: $project (buildModule=NO)" 3656 } 3657 } 3658 3659 3660 // Create the legacy sdk from the modular-sdk 3661 3662 compileTargets { t -> 3663 //def targetProperties = project.ext[t.upper] 3664 //def platformPrefix = targetProperties.platformPrefix 3665 //def sdkDirName = "${platformPrefix}sdk" 3666 //def modularSdkDirName = "${platformPrefix}modular-sdk" 3667 //def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}" 3668 //def modulesDir = "${modularSdkDir}/modules" 3669 //def modulesCmdsDir = "${modularSdkDir}/modules_cmds" 3670 //def modulesLibsDir = "${modularSdkDir}/modules_libs" 3671 3672 // FIXME: This is not the right place to do this, but it is 3673 // basically what we need to do to build this 3674 def javafxSwtTask = task("javafxSwt$t.capital", type: Jar) { 3675 enabled = COMPILE_SWT 3676 group = "Basic" 3677 description = "Creates the javafx-swt.jar for the $t.name target" 3678 archiveName = "${project(":swt").buildDir}/libs/javafx-swt.jar"; 3679 includeEmptyDirs = false 3680 from("${project(":swt").buildDir}/classes/main"); 3681 include("**/javafx/embed/swt/**") 3682 3683 dependsOn(subprojects.collect { project -> project.getTasksByName("assemble", true)}); 3684 } 3685 3686 def javafxSwtIndexTask = task("javafxSwtIndex$t.capital") { 3687 //the following is a workaround for the lack of indexing in gradle 1.4 through 1.7 3688 dependsOn(javafxSwtTask) 3689 3690 doLast() { 3691 ant.jar (update: true, index: true, destfile: javafxSwtTask.archiveName) 3692 } 3693 } 3694 3695 def sdkTask = task("sdk$t.capital") { 3696 group = "Basic" 3697 dependsOn(javafxSwtIndexTask) 3698 dependsOn(javadoc) 3699 } 3700 3701 sdk.dependsOn(sdkTask) 3702 } 3703 3704 project(":apps") { 3705 // The apps build is Ant based, and gradle lets us "import" ant build.xml 3706 // into our configuration. 3707 3708 compileTargets { t -> 3709 List<String> params = [] 3710 3711 params << "-DtargetBld=$t.name" 3712 3713 if (!rootProject.ext[t.upper].compileSwing) { 3714 params << "-DJFX_CORE_ONLY=true" 3715 } 3716 params << "-Dplatforms.JDK_1.9.home=${rootProject.ext.JDK_HOME}" 3717 params << "-Dcompile.patch=@${rootProject.buildDir}/${COMPILEARGSFILE}" 3718 params << "-Drun.patch=@${rootProject.buildDir}/${RUNARGSFILE}" 3719 3720 def appsJar = project.task("appsJar${t.capital}") { 3721 dependsOn(sdk) 3722 doLast() { 3723 ant(t.name, 3724 projectDir.path, 3725 "appsJar", 3726 params); 3727 } 3728 } 3729 rootProject.appsjar.dependsOn(appsJar) 3730 3731 def appsClean = project.task("clean${t.capital}") { 3732 doLast() { 3733 ant(t.name, 3734 project.projectDir.path, 3735 "clean", 3736 params); 3737 } 3738 } 3739 rootProject.clean.dependsOn(appsClean) 3740 } 3741 } 3742 3743 3744 /****************************************************************************** 3745 * * 3746 * Modules * 3747 * * 3748 *****************************************************************************/ 3749 3750 ext.moduleDependencies = [file("dependencies")] 3751 3752 task buildModules { 3753 } 3754 3755 // Combine the classes, lib, and bin for each module 3756 compileTargets { t -> 3757 def targetProperties = project.ext[t.upper] 3758 3759 def platformPrefix = targetProperties.platformPrefix 3760 def modularSdkDirName = "${platformPrefix}modular-sdk" 3761 def modularSdkDir = "${rootProject.buildDir}/${modularSdkDirName}" 3762 def modulesDir = "${modularSdkDir}/modules" 3763 def modulesCmdsDir = "${modularSdkDir}/modules_cmds" 3764 def modulesLibsDir = "${modularSdkDir}/modules_libs" 3765 def modulesSrcDir = "${modularSdkDir}/modules_src" 3766 def modulesConfDir = "${modularSdkDir}/modules_conf" 3767 def modulesMakeDir = "${modularSdkDir}/make" 3768 final File runArgsFile = file("${rootProject.buildDir}/${RUNARGSFILE}") 3769 final File compileArgsFile = file("${rootProject.buildDir}/${COMPILEARGSFILE}") 3770 3771 project.files(runArgsFile); 3772 3773 def zipTask = project.task("buildModuleZip$t.capital", type: Zip, group: "Build") { 3774 enabled = IS_BUILD_MODULE_ZIP 3775 3776 // FIXME: JIGSAW -- this should be moved to a sub-directory so we can keep the same name 3777 def jfxBundle = "${platformPrefix}javafx-exports.zip" 3778 3779 doFirst() { 3780 file("${rootProject.buildDir}/${jfxBundle}").delete() 3781 } 3782 3783 archiveName = jfxBundle 3784 destinationDir = file("${rootProject.buildDir}") 3785 includeEmptyDirs = false 3786 from "${modularSdkDir}" 3787 } 3788 buildModules.dependsOn(zipTask) 3789 3790 def buildModulesTask = task("buildModules$t.capital", group: "Build") { 3791 doLast { 3792 moduleProjList.each { project -> 3793 3794 // Copy classes, bin, and lib directories 3795 3796 def moduleName = project.ext.moduleName 3797 def buildDir = project.buildDir 3798 3799 def srcClassesDir = "${buildDir}/${platformPrefix}module-classes" 3800 def dstClassesDir = "${modulesDir}/${moduleName}" 3801 copy { 3802 from srcClassesDir 3803 into dstClassesDir 3804 exclude("module-info.class") 3805 } 3806 3807 def srcCmdsDir = "${buildDir}/${platformPrefix}module-bin" 3808 def dstCmdsDir = "${modulesCmdsDir}/${moduleName}" 3809 copy { 3810 from srcCmdsDir 3811 into dstCmdsDir 3812 } 3813 3814 def srcLibsDir = "${buildDir}/${platformPrefix}module-lib" 3815 def dstLibsDir = "${modulesLibsDir}/${moduleName}" 3816 copy { 3817 from srcLibsDir 3818 into dstLibsDir 3819 } 3820 3821 // Copy module-info.java 3822 def srcModuleInfoFile = "${project.projectDir}/src/main/java/module-info.java" 3823 def dstModuleInfoDir = "${modulesSrcDir}/${moduleName}" 3824 copy { 3825 from srcModuleInfoFile 3826 into dstModuleInfoDir 3827 if (!IS_COMPILE_JFR && project.name.equals("base")) { 3828 filter { line-> line.contains("requires jdk.jfr;") ? "" : line } 3829 } 3830 } 3831 3832 // Copy make/build.properties 3833 def srcMakeDir = "${project.projectDir}/make" 3834 def dstMakeDir = "${modulesMakeDir}/${moduleName}" 3835 copy { 3836 from srcMakeDir 3837 into dstMakeDir 3838 } 3839 } 3840 3841 // Copy dependencies/*/module-info.java.extra 3842 // merging as needed, removing duplicates 3843 // only lines with 'exports' will be copied 3844 def dependencyRoots = moduleDependencies 3845 if (rootProject.hasProperty("closedModuleDepedencies")) { 3846 dependencyRoots = [dependencyRoots, closedModuleDepedencies].flatten() 3847 } 3848 3849 Map extras = [:] 3850 3851 dependencyRoots.each { root -> 3852 FileTree ft = fileTree(root).include('**/*.extra') 3853 ft.each() { e-> 3854 String usename = e.path 3855 String filePath = e.getAbsolutePath() 3856 String folderPath = root.getAbsolutePath() 3857 if (filePath.startsWith(folderPath)) { 3858 usename = filePath.substring(folderPath.length() + 1); 3859 } 3860 if (extras.containsKey(usename)) { 3861 List<String> lines = extras.get(usename) 3862 e.eachLine { line -> 3863 line = line.trim() 3864 if (line.contains("exports")) { 3865 lines << line 3866 } 3867 } 3868 3869 } else { 3870 List<String> lines = [] 3871 e.eachLine { line -> 3872 if (line.contains("exports")) { 3873 lines << line.trim() 3874 } 3875 } 3876 extras.put(usename,lines) 3877 } 3878 } 3879 } 3880 extras.keySet().each() { e-> 3881 File f = new File(modulesSrcDir, e) 3882 f.getParentFile().mkdirs() 3883 f.delete() 3884 3885 extras.get(e).unique().each() { l-> 3886 f << l 3887 f << "\n" 3888 } 3889 } 3890 3891 // concatecate java.policy files into a single file 3892 // 3893 def outputPolicyDir = "${modulesConfDir}/java.base/security" 3894 def outputPolicyFile = file("${outputPolicyDir}/java.policy.extra") 3895 mkdir outputPolicyDir 3896 outputPolicyFile.delete() 3897 moduleProjList.each { project -> 3898 def policyDir = "${project.projectDir}/src/main/conf/security" 3899 def policyFile = file("${policyDir}/java.policy") 3900 if (policyFile.exists()) outputPolicyFile << policyFile.text 3901 } 3902 } 3903 } 3904 zipTask.dependsOn(buildModulesTask); 3905 buildModules.dependsOn(buildModulesTask) 3906 3907 def buildRunArgsTask = task("buildRunArgs$t.capital", 3908 group: "Build", dependsOn: buildModulesTask) { 3909 outputs.file(runArgsFile); 3910 doLast() { 3911 List<String>libpath = [] 3912 List<String>modpath = [] 3913 3914 moduleProjList.each { project -> 3915 def moduleName = project.ext.moduleName 3916 def dstModuleDir = cygpath("${modulesDir}/${moduleName}") 3917 modpath << "${moduleName}=${dstModuleDir}" 3918 } 3919 3920 writeRunArgsFile(runArgsFile, computeLibraryPath(true), modpath) 3921 } 3922 } 3923 buildModules.dependsOn(buildRunArgsTask) 3924 3925 def buildCompileArgsTask = task("buildCompileArgs$t.capital", 3926 group: "Build", dependsOn: buildModulesTask) { 3927 outputs.file(compileArgsFile); 3928 doLast() { 3929 List<String> modlist = [] 3930 moduleProjList.each { project -> 3931 def moduleName = project.ext.moduleName 3932 def dstModuleDir = "${modulesDir}/${moduleName}" 3933 modlist << dstModuleDir 3934 } 3935 writeCompileArgsFile(compileArgsFile, modlist); 3936 } 3937 } 3938 buildModules.dependsOn(buildCompileArgsTask) 3939 3940 def isWindows = IS_WINDOWS && t.name == "win"; 3941 def isMac = IS_MAC && t.name == "mac"; 3942 3943 // Create layout for modular classes 3944 moduleProjList.each { project -> 3945 def buildModuleClassesTask = project.task("buildModule$t.capital", group: "Build") { 3946 dependsOn(project.assemble) 3947 def buildDir = project.buildDir 3948 def sourceBuildDirs = [ 3949 "${buildDir}/classes/main/${project.moduleName}", 3950 ] 3951 doLast { 3952 def moduleClassesDir = "$buildDir/${platformPrefix}module-classes" 3953 copy { 3954 includeEmptyDirs = false 3955 sourceBuildDirs.each { d -> 3956 from d 3957 } 3958 into moduleClassesDir 3959 3960 // Exclude obsolete, experimental, or non-shipping code 3961 exclude("version.rc") 3962 exclude("com/sun/glass/ui/swt") 3963 exclude("com/sun/javafx/tools/ant") 3964 exclude("com/javafx/main") 3965 if (!IS_INCLUDE_NULL3D) { 3966 exclude ("com/sun/prism/null3d") 3967 } 3968 if (!IS_INCLUDE_ES2) { 3969 exclude("com/sun/prism/es2", 3970 "com/sun/scenario/effect/impl/es2") 3971 } 3972 3973 // Exclude platform-specific classes for other platforms 3974 3975 if (!isMac) { 3976 exclude ("com/sun/media/jfxmediaimpl/platform/osx", 3977 "com/sun/prism/es2/MacGL*", 3978 "com/sun/glass/events/mac", 3979 "com/sun/glass/ui/mac", 3980 ) 3981 } 3982 3983 if (!isWindows) { 3984 exclude ("**/*.hlsl", 3985 "com/sun/glass/ui/win", 3986 "com/sun/prism/d3d", 3987 "com/sun/prism/es2/WinGL*", 3988 "com/sun/scenario/effect/impl/hw/d3d" 3989 ) 3990 } 3991 3992 if (!targetProperties.includeGTK) { //usually IS_LINUX 3993 exclude ( 3994 "com/sun/glass/ui/gtk", 3995 "com/sun/prism/es2/EGL*", 3996 "com/sun/prism/es2/X11GL*" 3997 ) 3998 } 3999 4000 if (!targetProperties.includeEGL) { 4001 exclude ("com/sun/prism/es2/EGL*") 4002 } 4003 4004 if (!targetProperties.includeLens) { 4005 exclude ("com/sun/glass/ui/lens") 4006 } 4007 4008 // FIXME: JIGSAW -- Figure out what to do with Monocle 4009 /* 4010 if (!targetProperties.includeMonocle) { 4011 exclude ("com/sun/glass/ui/monocle") 4012 exclude("com/sun/prism/es2/Monocle*") 4013 } 4014 */ 4015 4016 if (t.name != 'ios') { 4017 exclude ("com/sun/media/jfxmediaimpl/platform/ios", 4018 "com/sun/glass/ui/ios", 4019 "com/sun/prism/es2/IOS*" 4020 ) 4021 } 4022 4023 if (t.name != 'android' && t.name != 'dalvik') { 4024 exclude ("com/sun/glass/ui/android") 4025 } 4026 4027 // Filter out other platform-specific classes 4028 if (targetProperties.containsKey('jfxrtJarExcludes')) { 4029 exclude(targetProperties.jfxrtJarExcludes) 4030 } 4031 4032 /* FIXME: JIGSAW -- handle this in the module itself 4033 String webbld = project(":web").buildDir.path 4034 String ctrlbld = project(":controls").buildDir.path 4035 if (t.name == 'android') { 4036 from ("${webbld}/classes/android", 4037 "${webbld}/resources/android", 4038 "${ctrlbld}/classes/android", 4039 "${ctrlbld}/resources/android") 4040 } else if (t.name == 'ios') { 4041 from ("${webbld}/classes/ios", 4042 "${webbld}/resources/ios", 4043 "modules/extensions/build/classes/ios") 4044 } else { 4045 from ("${webbld}/classes/main", 4046 "${webbld}resources/main") 4047 } 4048 */ 4049 } 4050 } 4051 } 4052 buildModulesTask.dependsOn(buildModuleClassesTask) 4053 } 4054 4055 4056 def buildModuleLibsTask = task("buildModuleLibs$t.capital") { 4057 group = "Basic" 4058 4059 def graphicsProject = project(":graphics"); 4060 dependsOn(graphicsProject.assemble) 4061 4062 def mediaProject = project(":media"); 4063 dependsOn(mediaProject.assemble) 4064 4065 def webProject = project(":web"); 4066 dependsOn(webProject.assemble) 4067 4068 def swtProject = project(":swt"); 4069 if (COMPILE_SWT) { 4070 def javafxSwtIndexTask = tasks.getByName("javafxSwtIndex${t.capital}"); 4071 dependsOn(javafxSwtIndexTask) 4072 } 4073 4074 def packagerProject = project(":fxpackager"); 4075 //dependsOn(packagerProject.assemble) 4076 dependsOn(packagerProject.jar) 4077 dependsOn(project(":fxpackagerservices").jar) 4078 4079 doLast { 4080 4081 def library = targetProperties.library 4082 4083 // javafx.base (lib/javafx.properties) 4084 4085 def baseProject = project(":base"); 4086 def moduleLibDir = "${baseProject.buildDir}/${platformPrefix}module-lib" 4087 mkdir moduleLibDir 4088 final File javafxProperties = file("${moduleLibDir}/javafx.properties") 4089 javafxProperties.delete() 4090 javafxProperties << "javafx.version=$RELEASE_VERSION_SHORT"; 4091 javafxProperties << "\n" 4092 javafxProperties << "javafx.runtime.version=$RELEASE_VERSION_LONG"; 4093 javafxProperties << "\n" 4094 javafxProperties << "javafx.runtime.build=$PROMOTED_BUILD_NUMBER"; 4095 javafxProperties << "\n" 4096 // Include any properties that have been defined (most likely in 4097 // one of the various platform gradle files) 4098 if (targetProperties.containsKey("javafxProperties")) { 4099 javafxProperties << targetProperties.javafxProperties 4100 javafxProperties << "\n" 4101 } 4102 4103 // Embedded builds define this file as well 4104 if (targetProperties.containsKey("javafxPlatformProperties")) { 4105 final File javafxPlatformProperties = file("${moduleLibDir}/javafx.platform.properties") 4106 javafxPlatformProperties.delete() 4107 javafxPlatformProperties << targetProperties.javafxPlatformProperties 4108 javafxPlatformProperties << "\n" 4109 } 4110 4111 4112 def useLipo = targetProperties.containsKey('useLipo') ? targetProperties.useLipo : false 4113 def modLibDest = targetProperties.modLibDest 4114 def moduleNativeDirName = "${platformPrefix}module-$modLibDest" 4115 4116 // javafx.graphics native libraries 4117 4118 copy { 4119 into "${graphicsProject.buildDir}/${moduleNativeDirName}" 4120 4121 from("${graphicsProject.buildDir}/libs/jsl-decora/${t.name}/${library(targetProperties.decora.lib)}") 4122 def libs = ['font', 'prism', 'prismSW', 'glass', 'iio'] 4123 if (IS_INCLUDE_ES2) { 4124 libs += ['prismES2']; 4125 } 4126 if (IS_COMPILE_PANGO) { 4127 libs += ['fontFreetype', 'fontPango']; 4128 } 4129 libs.each { lib -> 4130 def variants = targetProperties[lib].containsKey('variants') && !useLipo ? targetProperties[lib].variants : [null] 4131 variants.each { variant -> 4132 def variantProperties = variant ? targetProperties[lib][variant] : targetProperties[lib] 4133 from ("${graphicsProject.buildDir}/libs/$lib/$t.name/${library(variantProperties.lib)}") 4134 } 4135 } 4136 if (IS_WINDOWS) { 4137 from ("${graphicsProject.buildDir}/libs/prismD3D/${t.name}/${library(targetProperties.prismD3D.lib)}"); 4138 } 4139 } 4140 4141 4142 // javafx.media native libraries 4143 4144 copy { 4145 into "${mediaProject.buildDir}/${moduleNativeDirName}" 4146 4147 def mediaBuildType = project(":media").ext.buildType 4148 if (IS_COMPILE_MEDIA) { 4149 [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name -> 4150 from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") } 4151 4152 if (t.name == "mac") { 4153 // OSX media natives 4154 [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name -> 4155 from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library(name)}") } 4156 } else if (t.name == "linux") { 4157 from("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" } 4158 } else from ("${mediaProject.buildDir}/native/${t.name}/${mediaBuildType}/${library("glib-lite")}") 4159 } else { 4160 if (t.name != "android" && t.name != "dalvik" ) { 4161 [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name -> 4162 from ("$MEDIA_STUB/${library(name)}") } 4163 } 4164 4165 if (t.name == "mac") { 4166 // copy libjfxmedia_{avf,qtkit}.dylib if they exist 4167 [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name -> 4168 from ("$MEDIA_STUB/${library(name)}") } 4169 } else if (t.name == "linux") { 4170 from(MEDIA_STUB) { include "libavplugin*.so" } 4171 } 4172 else if (t.name != "android" && t.name != "dalvik" ) { 4173 from ("$MEDIA_STUB/${library("glib-lite")}") 4174 } 4175 } 4176 } 4177 4178 4179 // javafx.web native libraries 4180 4181 copy { 4182 into "${webProject.buildDir}/${moduleNativeDirName}" 4183 4184 if (IS_COMPILE_WEBKIT) { 4185 from ("${webProject.buildDir}/libs/${t.name}/${library('jfxwebkit')}") 4186 } else { 4187 if (t.name != "android" && t.name != "ios" && t.name != "dalvik") { 4188 from ("$WEB_STUB/${library('jfxwebkit')}") 4189 } 4190 } 4191 } 4192 4193 // FIXME: the following is a hack to workaround the fact that there 4194 // is no way to deliver javafx-swt.jar other than in one of the 4195 // existing runtime modules. 4196 if (COMPILE_SWT) { 4197 // Copy javafx-swt.jar to the javafx-graphics module lib dir 4198 copy { 4199 from "${swtProject.buildDir}/libs/javafx-swt.jar" 4200 into "${graphicsProject.buildDir}/${platformPrefix}module-lib" 4201 } 4202 } 4203 4204 // javafx.packager libraries and executable 4205 4206 // Copy over the javapackager libs 4207 copy { 4208 from "${packagerProject.buildDir}/libs" 4209 into "${packagerProject.buildDir}/${platformPrefix}module-lib" 4210 } 4211 4212 // Copy over the javapackager executable 4213 if (t.name == "win" || t.name == "linux" || t.name == "mac") { 4214 copy { 4215 from "${packagerProject.buildDir}/javapackager" 4216 into "${packagerProject.buildDir}/${platformPrefix}module-bin" 4217 } 4218 } 4219 4220 } 4221 } 4222 buildModulesTask.dependsOn(buildModuleLibsTask) 4223 4224 Task testArgFiles = task("createTestArgfiles${t.capital}") { 4225 4226 File testRunArgsFile = new File(rootProject.buildDir, TESTRUNARGSFILE) 4227 //test (shimed) version 4228 File testCompileArgsFile = new File(rootProject.buildDir, TESTCOMPILEARGSFILE) 4229 // And a test java.policy file 4230 File testJavaPolicyFile = new File(rootProject.buildDir, TESTJAVAPOLICYFILE) 4231 4232 outputs.file(testRunArgsFile) 4233 outputs.file(testCompileArgsFile) 4234 outputs.file(testJavaPolicyFile) 4235 4236 doLast() { 4237 rootProject.buildDir.mkdir() 4238 4239 List<String> projNames = [] 4240 moduleProjList.each { project -> 4241 projNames << project.name 4242 } 4243 4244 // And the test (shimed) variation... 4245 4246 testRunArgsFile.delete() 4247 4248 logger.info("Creating argfile ${testRunArgsFile.path}") 4249 4250 computePatchModuleArgs(projNames, true).each() { a-> 4251 testRunArgsFile << a 4252 testRunArgsFile << "\n" 4253 } 4254 4255 testJavaPolicyFile.delete() 4256 4257 List<String> modpath = [] 4258 4259 moduleProjList.each { project -> 4260 if (project.hasProperty("moduleName") && project.buildModule) { 4261 File dir; 4262 if (project.sourceSets.hasProperty('shims')) { 4263 dir = new File(project.sourceSets.shims.output.classesDir, project.ext.moduleName); 4264 } else { 4265 dir = new File(project.sourceSets.main.output.classesDir, project.ext.moduleName); 4266 } 4267 4268 modpath << dir.path 4269 4270 String themod = dir.toURI() 4271 testJavaPolicyFile << "grant codeBase \"${themod}\" {\n" + 4272 " permission java.security.AllPermission;\n" + 4273 "};\n" 4274 } 4275 } 4276 4277 writeCompileArgsFile(testCompileArgsFile, modpath) 4278 } 4279 } 4280 sdk.dependsOn(testArgFiles) 4281 createTestArgfiles.dependsOn(testArgFiles) 4282 4283 def sdkTask = tasks.getByName("sdk${t.capital}"); 4284 sdkTask.dependsOn(buildModulesTask) 4285 } 4286 sdk.dependsOn(buildModules) 4287 4288 task checkrepo() { 4289 doLast { 4290 logger.info("checking for whitespace (open)"); 4291 exec { 4292 if (IS_WINDOWS) { 4293 commandLine 'bash', 'tools/scripts/checkWhiteSpace' 4294 } else { 4295 commandLine 'bash', 'tools/scripts/checkWhiteSpace', '-x' 4296 } 4297 } 4298 } 4299 } 4300 4301 task checkrepoall() { 4302 doLast { 4303 logger.info("checking for all whitespace (open)"); 4304 exec { 4305 if (IS_WINDOWS) { 4306 commandLine 'bash', 'tools/scripts/checkWhiteSpace', '-a' 4307 } else { 4308 commandLine 'bash', 'tools/scripts/checkWhiteSpace', '-x', '-a' 4309 } 4310 } 4311 } 4312 } 4313 4314 /****************************************************************************** 4315 * * 4316 * BUILD_CLOSED * 4317 * * 4318 * This next section should remain at the end of the build script. It allows * 4319 * for a "supplemental" gradle file to be used to extend the normal build * 4320 * structure. For example, this is used for passing a supplemental gradle * 4321 * file for producing official JavaFX builds. * 4322 * * 4323 *****************************************************************************/ 4324 4325 if (BUILD_CLOSED) { 4326 apply from: supplementalBuildFile 4327 } 4328 4329 task showFlags { 4330 } 4331 4332 compileTargets { t -> 4333 // Every platform must define these variables 4334 def props = project.ext[t.upper]; 4335 showFlags.dependsOn( 4336 project.task("showFlags$t.upper") { 4337 doLast() { 4338 println "Properties set for $t.upper" 4339 props.each { println it } 4340 } 4341 } 4342 ) 4343 4344 }