1 /* 2 * Copyright (c) 2015, 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 * This file defines build profiles for the JIB tool and others. 28 * 29 * A build profile defines a set of configuration options and external 30 * dependencies that we for some reason or other care about specifically. 31 * Typically, build profiles are defined for the build configurations we 32 * build regularly. 33 * 34 * Contract against this file from the tools that use it, is to provide 35 * a function on the form: 36 * 37 * getJibProfiles(input) 38 * 39 * which returns an object graph describing the profiles and their 40 * dependencies. The name of the function is based on the name of this 41 * file, minus the extension and the '-', camel cased and prefixed with 42 * 'get'. 43 * 44 * 45 * The parameter 'input' is an object that optionally contains some data. 46 * Optionally because a tool may read the configuration for different purposes. 47 * To initially get a list of available profiles, the active profile may not 48 * yet be known for instance. 49 * 50 * Data that may be set on the input object: 51 * 52 * input.profile = <name of active profile> 53 * 54 * If the active profile is set, the following data from it must also 55 * be provided: 56 * 57 * input.profile 58 * input.build_id 59 * input.target_os 60 * input.target_cpu 61 * input.build_os 62 * input.build_cpu 63 * input.target_platform 64 * input.build_platform 65 * // The build_osenv_* variables describe the unix layer on Windows systems, 66 * // i.e. Cygwin, which may also be 32 or 64 bit. 67 * input.build_osenv 68 * input.build_osenv_cpu 69 * input.build_osenv_platform 70 * 71 * For more complex nested attributes, there is a method "get": 72 * 73 * input.get("<dependency>", "<attribute>") 74 * 75 * Valid attributes are: 76 * install_path 77 * download_path 78 * download_dir 79 * 80 * 81 * The output data generated by this configuration file has the following 82 * format: 83 * 84 * data: { 85 * // Identifies the version of this format to the tool reading it 86 * format_version: "1.0", 87 * 88 * // Name of base outputdir. JIB assumes the actual output dir is formed 89 * // by adding the configuration name: <output_basedir>/<config-name> 90 * output_basedir: "build", 91 * // Configure argument to use to specify configuration name 92 * configuration_configure_arg: 93 * // Make argument to use to specify configuration name 94 * configuration_make_arg: 95 * 96 * profiles: { 97 * <profile-name>: { 98 * // Name of os the profile is built to run on 99 * target_os; <string> 100 * // Name of cpu the profile is built to run on 101 * target_cpu; <string> 102 * // Combination of target_os and target_cpu for convenience 103 * target_platform; <string> 104 * // Name of os the profile is built on 105 * build_os; <string> 106 * // Name of cpu the profile is built on 107 * build_cpu; <string> 108 * // Combination of build_os and build_cpu for convenience 109 * build_platform; <string> 110 * 111 * // List of dependencies needed to build this profile 112 * dependencies: <Array of strings> 113 * 114 * // List of configure args to use for this profile 115 * configure_args: <Array of strings> 116 * 117 * // List of free form labels describing aspects of this profile 118 * labels: <Array of strings> 119 * } 120 * } 121 * 122 * // Dependencies use a Maven like deployment structure 123 * dependencies: { 124 * <dependency-name>: { 125 * // Organization part of path defining this dependency 126 * organization: <string> 127 * // File extension for this dependency 128 * ext: <string> 129 * // Module part of path for defining this dependency, 130 * // defaults to <dependency-name> 131 * module: <string> 132 * // Revision part of path for defining this dependency 133 * revision: <string> 134 * 135 * // List of configure args to add when using this dependency, 136 * // defaults to 137 * // "--with-<dependency-name>=input.get("<dependency-name", "install_path")" 138 * configure_args: <array of strings> 139 * 140 * // Name of environment variable to set when using this dependency 141 * // when running make 142 * environment_name: <string> 143 * // Value of environment variable to set when using this dependency 144 * // when running make 145 * environment_value: <string> 146 * 147 * // Value to add to the PATH variable when using this dependency, 148 * // applies to both make and configure 149 * environment_path: <string> 150 * } 151 * 152 * <dependency-name>: { 153 * // For certain dependencies where a legacy distribution mechanism is 154 * // already in place, the "javare" server layout is also supported 155 * // Indicate that an alternate server source and layout should be used 156 * server: "javare" 157 * 158 * // For "javare", a combination of module, revision, 159 * // build number (optional), files and checksum file is possible for 160 * // artifacts following the standard layout. 161 * module: <string> 162 * revision: <string> 163 * build_number: <string> 164 * checksum_file: <string> 165 * file: <string> 166 * 167 * // For other files, use checksum path and path instead 168 * checksum_path: <string> 169 * path: <string> 170 * } 171 * } 172 * } 173 */ 174 175 /** 176 * Main entry to generate the profile configuration 177 * 178 * @param input External data to use for generating the configuration 179 * @returns {{}} Profile configuration 180 */ 181 var getJibProfiles = function (input) { 182 183 var data = {}; 184 185 // Identifies the version of this format to the tool reading it. 186 // 1.1 signifies that the publish, publish-src and get-src features are usable. 187 // 1.2 signifies that artifact uploads should fail on missing artifacts by default. 188 data.format_version = "1.2"; 189 190 // Organization, product and version are used when uploading/publishing build results 191 data.organization = ""; 192 data.product = "jdk"; 193 data.version = getVersion(); 194 195 // The base directory for the build output. JIB will assume that the 196 // actual build directory will be <output_basedir>/<configuration> 197 data.output_basedir = "build"; 198 // The configure argument to use to specify the name of the configuration 199 data.configuration_configure_arg = "--with-conf-name="; 200 // The make argument to use to specify the name of the configuration 201 data.configuration_make_arg = "CONF_NAME="; 202 203 // Exclude list to use when Jib creates a source bundle 204 data.src_bundle_excludes = "./build .build webrev* */webrev* */*/webrev* */*/*/webrev* .hg */.hg */*/.hg */*/*/.hg"; 205 // Include list to use when creating a minimal jib source bundle which 206 // contains just the jib configuration files. 207 data.conf_bundle_includes = "*/conf/jib-profiles.* make/autoconf/version-numbers" 208 209 // Define some common values 210 var common = getJibProfilesCommon(input, data); 211 // Generate the profiles part of the configuration 212 data.profiles = getJibProfilesProfiles(input, common, data); 213 // Generate the dependencies part of the configuration 214 data.dependencies = getJibProfilesDependencies(input, common, data); 215 216 return data; 217 }; 218 219 /** 220 * Generates some common values 221 * 222 * @param input External data to use for generating the configuration 223 * @returns Common values 224 */ 225 var getJibProfilesCommon = function (input, data) { 226 var common = {}; 227 228 common.organization = "jpg.infra.builddeps"; 229 common.build_id = getBuildId(input); 230 common.build_number = input.build_number != null ? input.build_number : "0"; 231 232 // List of the main profile names used for iteration 233 common.main_profile_names = [ 234 "linux-x64", "linux-x86", "macosx-x64", "solaris-x64", 235 "solaris-sparcv9", "windows-x64", "windows-x86", 236 "linux-aarch64", "linux-arm32" 237 ]; 238 239 // These are the base setttings for all the main build profiles. 240 common.main_profile_base = { 241 dependencies: ["boot_jdk", "gnumake", "jtreg", "jib", "autoconf"], 242 default_make_targets: ["product-bundles", "test-bundles"], 243 configure_args: concat(["--enable-jtreg-failure-handler"], 244 "--with-exclude-translations=de,es,fr,it,ko,pt_BR,sv,ca,tr,cs,sk,ja_JP_A,ja_JP_HA,ja_JP_HI,ja_JP_I,zh_TW,zh_HK", 245 "--disable-manpages", 246 versionArgs(input, common)) 247 }; 248 // Extra settings for debug profiles 249 common.debug_suffix = "-debug"; 250 common.debug_profile_base = { 251 configure_args: ["--enable-debug"], 252 labels: "debug" 253 }; 254 // Extra settings for slowdebug profiles 255 common.slowdebug_suffix = "-slowdebug"; 256 common.slowdebug_profile_base = { 257 configure_args: ["--with-debug-level=slowdebug"], 258 labels: "slowdebug" 259 }; 260 // Extra settings for openjdk only profiles 261 common.open_suffix = "-open"; 262 common.open_profile_base = { 263 configure_args: ["--enable-openjdk-only"], 264 labels: "open" 265 }; 266 267 common.configure_args_64bit = ["--with-target-bits=64"]; 268 common.configure_args_32bit = ["--with-target-bits=32"]; 269 270 /** 271 * Define common artifacts template for all main profiles 272 * @param o - Object containing data for artifacts 273 */ 274 common.main_profile_artifacts = function (o) { 275 var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version); 276 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 277 var pf = o.platform 278 return { 279 artifacts: { 280 jdk: { 281 local: "bundles/\\(jdk.*bin." + jdk_suffix + "\\)", 282 remote: [ 283 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin." + jdk_suffix, 284 "bundles/" + pf + "/\\1" 285 ], 286 subdir: jdk_subdir, 287 exploded: "images/jdk" 288 }, 289 test: { 290 local: "bundles/\\(jdk.*bin-tests.tar.gz\\)", 291 remote: [ 292 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests.tar.gz", 293 "bundles/" + pf + "/\\1" 294 ], 295 exploded: "images/test" 296 }, 297 test_demos: { 298 local: "bundles/\\(jdk.*bin-tests-demos.tar.gz\\)", 299 remote: [ 300 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests-demos.tar.gz", 301 "bundles/" + pf + "/\\1" 302 ], 303 exploded: "images/test" 304 }, 305 jdk_symbols: { 306 local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", 307 remote: [ 308 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-symbols.tar.gz", 309 "bundles/" + pf + "/\\1" 310 ], 311 subdir: jdk_subdir, 312 exploded: "images/jdk" 313 }, 314 } 315 }; 316 }; 317 318 319 /** 320 * Define common artifacts template for all debug profiles 321 * @param o - Object containing data for artifacts 322 */ 323 common.debug_profile_artifacts = function (o) { 324 var jdk_subdir = "jdk-" + data.version + "/fastdebug"; 325 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 326 var pf = o.platform 327 return { 328 artifacts: { 329 jdk: { 330 local: "bundles/\\(jdk.*bin-debug." + jdk_suffix + "\\)", 331 remote: [ 332 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug." + jdk_suffix, 333 "bundles/" + pf + "/\\1" 334 ], 335 subdir: jdk_subdir, 336 exploded: "images/jdk" 337 }, 338 test: { 339 local: "bundles/\\(jdk.*bin-tests-debug.tar.gz\\)", 340 remote: [ 341 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests-debug.tar.gz", 342 "bundles/" + pf + "/\\1" 343 ], 344 exploded: "images/test" 345 }, 346 jdk_symbols: { 347 local: "bundles/\\(jdk.*bin-debug-symbols.tar.gz\\)", 348 remote: [ 349 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz", 350 "bundles/" + pf + "/\\1" 351 ], 352 subdir: jdk_subdir, 353 exploded: "images/jdk" 354 }, 355 } 356 }; 357 }; 358 359 common.boot_jdk_version = "10"; 360 common.boot_jdk_home = input.get("boot_jdk", "home_path") + "/jdk-" 361 + common.boot_jdk_version 362 + (input.build_os == "macosx" ? ".jdk/Contents/Home" : ""); 363 364 return common; 365 }; 366 367 /** 368 * Generates the profiles part of the configuration. 369 * 370 * @param input External data to use for generating the configuration 371 * @param common The common values 372 * @returns {{}} Profiles part of the configuration 373 */ 374 var getJibProfilesProfiles = function (input, common, data) { 375 // Main SE profiles 376 var profiles = { 377 378 "linux-x64": { 379 target_os: "linux", 380 target_cpu: "x64", 381 dependencies: ["devkit", "graphviz", "pandoc", "graalunit_lib"], 382 configure_args: concat(common.configure_args_64bit, 383 "--enable-full-docs", "--with-zlib=system"), 384 default_make_targets: ["docs-bundles"], 385 }, 386 387 "linux-x86": { 388 target_os: "linux", 389 target_cpu: "x86", 390 build_cpu: "x64", 391 dependencies: ["devkit"], 392 configure_args: concat(common.configure_args_32bit, 393 "--with-jvm-variants=minimal,server", "--with-zlib=system"), 394 }, 395 396 "macosx-x64": { 397 target_os: "macosx", 398 target_cpu: "x64", 399 dependencies: ["devkit", "graalunit_lib"], 400 configure_args: concat(common.configure_args_64bit, "--with-zlib=system", 401 "--with-macosx-version-max=10.9.0"), 402 }, 403 404 "solaris-x64": { 405 target_os: "solaris", 406 target_cpu: "x64", 407 dependencies: ["devkit", "cups"], 408 configure_args: concat(common.configure_args_64bit, 409 "--with-zlib=system", "--enable-dtrace"), 410 }, 411 412 "solaris-sparcv9": { 413 target_os: "solaris", 414 target_cpu: "sparcv9", 415 dependencies: ["devkit", "cups"], 416 configure_args: concat(common.configure_args_64bit, 417 "--with-zlib=system", "--enable-dtrace"), 418 }, 419 420 "windows-x64": { 421 target_os: "windows", 422 target_cpu: "x64", 423 dependencies: ["devkit", "graalunit_lib"], 424 configure_args: concat(common.configure_args_64bit), 425 }, 426 427 "windows-x86": { 428 target_os: "windows", 429 target_cpu: "x86", 430 build_cpu: "x64", 431 dependencies: ["devkit"], 432 configure_args: concat(common.configure_args_32bit), 433 }, 434 435 "linux-aarch64": { 436 target_os: "linux", 437 target_cpu: "aarch64", 438 build_cpu: "x64", 439 dependencies: ["devkit", "build_devkit", "cups"], 440 configure_args: [ 441 "--openjdk-target=aarch64-linux-gnu", "--with-freetype=bundled", 442 "--disable-warnings-as-errors" 443 ], 444 }, 445 446 "linux-arm32": { 447 target_os: "linux", 448 target_cpu: "arm", 449 build_cpu: "x64", 450 dependencies: ["devkit", "build_devkit", "cups"], 451 configure_args: [ 452 "--openjdk-target=arm-linux-gnueabihf", "--with-freetype=bundled", 453 "--with-abi-profile=arm-vfp-hflt", "--disable-warnings-as-errors" 454 ], 455 }, 456 }; 457 458 // Add the base settings to all the main profiles 459 common.main_profile_names.forEach(function (name) { 460 profiles[name] = concatObjects(common.main_profile_base, profiles[name]); 461 }); 462 463 // Generate debug versions of all the main profiles 464 common.main_profile_names.forEach(function (name) { 465 var debugName = name + common.debug_suffix; 466 profiles[debugName] = concatObjects(profiles[name], 467 common.debug_profile_base); 468 }); 469 // Generate slowdebug versions of all the main profiles 470 common.main_profile_names.forEach(function (name) { 471 var debugName = name + common.slowdebug_suffix; 472 profiles[debugName] = concatObjects(profiles[name], 473 common.slowdebug_profile_base); 474 }); 475 // Generate testmake profiles for the main profile of each build host 476 // platform. This profile only runs the makefile tests. 477 // Ant is needed to run the idea project generator test. 478 var testmakeBase = { 479 dependencies: [ "ant" ], 480 environment: { 481 "ANT_HOME": input.get("ant", "install_path") + "/apache-ant-1.7.1" 482 } 483 }; 484 [ "linux-x64", "macosx-x64", "solaris-sparcv9", "solaris-x64", "windows-x64"] 485 .forEach(function (name) { 486 var maketestName = name + "-testmake"; 487 profiles[maketestName] = concatObjects(profiles[name], testmakeBase); 488 profiles[maketestName].default_make_targets = [ "test-make" ]; 489 }); 490 491 // Profiles for building the zero jvm variant. These are used for verification. 492 var zeroProfiles = { 493 "linux-x64-zero": { 494 target_os: "linux", 495 target_cpu: "x64", 496 dependencies: ["devkit"], 497 configure_args: concat(common.configure_args_64bit, [ 498 "--with-zlib=system", 499 "--with-jvm-variants=zero", 500 "--enable-libffi-bundling" 501 ]) 502 }, 503 504 "linux-x86-zero": { 505 target_os: "linux", 506 target_cpu: "x86", 507 build_cpu: "x64", 508 dependencies: ["devkit"], 509 configure_args: concat(common.configure_args_32bit, [ 510 "--with-zlib=system", 511 "--with-jvm-variants=zero", 512 "--enable-libffi-bundling" 513 ]) 514 } 515 } 516 profiles = concatObjects(profiles, zeroProfiles); 517 518 // Add the base settings to the zero profiles and generate debug profiles 519 Object.keys(zeroProfiles).forEach(function (name) { 520 var debugName = name + common.debug_suffix; 521 profiles[name] = concatObjects(common.main_profile_base, profiles[name]); 522 profiles[debugName] = concatObjects(profiles[name], common.debug_profile_base); 523 }); 524 525 // Bootcycle profiles runs the build with itself as the boot jdk. This can 526 // be done in two ways. Either using the builtin bootcycle target in the 527 // build system. Or by supplying the main jdk build as bootjdk to configure. 528 [ "linux-x64", "macosx-x64", "solaris-sparcv9", "windows-x64"] 529 .forEach(function (name) { 530 var bootcycleName = name + "-bootcycle"; 531 var bootcyclePrebuiltName = name + "-bootcycle-prebuilt"; 532 // The base bootcycle profile just changes the default target 533 // compared to the base profile 534 profiles[bootcycleName] = clone(profiles[name]); 535 profiles[bootcycleName].default_make_targets = [ "bootcycle-images" ]; 536 // The prebuilt bootcycle variant modifies the boot jdk argument 537 var bootcyclePrebuiltBase = { 538 dependencies: [ name + ".jdk" ], 539 configure_args: "--with-boot-jdk=" + input.get(name + ".jdk", "home_path"), 540 } 541 profiles[bootcyclePrebuiltName] = concatObjects(profiles[name], 542 bootcyclePrebuiltBase); 543 var bootJdkIndex = profiles[bootcyclePrebuiltName].dependencies.indexOf("boot_jdk"); 544 delete profiles[bootcyclePrebuiltName].dependencies[bootJdkIndex]; 545 profiles[bootcyclePrebuiltName].default_make_targets = [ "product-images" ]; 546 }); 547 548 // 549 // Define artifacts for profiles 550 // 551 // Macosx bundles are named osx 552 // tar.gz. 553 var artifactData = { 554 "linux-x64": { 555 platform: "linux-x64", 556 }, 557 "linux-x86": { 558 platform: "linux-x86", 559 }, 560 "macosx-x64": { 561 platform: "osx-x64", 562 jdk_subdir: "jdk-" + data.version + ".jdk/Contents/Home", 563 }, 564 "solaris-x64": { 565 platform: "solaris-x64", 566 }, 567 "solaris-sparcv9": { 568 platform: "solaris-sparcv9", 569 }, 570 "windows-x64": { 571 platform: "windows-x64", 572 jdk_suffix: "zip", 573 }, 574 "windows-x86": { 575 platform: "windows-x86", 576 jdk_suffix: "zip", 577 }, 578 "linux-aarch64": { 579 platform: "linux-aarch64", 580 }, 581 "linux-arm32": { 582 platform: "linux-arm32", 583 } 584 } 585 // Generate common artifacts for all main profiles 586 Object.keys(artifactData).forEach(function (name) { 587 profiles[name] = concatObjects(profiles[name], 588 common.main_profile_artifacts(artifactData[name])); 589 }); 590 591 // Generate common artifacts for all debug profiles 592 Object.keys(artifactData).forEach(function (name) { 593 var debugName = name + common.debug_suffix; 594 profiles[debugName] = concatObjects(profiles[debugName], 595 common.debug_profile_artifacts(artifactData[name])); 596 }); 597 598 profilesArtifacts = { 599 "linux-x64": { 600 artifacts: { 601 doc_api_spec: { 602 local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)", 603 remote: [ 604 "bundles/common/jdk-" + data.version + "_doc-api-spec.tar.gz", 605 "bundles/linux-x64/\\1" 606 ], 607 }, 608 } 609 } 610 }; 611 profiles = concatObjects(profiles, profilesArtifacts); 612 613 // Generate open only profiles for all the main and debug profiles. 614 // Rewrite artifact remote paths by adding "openjdk/GPL". 615 common.main_profile_names.forEach(function (name) { 616 var openName = name + common.open_suffix; 617 profiles[openName] = concatObjects(profiles[name], 618 common.open_profile_base); 619 for (artifactName in profiles[openName].artifacts) { 620 var artifact = profiles[openName].artifacts[artifactName]; 621 artifact.remote = replaceAll( 622 "bundles\/", "bundles/openjdk/GPL/", 623 (artifact.remote != null ? artifact.remote : artifact.local)); 624 } 625 var debugName = name + common.debug_suffix; 626 var openDebugName = name + common.open_suffix + common.debug_suffix; 627 profiles[openDebugName] = concatObjects(profiles[debugName], 628 common.open_profile_base); 629 for (artifactName in profiles[openDebugName].artifacts) { 630 var artifact = profiles[openDebugName].artifacts[artifactName]; 631 artifact.remote = replaceAll( 632 "bundles\/", "bundles/openjdk/GPL/", 633 (artifact.remote != null ? artifact.remote : artifact.local)); 634 } 635 }); 636 637 // Define the reference implementation profiles. These are basically the same 638 // as the open profiles, but upload artifacts to a different location. 639 common.main_profile_names.forEach(function (name) { 640 var riName = name + "-ri"; 641 var riDebugName = riName + common.debug_suffix; 642 var openName = name + common.open_suffix; 643 var openDebugName = openName + common.debug_suffix; 644 profiles[riName] = clone(profiles[openName]); 645 profiles[riDebugName] = clone(profiles[openDebugName]); 646 // Rewrite all remote dirs to "bundles/openjdk/BCL/..." 647 for (artifactName in profiles[riName].artifacts) { 648 var artifact = profiles[riName].artifacts[artifactName]; 649 artifact.remote = replaceAll( 650 "\/GPL\/", "/BCL/", 651 (artifact.remote != null ? artifact.remote : artifact.local)); 652 } 653 }); 654 655 // For open profiles, the non-debug jdk bundles, need an "open" prefix on the 656 // remote bundle names, forming the word "openjdk". See JDK-8188789. 657 common.main_profile_names.forEach(function (name) { 658 var openName = name + common.open_suffix; 659 profiles[openName].artifacts["jdk"].remote = replaceAll( 660 "\/jdk-", "/openjdk-", 661 replaceAll("\/\\1", "/open\\1", 662 profiles[openName].artifacts["jdk"].remote)); 663 }); 664 665 // Enable ZGC in linux-x64-open builds 666 [ "linux-x64-open" ].forEach(function (name) { 667 var configureArgs = { configure_args: [ "--with-jvm-features=zgc" ] }; 668 var debugName = name + common.debug_suffix; 669 profiles[name] = concatObjects(profiles[name], configureArgs); 670 profiles[debugName] = concatObjects(profiles[debugName], configureArgs); 671 }); 672 673 // Generate cmp-baseline profiles for each main profile and their 674 // corresponding debug profile. This profile does a compare build run with no 675 // changes to verify that the compare script has a clean baseline 676 common.main_profile_names.forEach(function (name) { 677 [ "", common.open_suffix ].forEach(function (suffix) { 678 var cmpBaselineName = name + suffix + "-cmp-baseline"; 679 profiles[cmpBaselineName] = clone(profiles[name + suffix]); 680 // Only compare the images target. This should pressumably be expanded 681 // to include more build targets when possible. 682 profiles[cmpBaselineName].default_make_targets = [ "images" ]; 683 profiles[cmpBaselineName].make_args = [ "COMPARE_BUILD=CONF=" ]; 684 // Do not inherit artifact definitions from base profile 685 delete profiles[cmpBaselineName].artifacts; 686 }); 687 }); 688 689 // Profiles used to run tests. 690 var testOnlyProfiles = { 691 "run-test": { 692 target_os: input.build_os, 693 target_cpu: input.build_cpu, 694 dependencies: [ "jtreg", "gnumake", "boot_jdk", "devkit", "jib" ], 695 labels: "test", 696 environment: { 697 "JT_JAVA": common.boot_jdk_home 698 } 699 } 700 }; 701 profiles = concatObjects(profiles, testOnlyProfiles); 702 703 // Profiles used to run tests using Jib for internal dependencies. 704 var testedProfile = input.testedProfile; 705 if (testedProfile == null) { 706 testedProfile = input.build_os + "-" + input.build_cpu; 707 } 708 var testOnlyProfilesPrebuilt = { 709 "run-test-prebuilt": { 710 target_os: input.build_os, 711 target_cpu: input.build_cpu, 712 dependencies: [ "jtreg", "gnumake", "boot_jdk", "jib", testedProfile + ".jdk", 713 testedProfile + ".test" 714 ], 715 src: "src.conf", 716 make_args: [ "run-test-prebuilt", "LOG_CMDLINES=true", "JTREG_VERBOSE=fail,error,time" ], 717 environment: { 718 "BOOT_JDK": common.boot_jdk_home, 719 "JDK_IMAGE_DIR": input.get(testedProfile + ".jdk", "home_path"), 720 "TEST_IMAGE_DIR": input.get(testedProfile + ".test", "home_path") 721 }, 722 labels: "test" 723 } 724 }; 725 726 // If actually running the run-test-prebuilt profile, verify that the input 727 // variable is valid and if so, add the appropriate target_* values from 728 // the tested profile. 729 if (input.profile == "run-test-prebuilt") { 730 if (profiles[testedProfile] == null) { 731 error("testedProfile is not defined: " + testedProfile); 732 } 733 } 734 if (profiles[testedProfile] != null) { 735 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_os"] 736 = profiles[testedProfile]["target_os"]; 737 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"] 738 = profiles[testedProfile]["target_cpu"]; 739 } 740 profiles = concatObjects(profiles, testOnlyProfilesPrebuilt); 741 742 // On macosx add the devkit bin dir to the path in all the run-test profiles. 743 // This gives us a guaranteed working version of lldb for the jtreg failure handler. 744 if (input.build_os == "macosx") { 745 macosxRunTestExtra = { 746 dependencies: [ "devkit" ], 747 environment_path: input.get("devkit", "install_path") 748 + "/Xcode.app/Contents/Developer/usr/bin" 749 }; 750 profiles["run-test"] = concatObjects(profiles["run-test"], macosxRunTestExtra); 751 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], macosxRunTestExtra); 752 } 753 // On windows we want the debug symbols available at test time 754 if (input.build_os == "windows") { 755 windowsRunTestPrebuiltExtra = { 756 dependencies: [ testedProfile + ".jdk_symbols" ], 757 environment: { 758 "SYMBOLS_IMAGE_DIR": input.get(testedProfile + ".jdk_symbols", "home_path"), 759 } 760 }; 761 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], 762 windowsRunTestPrebuiltExtra); 763 } 764 765 // The profile run-test-prebuilt defines src.conf as the src bundle. When 766 // running in Mach 5, this reduces the time it takes to populate the 767 // considerably. But with just src.conf, we cannot actually run any tests, 768 // so if running from a workspace with just src.conf in it, we need to also 769 // get src.full as a dependency, and define the work_dir (where make gets 770 // run) to be in the src.full install path. By running in the install path, 771 // the same cached installation of the full src can be reused for multiple 772 // test tasks. Care must however be taken not to polute that work dir by 773 // setting the appropriate make variables to control output directories. 774 // 775 // Use the existance of the top level README as indication of if this is 776 // the full source or just src.conf. 777 if (!new java.io.File(__DIR__, "../../README").exists()) { 778 var runTestPrebuiltSrcFullExtra = { 779 dependencies: "src.full", 780 work_dir: input.get("src.full", "install_path"), 781 } 782 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], 783 runTestPrebuiltSrcFullExtra); 784 } 785 786 // Generate the missing platform attributes 787 profiles = generatePlatformAttributes(profiles); 788 profiles = generateDefaultMakeTargetsConfigureArg(common, profiles); 789 return profiles; 790 }; 791 792 /** 793 * Generate the dependencies part of the configuration 794 * 795 * @param input External data to use for generating the configuration 796 * @param common The common values 797 * @returns {{}} Dependencies part of configuration 798 */ 799 var getJibProfilesDependencies = function (input, common) { 800 801 var devkit_platform_revisions = { 802 linux_x64: "gcc7.3.0-OEL6.4+1.1", 803 macosx_x64: "Xcode9.4-MacOSX10.13+1.0", 804 solaris_x64: "SS12u4-Solaris11u1+1.0", 805 solaris_sparcv9: "SS12u6-Solaris11u3+1.0", 806 windows_x64: "VS2017-15.5.5+1.0", 807 linux_aarch64: "gcc7.3.0-Fedora27+1.0", 808 linux_arm: "gcc7.3.0-Fedora27+1.0" 809 }; 810 811 var devkit_platform = (input.target_cpu == "x86" 812 ? input.target_os + "_x64" 813 : input.target_platform); 814 815 var boot_jdk_platform = (input.build_os == "macosx" ? "osx" : input.build_os) 816 + "-" + input.build_cpu; 817 818 var makeBinDir = (input.build_os == "windows" 819 ? input.get("gnumake", "install_path") + "/cygwin/bin" 820 : input.get("gnumake", "install_path") + "/bin"); 821 822 var dependencies = { 823 824 boot_jdk: { 825 server: "jpg", 826 product: "jdk", 827 version: common.boot_jdk_version, 828 build_number: "46", 829 file: "bundles/" + boot_jdk_platform + "/jdk-" + common.boot_jdk_version + "_" 830 + boot_jdk_platform + "_bin.tar.gz", 831 configure_args: "--with-boot-jdk=" + common.boot_jdk_home, 832 environment_path: common.boot_jdk_home + "/bin" 833 }, 834 835 devkit: { 836 organization: common.organization, 837 ext: "tar.gz", 838 module: "devkit-" + devkit_platform, 839 revision: devkit_platform_revisions[devkit_platform] 840 }, 841 842 build_devkit: { 843 organization: common.organization, 844 ext: "tar.gz", 845 module: "devkit-" + input.build_platform, 846 revision: devkit_platform_revisions[input.build_platform] 847 }, 848 849 cups: { 850 organization: common.organization, 851 ext: "tar.gz", 852 revision: "1.0118+1.0" 853 }, 854 855 jtreg: { 856 server: "javare", 857 revision: "4.2", 858 build_number: "b13", 859 checksum_file: "MD5_VALUES", 860 file: "jtreg_bin-4.2.zip", 861 environment_name: "JT_HOME", 862 environment_path: input.get("jtreg", "install_path") + "/jtreg/bin" 863 }, 864 865 gnumake: { 866 organization: common.organization, 867 ext: "tar.gz", 868 revision: "4.0+1.0", 869 870 module: (input.build_os == "windows" 871 ? "gnumake-" + input.build_osenv_platform 872 : "gnumake-" + input.build_platform), 873 874 configure_args: "MAKE=" + makeBinDir + "/make", 875 876 environment: { 877 "MAKE": makeBinDir + "/make" 878 }, 879 880 environment_path: makeBinDir 881 }, 882 883 autoconf: { 884 organization: common.organization, 885 ext: "tar.gz", 886 revision: "2.69+1.0.1", 887 module: (input.build_os == "windows" 888 ? "autoconf-" + input.build_osenv_platform 889 : "autoconf-" + input.build_platform), 890 configure_args: "", 891 environment_path: input.get("autoconf", "install_path") 892 }, 893 894 graphviz: { 895 organization: common.organization, 896 ext: "tar.gz", 897 revision: "2.38.0-1+1.1", 898 module: "graphviz-" + input.target_platform, 899 configure_args: "DOT=" + input.get("graphviz", "install_path") + "/dot", 900 environment_path: input.get("graphviz", "install_path") 901 }, 902 903 pandoc: { 904 organization: common.organization, 905 ext: "tar.gz", 906 revision: "1.17.2+1.0", 907 module: "pandoc-" + input.target_platform, 908 configure_args: "PANDOC=" + input.get("pandoc", "install_path") + "/pandoc/pandoc", 909 environment_path: input.get("pandoc", "install_path") + "/pandoc" 910 }, 911 912 // This adds java jib as a dependency for the test artifacts resolver 913 jib: { 914 organization: "com.oracle.java.jib", 915 ext: "zip", 916 classifier: "distribution", 917 revision: "3.0-SNAPSHOT", 918 environment_name: "JIB_HOME", 919 environment_value: input.get("jib", "install_path") 920 + "/jib-3.0-SNAPSHOT-distribution" 921 }, 922 923 ant: { 924 organization: common.organization, 925 ext: "zip", 926 revision: "1.7.1+1.0", 927 configure_args: "", 928 }, 929 930 graalunit_lib: { 931 organization: common.organization, 932 ext: "zip", 933 revision: "619_Apr_12_2018", 934 module: "graalunit-lib", 935 configure_args: "--with-graalunit-lib=" + input.get("graalunit_lib", "install_path"), 936 environment_name: "GRAALUNIT_LIB" 937 }, 938 }; 939 940 // Need to add a value for the Visual Studio tools variable to make 941 // jaot be able to pick up the Visual Studio linker in testing. 942 if (input.target_os == "windows") { 943 dependencies.devkit.environment = { 944 VS120COMNTOOLS: input.get("devkit", "install_path") + "/Common7/Tools" 945 }; 946 } 947 948 return dependencies; 949 }; 950 951 /** 952 * Generate the missing platform attributes for profiles 953 * 954 * @param profiles Profiles map to generate attributes on 955 * @returns {{}} New profiles map with platform attributes fully filled in 956 */ 957 var generatePlatformAttributes = function (profiles) { 958 var ret = concatObjects(profiles, {}); 959 for (var profile in profiles) { 960 if (ret[profile].build_os == null) { 961 ret[profile].build_os = ret[profile].target_os; 962 } 963 if (ret[profile].build_cpu == null) { 964 ret[profile].build_cpu = ret[profile].target_cpu; 965 } 966 ret[profile].target_platform = ret[profile].target_os + "_" + ret[profile].target_cpu; 967 ret[profile].build_platform = ret[profile].build_os + "_" + ret[profile].build_cpu; 968 } 969 return ret; 970 }; 971 972 /** 973 * The default_make_targets attribute on a profile is not a real Jib attribute. 974 * This function rewrites that attribute into the corresponding configure arg. 975 * Calling this function multiple times on the same profiles object is safe. 976 * 977 * @param common Common values 978 * @param profiles Profiles map to rewrite profiles for 979 * @returns {{}} New map of profiles with the make targets converted 980 */ 981 var generateDefaultMakeTargetsConfigureArg = function (common, profiles) { 982 var ret = concatObjects(profiles, {}); 983 for (var profile in ret) { 984 if (ret[profile]["default_make_targets"] != null) { 985 var targetsString = concat(ret[profile].default_make_targets).join(" "); 986 // Iterate over all configure args and see if --with-default-make-target 987 // is already there and change it, otherwise add it. 988 var found = false; 989 for (var i in ret[profile].configure_args) { 990 var arg = ret[profile].configure_args[i]; 991 if (arg != null && arg.startsWith("--with-default-make-target=")) { 992 found = true; 993 ret[profile].configure_args[i] 994 = "--with-default-make-target=" + targetsString; 995 } 996 } 997 if (!found) { 998 ret[profile].configure_args = concat( 999 ret[profile].configure_args, 1000 "--with-default-make-target=" + targetsString); 1001 } 1002 } 1003 } 1004 return ret; 1005 } 1006 1007 var getBuildId = function (input) { 1008 if (input.build_id != null) { 1009 return input.build_id; 1010 } else { 1011 var topdir = new java.io.File(__DIR__, "../..").getCanonicalFile().getName(); 1012 var userName = java.lang.System.getProperty("user.name"); 1013 return userName + "." + topdir; 1014 } 1015 } 1016 1017 /** 1018 * Deep clones an object tree. 1019 * 1020 * @param o Object to clone 1021 * @returns {{}} Clone of o 1022 */ 1023 var clone = function (o) { 1024 return JSON.parse(JSON.stringify(o)); 1025 }; 1026 1027 /** 1028 * Concatenates all arguments into a new array 1029 * 1030 * @returns {Array.<T>} New array containing all arguments 1031 */ 1032 var concat = function () { 1033 return Array.prototype.concat.apply([], arguments); 1034 }; 1035 1036 /** 1037 * Takes a String or Array of Strings and does a replace operation on each 1038 * of them. 1039 * 1040 * @param pattern Pattern to look for 1041 * @param replacement Replacement text to insert 1042 * @param a String or Array of Strings to replace 1043 * @returns {Array} Either a new array or a new string depending on the input 1044 */ 1045 var replaceAll = function (pattern, replacement, a) { 1046 // If a is an array 1047 if (Array === a.constructor) { 1048 var newA = []; 1049 for (var i in a) { 1050 newA.push(a[i].replace(pattern, replacement)); 1051 } 1052 return newA; 1053 } else { 1054 return a.replace(pattern, replacement); 1055 } 1056 }; 1057 1058 /** 1059 * Deep concatenation of two objects. For each node encountered, merge 1060 * the contents with the corresponding node in the other object tree, 1061 * treating all strings as array elements. 1062 * 1063 * @param o1 Object to concatenate 1064 * @param o2 Object to concatenate 1065 * @returns {{}} New object tree containing the concatenation of o1 and o2 1066 */ 1067 var concatObjects = function (o1, o2) { 1068 if (o1 == null) { 1069 return clone(o2); 1070 } 1071 if (o2 == null) { 1072 return clone(o1); 1073 } 1074 var ret = {}; 1075 for (var a in o1) { 1076 if (o2[a] == null) { 1077 ret[a] = clone(o1[a]); 1078 } 1079 } 1080 for (var a in o2) { 1081 if (o1[a] == null) { 1082 ret[a] = clone(o2[a]); 1083 } else { 1084 if (typeof o1[a] == 'string') { 1085 ret[a] = clone([o1[a]].concat(o2[a])); 1086 } else if (Array.isArray(o1[a])) { 1087 ret[a] = clone(o1[a].concat(o2[a])); 1088 } else if (typeof o1[a] == 'object') { 1089 ret[a] = concatObjects(o1[a], o2[a]); 1090 } 1091 } 1092 } 1093 return ret; 1094 }; 1095 1096 /** 1097 * Constructs the numeric version string from reading the 1098 * make/autoconf/version-numbers file and removing all trailing ".0". 1099 * 1100 * @param feature Override feature version 1101 * @param interim Override interim version 1102 * @param update Override update version 1103 * @param patch Override patch version 1104 * @returns {String} The numeric version string 1105 */ 1106 var getVersion = function (feature, interim, update, patch) { 1107 var version_numbers = getVersionNumbers(); 1108 var version = (feature != null ? feature : version_numbers.get("DEFAULT_VERSION_FEATURE")) 1109 + "." + (interim != null ? interim : version_numbers.get("DEFAULT_VERSION_INTERIM")) 1110 + "." + (update != null ? update : version_numbers.get("DEFAULT_VERSION_UPDATE")) 1111 + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH")); 1112 while (version.match(".*\\.0$")) { 1113 version = version.substring(0, version.length - 2); 1114 } 1115 return version; 1116 }; 1117 1118 /** 1119 * Constructs the common version configure args based on build type and 1120 * other version inputs 1121 */ 1122 var versionArgs = function(input, common) { 1123 var args = ["--with-version-build=" + common.build_number]; 1124 if (input.build_type == "promoted") { 1125 args = concat(args, 1126 // This needs to be changed when we start building release candidates 1127 // with-version-pre must be set to ea for 'ea' and empty for fcs build 1128 "--with-version-pre=ea", 1129 "--without-version-opt"); 1130 } else { 1131 args = concat(args, "--with-version-opt=" + common.build_id); 1132 } 1133 return args; 1134 } 1135 1136 // Properties representation of the make/autoconf/version-numbers file. Lazily 1137 // initiated by the function below. 1138 var version_numbers; 1139 1140 /** 1141 * Read the make/autoconf/version-numbers file into a Properties object. 1142 * 1143 * @returns {java.utilProperties} 1144 */ 1145 var getVersionNumbers = function () { 1146 // Read version information from make/autoconf/version-numbers 1147 if (version_numbers == null) { 1148 version_numbers = new java.util.Properties(); 1149 var stream = new java.io.FileInputStream(__DIR__ + "/../autoconf/version-numbers"); 1150 version_numbers.load(stream); 1151 stream.close(); 1152 } 1153 return version_numbers; 1154 }