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