1 /* 2 * Copyright (c) 2015, 2020, 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 * home_path 80 * 81 * 82 * The output data generated by this configuration file has the following 83 * format: 84 * 85 * data: { 86 * // Identifies the version of this format to the tool reading it 87 * format_version: "1.0", 88 * 89 * // Name of base outputdir. JIB assumes the actual output dir is formed 90 * // by adding the configuration name: <output_basedir>/<config-name> 91 * output_basedir: "build", 92 * // Configure argument to use to specify configuration name 93 * configuration_configure_arg: 94 * // Make argument to use to specify configuration name 95 * configuration_make_arg: 96 * 97 * profiles: { 98 * <profile-name>: { 99 * // Name of os the profile is built to run on 100 * target_os; <string> 101 * // Name of cpu the profile is built to run on 102 * target_cpu; <string> 103 * // Combination of target_os and target_cpu for convenience 104 * target_platform; <string> 105 * // Name of os the profile is built on 106 * build_os; <string> 107 * // Name of cpu the profile is built on 108 * build_cpu; <string> 109 * // Combination of build_os and build_cpu for convenience 110 * build_platform; <string> 111 * 112 * // List of dependencies needed to build this profile 113 * dependencies: <Array of strings> 114 * 115 * // List of configure args to use for this profile 116 * configure_args: <Array of strings> 117 * 118 * // List of free form labels describing aspects of this profile 119 * labels: <Array of strings> 120 * } 121 * } 122 * 123 * // Dependencies use a Maven like deployment structure 124 * dependencies: { 125 * <dependency-name>: { 126 * // Organization part of path defining this dependency 127 * organization: <string> 128 * // File extension for this dependency 129 * ext: <string> 130 * // Module part of path for defining this dependency, 131 * // defaults to <dependency-name> 132 * module: <string> 133 * // Revision part of path for defining this dependency 134 * revision: <string> 135 * 136 * // List of configure args to add when using this dependency, 137 * // defaults to 138 * // "--with-<dependency-name>=input.get("<dependency-name", "install_path")" 139 * configure_args: <array of strings> 140 * 141 * // Name of environment variable to set when using this dependency 142 * // when running make 143 * environment_name: <string> 144 * // Value of environment variable to set when using this dependency 145 * // when running make 146 * environment_value: <string> 147 * 148 * // Value to add to the PATH variable when using this dependency, 149 * // applies to both make and configure 150 * environment_path: <string> 151 * } 152 * 153 * <dependency-name>: { 154 * // For certain dependencies where a legacy distribution mechanism is 155 * // already in place, the "javare" server layout is also supported 156 * // Indicate that an alternate server source and layout should be used 157 * server: "javare" 158 * 159 * // For "javare", a combination of module, revision, 160 * // build number (optional), files and checksum file is possible for 161 * // artifacts following the standard layout. 162 * module: <string> 163 * revision: <string> 164 * build_number: <string> 165 * checksum_file: <string> 166 * file: <string> 167 * 168 * // For other files, use checksum path and path instead 169 * checksum_path: <string> 170 * path: <string> 171 * } 172 * } 173 * } 174 */ 175 176 /** 177 * Main entry to generate the profile configuration 178 * 179 * @param input External data to use for generating the configuration 180 * @returns {{}} Profile configuration 181 */ 182 var getJibProfiles = function (input) { 183 184 var data = {}; 185 186 // Identifies the version of this format to the tool reading it. 187 // 1.1 signifies that the publish, publish-src and get-src features are usable. 188 // 1.2 signifies that artifact uploads should fail on missing artifacts by default. 189 // 1.3 input.get(<dep>, "home_path") automatically goes down into a single top 190 // dir just like default configure_args and environment_path variables. 191 data.format_version = "1.3"; 192 193 // Organization, product and version are used when uploading/publishing build results 194 data.organization = ""; 195 data.product = "jdk"; 196 data.version = getVersion(); 197 198 // The base directory for the build output. JIB will assume that the 199 // actual build directory will be <output_basedir>/<configuration> 200 data.output_basedir = "build"; 201 // The configure argument to use to specify the name of the configuration 202 data.configuration_configure_arg = "--with-conf-name="; 203 // The make argument to use to specify the name of the configuration 204 data.configuration_make_arg = "CONF_NAME="; 205 206 // Exclude list to use when Jib creates a source bundle 207 data.src_bundle_excludes = [ 208 "build", "{,**/}webrev*", "{,**/}.hg", "{,**/}JTwork", "{,**/}JTreport", 209 "{,**/}.git" 210 ]; 211 // Include list to use when creating a minimal jib source bundle which 212 // contains just the jib configuration files. 213 data.conf_bundle_includes = [ 214 "make/autoconf/version-numbers", 215 ]; 216 217 // Define some common values 218 var common = getJibProfilesCommon(input, data); 219 // Generate the profiles part of the configuration 220 data.profiles = getJibProfilesProfiles(input, common, data); 221 // Generate the dependencies part of the configuration 222 data.dependencies = getJibProfilesDependencies(input, common, data); 223 224 return data; 225 }; 226 227 /** 228 * Generates some common values 229 * 230 * @param input External data to use for generating the configuration 231 * @returns Common values 232 */ 233 var getJibProfilesCommon = function (input, data) { 234 var common = {}; 235 236 common.organization = "jpg.infra.builddeps"; 237 common.build_id = getBuildId(input); 238 common.build_number = input.build_number != null ? input.build_number : "0"; 239 240 // List of the main profile names used for iteration 241 common.main_profile_names = [ 242 "linux-x64", "linux-x86", "macosx-x64", 243 "windows-x64", "windows-x86", 244 "linux-aarch64", "linux-arm32", "linux-ppc64le", "linux-s390x" 245 ]; 246 247 // These are the base setttings for all the main build profiles. 248 common.main_profile_base = { 249 dependencies: ["boot_jdk", "gnumake", "jtreg", "jib", "autoconf", "jmh", "jcov"], 250 default_make_targets: ["product-bundles", "test-bundles", "static-libs-bundles"], 251 configure_args: concat("--enable-jtreg-failure-handler", 252 "--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", 253 "--disable-manpages", 254 "--disable-jvm-feature-shenandoahgc", 255 versionArgs(input, common)) 256 }; 257 // Extra settings for debug profiles 258 common.debug_suffix = "-debug"; 259 common.debug_profile_base = { 260 configure_args: ["--enable-debug"], 261 labels: "debug" 262 }; 263 // Extra settings for slowdebug profiles 264 common.slowdebug_suffix = "-slowdebug"; 265 common.slowdebug_profile_base = { 266 configure_args: ["--with-debug-level=slowdebug"], 267 labels: "slowdebug" 268 }; 269 // Extra settings for openjdk only profiles 270 common.open_suffix = "-open"; 271 common.open_profile_base = { 272 configure_args: ["--enable-openjdk-only"], 273 labels: "open" 274 }; 275 276 common.configure_args_64bit = ["--with-target-bits=64"]; 277 common.configure_args_32bit = ["--with-target-bits=32"]; 278 279 /** 280 * Define common artifacts template for all main profiles 281 * @param o - Object containing data for artifacts 282 */ 283 common.main_profile_artifacts = function (o) { 284 var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version); 285 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 286 var pf = o.platform 287 return { 288 artifacts: { 289 jdk: { 290 local: "bundles/\\(jdk.*bin." + jdk_suffix + "\\)", 291 remote: [ 292 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin." + jdk_suffix, 293 "bundles/" + pf + "/\\1" 294 ], 295 subdir: jdk_subdir, 296 exploded: "images/jdk" 297 }, 298 test: { 299 local: "bundles/\\(jdk.*bin-tests.tar.gz\\)", 300 remote: [ 301 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests.tar.gz", 302 "bundles/" + pf + "/\\1" 303 ], 304 exploded: "images/test" 305 }, 306 test_demos: { 307 local: "bundles/\\(jdk.*bin-tests-demos.tar.gz\\)", 308 remote: [ 309 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests-demos.tar.gz", 310 "bundles/" + pf + "/\\1" 311 ], 312 exploded: "images/test" 313 }, 314 jdk_symbols: { 315 local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", 316 remote: [ 317 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-symbols.tar.gz", 318 "bundles/" + pf + "/\\1" 319 ], 320 subdir: jdk_subdir, 321 exploded: "images/jdk" 322 }, 323 static_libs: { 324 local: "bundles/\\(jdk.*bin-static-libs.tar.gz\\)", 325 remote: [ 326 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-static-libs.tar.gz", 327 "bundles/" + pf + "/\\1" 328 ], 329 subdir: jdk_subdir, 330 }, 331 } 332 }; 333 }; 334 335 336 /** 337 * Define common artifacts template for all debug profiles 338 * @param o - Object containing data for artifacts 339 */ 340 common.debug_profile_artifacts = function (o) { 341 var jdk_subdir = "jdk-" + data.version + "/fastdebug"; 342 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 343 var pf = o.platform 344 return { 345 artifacts: { 346 jdk: { 347 local: "bundles/\\(jdk.*bin-debug." + jdk_suffix + "\\)", 348 remote: [ 349 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug." + jdk_suffix, 350 "bundles/" + pf + "/\\1" 351 ], 352 subdir: jdk_subdir, 353 exploded: "images/jdk" 354 }, 355 test: { 356 local: "bundles/\\(jdk.*bin-tests-debug.tar.gz\\)", 357 remote: [ 358 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests-debug.tar.gz", 359 "bundles/" + pf + "/\\1" 360 ], 361 exploded: "images/test" 362 }, 363 jdk_symbols: { 364 local: "bundles/\\(jdk.*bin-debug-symbols.tar.gz\\)", 365 remote: [ 366 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz", 367 "bundles/" + pf + "/\\1" 368 ], 369 subdir: jdk_subdir, 370 exploded: "images/jdk" 371 }, 372 static_libs: { 373 local: "bundles/\\(jdk.*bin-static-libs-debug.tar.gz\\)", 374 remote: [ 375 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-static-libs-debug.tar.gz", 376 "bundles/" + pf + "/\\1" 377 ], 378 subdir: jdk_subdir, 379 }, 380 } 381 }; 382 }; 383 384 common.boot_jdk_version = "14"; 385 common.boot_jdk_build_number = "36"; 386 common.boot_jdk_home = input.get("boot_jdk", "install_path") + "/jdk-" 387 + common.boot_jdk_version 388 + (input.build_os == "macosx" ? ".jdk/Contents/Home" : ""); 389 390 return common; 391 }; 392 393 /** 394 * Generates the profiles part of the configuration. 395 * 396 * @param input External data to use for generating the configuration 397 * @param common The common values 398 * @returns {{}} Profiles part of the configuration 399 */ 400 var getJibProfilesProfiles = function (input, common, data) { 401 // Main SE profiles 402 var profiles = { 403 404 "linux-x64": { 405 target_os: "linux", 406 target_cpu: "x64", 407 dependencies: ["devkit", "gtest", "graphviz", "pandoc", "graalunit_lib"], 408 configure_args: concat(common.configure_args_64bit, 409 "--enable-full-docs", "--with-zlib=system", 410 (isWsl(input) ? [ "--host=x86_64-unknown-linux-gnu", 411 "--build=x86_64-unknown-linux-gnu" ] : [])), 412 default_make_targets: ["docs-bundles"], 413 }, 414 415 "linux-x86": { 416 target_os: "linux", 417 target_cpu: "x86", 418 build_cpu: "x64", 419 dependencies: ["devkit", "gtest"], 420 configure_args: concat(common.configure_args_32bit, 421 "--with-jvm-variants=minimal,server", "--with-zlib=system"), 422 }, 423 424 "macosx-x64": { 425 target_os: "macosx", 426 target_cpu: "x64", 427 dependencies: ["devkit", "gtest", "pandoc", "graalunit_lib"], 428 configure_args: concat(common.configure_args_64bit, "--with-zlib=system", 429 "--with-macosx-version-max=10.9.0", 430 // Use system SetFile instead of the one in the devkit as the 431 // devkit one may not work on Catalina. 432 "SETFILE=/usr/bin/SetFile"), 433 }, 434 435 "windows-x64": { 436 target_os: "windows", 437 target_cpu: "x64", 438 dependencies: ["devkit", "gtest", "pandoc", "graalunit_lib"], 439 configure_args: concat(common.configure_args_64bit), 440 }, 441 442 "windows-x86": { 443 target_os: "windows", 444 target_cpu: "x86", 445 build_cpu: "x64", 446 dependencies: ["devkit", "gtest"], 447 configure_args: concat(common.configure_args_32bit), 448 }, 449 450 "linux-aarch64": { 451 target_os: "linux", 452 target_cpu: "aarch64", 453 build_cpu: "x64", 454 dependencies: ["devkit", "gtest", "build_devkit", "pandoc"], 455 configure_args: [ 456 "--openjdk-target=aarch64-linux-gnu", 457 "--disable-jvm-feature-jvmci", 458 "--disable-jvm-feature-graal", 459 "--disable-jvm-feature-aot", 460 ], 461 }, 462 463 "linux-arm32": { 464 target_os: "linux", 465 target_cpu: "arm", 466 build_cpu: "x64", 467 dependencies: ["devkit", "gtest", "build_devkit"], 468 configure_args: [ 469 "--openjdk-target=arm-linux-gnueabihf", "--with-freetype=bundled", 470 "--with-abi-profile=arm-vfp-hflt", "--disable-warnings-as-errors" 471 ], 472 }, 473 474 "linux-ppc64le": { 475 target_os: "linux", 476 target_cpu: "ppc64le", 477 build_cpu: "x64", 478 dependencies: ["devkit", "gtest", "build_devkit"], 479 configure_args: [ 480 "--openjdk-target=ppc64le-linux-gnu", "--with-freetype=bundled", 481 "--disable-warnings-as-errors" 482 ], 483 }, 484 485 "linux-s390x": { 486 target_os: "linux", 487 target_cpu: "s390x", 488 build_cpu: "x64", 489 dependencies: ["devkit", "gtest", "build_devkit"], 490 configure_args: [ 491 "--openjdk-target=s390x-linux-gnu", "--with-freetype=bundled", 492 "--disable-warnings-as-errors" 493 ], 494 }, 495 }; 496 497 // Add the base settings to all the main profiles 498 common.main_profile_names.forEach(function (name) { 499 profiles[name] = concatObjects(common.main_profile_base, profiles[name]); 500 }); 501 502 // Generate debug versions of all the main profiles 503 common.main_profile_names.forEach(function (name) { 504 var debugName = name + common.debug_suffix; 505 profiles[debugName] = concatObjects(profiles[name], 506 common.debug_profile_base); 507 }); 508 // Generate slowdebug versions of all the main profiles 509 common.main_profile_names.forEach(function (name) { 510 var debugName = name + common.slowdebug_suffix; 511 profiles[debugName] = concatObjects(profiles[name], 512 common.slowdebug_profile_base); 513 }); 514 // Generate testmake profiles for the main profile of each build host 515 // platform. This profile only runs the makefile tests. 516 // Ant is needed to run the idea project generator test. 517 var testmakeBase = { 518 dependencies: [ "ant" ], 519 environment: { 520 "ANT_HOME": input.get("ant", "home_path") 521 } 522 }; 523 [ "linux-x64", "macosx-x64", "windows-x64"] 524 .forEach(function (name) { 525 var maketestName = name + "-testmake"; 526 profiles[maketestName] = concatObjects(profiles[name], testmakeBase); 527 profiles[maketestName].default_make_targets = [ "test-make" ]; 528 }); 529 530 // Generate -gcov profiles 531 [ "linux-aarch64", "linux-x64", "macosx-x64" ].forEach(function (name) { 532 var gcovName = name + "-gcov"; 533 profiles[gcovName] = clone(profiles[name]); 534 profiles[gcovName].default_make_targets = ["product-bundles", "test-bundles"]; 535 profiles[gcovName].configure_args = concat(profiles[gcovName].configure_args, 536 ["--enable-native-coverage", "--disable-warnings-as-errors"]); 537 }); 538 539 // Profiles for building the zero jvm variant. These are used for verification. 540 var zeroProfiles = { 541 "linux-x64-zero": { 542 target_os: "linux", 543 target_cpu: "x64", 544 dependencies: ["devkit", "gtest"], 545 configure_args: concat(common.configure_args_64bit, [ 546 "--with-zlib=system", 547 "--with-jvm-variants=zero", 548 "--enable-libffi-bundling" 549 ]) 550 }, 551 552 "linux-x86-zero": { 553 target_os: "linux", 554 target_cpu: "x86", 555 build_cpu: "x64", 556 dependencies: ["devkit", "gtest"], 557 configure_args: concat(common.configure_args_32bit, [ 558 "--with-zlib=system", 559 "--with-jvm-variants=zero", 560 "--enable-libffi-bundling" 561 ]) 562 } 563 } 564 profiles = concatObjects(profiles, zeroProfiles); 565 566 // Add the base settings to the zero profiles and generate debug profiles 567 Object.keys(zeroProfiles).forEach(function (name) { 568 var debugName = name + common.debug_suffix; 569 profiles[name] = concatObjects(common.main_profile_base, profiles[name]); 570 profiles[debugName] = concatObjects(profiles[name], common.debug_profile_base); 571 }); 572 573 // Define a profile with precompiled headers disabled. This is just used for 574 // verfication of this build configuration. 575 var noPchProfiles = { 576 "linux-x64-debug-nopch": { 577 target_os: "linux", 578 target_cpu: "x64", 579 dependencies: ["devkit", "gtest"], 580 configure_args: concat(common.configure_args_64bit, 581 "--with-zlib=system", "--disable-precompiled-headers"), 582 }, 583 }; 584 profiles = concatObjects(profiles, noPchProfiles); 585 // Add base settings to noPch profiles 586 Object.keys(noPchProfiles).forEach(function (name) { 587 profiles[name] = concatObjects(common.main_profile_base, profiles[name]); 588 profiles[name] = concatObjects(common.debug_profile_base, profiles[name]); 589 // Override default make target with hotspot as that's the only part of 590 // the build using precompiled headers. 591 profiles[name].default_make_targets = ["hotspot"]; 592 }); 593 594 // Bootcycle profiles runs the build with itself as the boot jdk. This can 595 // be done in two ways. Either using the builtin bootcycle target in the 596 // build system. Or by supplying the main jdk build as bootjdk to configure. 597 [ "linux-x64", "macosx-x64", "windows-x64" ] 598 .forEach(function (name) { 599 var bootcycleName = name + "-bootcycle"; 600 var bootcyclePrebuiltName = name + "-bootcycle-prebuilt"; 601 // The base bootcycle profile just changes the default target 602 // compared to the base profile 603 profiles[bootcycleName] = clone(profiles[name]); 604 profiles[bootcycleName].default_make_targets = [ "bootcycle-images" ]; 605 // The prebuilt bootcycle variant modifies the boot jdk argument 606 var bootcyclePrebuiltBase = { 607 dependencies: [ name + ".jdk" ], 608 configure_args: [ 609 "--with-boot-jdk=" + input.get(name + ".jdk", "home_path"), 610 ] 611 } 612 profiles[bootcyclePrebuiltName] = concatObjects(profiles[name], 613 bootcyclePrebuiltBase); 614 var bootJdkIndex = profiles[bootcyclePrebuiltName].dependencies.indexOf("boot_jdk"); 615 delete profiles[bootcyclePrebuiltName].dependencies[bootJdkIndex]; 616 profiles[bootcyclePrebuiltName].default_make_targets = [ "product-images" ]; 617 }); 618 619 // JCov profiles build JCov-instrumented JDK image based on images provided through dependencies. 620 [ "linux-aarch64", "linux-x64", "macosx-x64", "windows-x64" ] 621 .forEach(function (name) { 622 var jcovName = name + "-jcov"; 623 profiles[jcovName] = clone(common.main_profile_base); 624 profiles[jcovName].target_os = profiles[name].target_os 625 profiles[jcovName].target_cpu = profiles[name].target_cpu 626 profiles[jcovName].default_make_targets = [ "jcov-bundles" ]; 627 profiles[jcovName].dependencies = concat(profiles[jcovName].dependencies, 628 [ name + ".jdk", "devkit" ]); 629 profiles[jcovName].configure_args = concat(profiles[jcovName].configure_args, 630 ["--with-jcov-input-jdk=" + input.get(name + ".jdk", "home_path")]); 631 }); 632 633 // 634 // Define artifacts for profiles 635 // 636 // Macosx bundles are named osx 637 // tar.gz. 638 var artifactData = { 639 "linux-x64": { 640 platform: "linux-x64", 641 }, 642 "linux-x86": { 643 platform: "linux-x86", 644 }, 645 "macosx-x64": { 646 platform: "osx-x64", 647 jdk_subdir: "jdk-" + data.version + ".jdk/Contents/Home", 648 }, 649 "windows-x64": { 650 platform: "windows-x64", 651 jdk_suffix: "zip", 652 }, 653 "windows-x86": { 654 platform: "windows-x86", 655 jdk_suffix: "zip", 656 }, 657 "linux-aarch64": { 658 platform: "linux-aarch64", 659 }, 660 "linux-arm32": { 661 platform: "linux-arm32", 662 }, 663 "linux-ppc64le": { 664 platform: "linux-ppc64le", 665 }, 666 "linux-s390x": { 667 platform: "linux-s390x", 668 } 669 } 670 // Generate common artifacts for all main profiles 671 Object.keys(artifactData).forEach(function (name) { 672 profiles[name] = concatObjects(profiles[name], 673 common.main_profile_artifacts(artifactData[name])); 674 }); 675 676 // Generate common artifacts for all debug profiles 677 Object.keys(artifactData).forEach(function (name) { 678 var debugName = name + common.debug_suffix; 679 profiles[debugName] = concatObjects(profiles[debugName], 680 common.debug_profile_artifacts(artifactData[name])); 681 }); 682 683 profilesArtifacts = { 684 "linux-x64": { 685 artifacts: { 686 doc_api_spec: { 687 local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)", 688 remote: [ 689 "bundles/common/jdk-" + data.version + "_doc-api-spec.tar.gz", 690 "bundles/common/\\1" 691 ], 692 }, 693 } 694 } 695 }; 696 profiles = concatObjects(profiles, profilesArtifacts); 697 698 // Generate open only profiles for all the main and debug profiles. 699 // Rewrite artifact remote paths by adding "openjdk/GPL". 700 common.main_profile_names.forEach(function (name) { 701 var openName = name + common.open_suffix; 702 profiles[openName] = concatObjects(profiles[name], 703 common.open_profile_base); 704 for (artifactName in profiles[openName].artifacts) { 705 var artifact = profiles[openName].artifacts[artifactName]; 706 artifact.remote = replaceAll( 707 "bundles\/", "bundles/openjdk/GPL/", 708 (artifact.remote != null ? artifact.remote : artifact.local)); 709 } 710 var debugName = name + common.debug_suffix; 711 var openDebugName = name + common.open_suffix + common.debug_suffix; 712 profiles[openDebugName] = concatObjects(profiles[debugName], 713 common.open_profile_base); 714 for (artifactName in profiles[openDebugName].artifacts) { 715 var artifact = profiles[openDebugName].artifacts[artifactName]; 716 artifact.remote = replaceAll( 717 "bundles\/", "bundles/openjdk/GPL/", 718 (artifact.remote != null ? artifact.remote : artifact.local)); 719 } 720 }); 721 722 // Define the reference implementation profiles. These are basically the same 723 // as the open profiles, but upload artifacts to a different location. 724 common.main_profile_names.forEach(function (name) { 725 var riName = name + "-ri"; 726 var riDebugName = riName + common.debug_suffix; 727 var openName = name + common.open_suffix; 728 var openDebugName = openName + common.debug_suffix; 729 profiles[riName] = clone(profiles[openName]); 730 profiles[riDebugName] = clone(profiles[openDebugName]); 731 // Rewrite all remote dirs to "bundles/openjdk/BCL/..." 732 for (artifactName in profiles[riName].artifacts) { 733 var artifact = profiles[riName].artifacts[artifactName]; 734 artifact.remote = replaceAll( 735 "\/GPL\/", "/BCL/", 736 (artifact.remote != null ? artifact.remote : artifact.local)); 737 } 738 }); 739 740 // For open profiles, the non-debug jdk bundles, need an "open" prefix on the 741 // remote bundle names, forming the word "openjdk". See JDK-8188789. 742 common.main_profile_names.forEach(function (name) { 743 var openName = name + common.open_suffix; 744 profiles[openName].artifacts["jdk"].remote = replaceAll( 745 "\/jdk-", "/openjdk-", 746 replaceAll("\/\\1", "/open\\1", 747 profiles[openName].artifacts["jdk"].remote)); 748 }); 749 750 // Generate cmp-baseline profiles for each main profile and their 751 // corresponding debug profile. This profile does a compare build run with no 752 // changes to verify that the compare script has a clean baseline 753 common.main_profile_names.forEach(function (name) { 754 [ "", common.open_suffix ].forEach(function (suffix) { 755 var cmpBaselineName = name + suffix + "-cmp-baseline"; 756 profiles[cmpBaselineName] = clone(profiles[name + suffix]); 757 // Only compare the images target. This should pressumably be expanded 758 // to include more build targets when possible. 759 profiles[cmpBaselineName].default_make_targets = [ "images", "test-image" ]; 760 if (name == "linux-x64") { 761 profiles[cmpBaselineName].default_make_targets 762 = concat(profiles[cmpBaselineName].default_make_targets, "docs"); 763 } 764 profiles[cmpBaselineName].make_args = [ "COMPARE_BUILD=CONF=" ]; 765 profiles[cmpBaselineName].configure_args = concat( 766 profiles[cmpBaselineName].configure_args, 767 "--with-hotspot-build-time=n/a", 768 "--disable-precompiled-headers"); 769 // Do not inherit artifact definitions from base profile 770 delete profiles[cmpBaselineName].artifacts; 771 }); 772 }); 773 774 // Artifacts of JCov profiles 775 [ "linux-aarch64", "linux-x64", "macosx-x64", "windows-x64" ] 776 .forEach(function (name) { 777 var o = artifactData[name] 778 var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version); 779 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 780 var pf = o.platform 781 var jcovName = name + "-jcov"; 782 profiles[jcovName].artifacts = { 783 jdk: { 784 local: "bundles/\\(jdk-jcov.*bin." + jdk_suffix + "\\)", 785 remote: [ 786 "bundles/" + pf + "/jdk-jcov-" + data.version + "_" + pf + "_bin." + jdk_suffix 787 ], 788 subdir: jdk_subdir, 789 exploded: "images/jdk-jcov" 790 } 791 }; 792 }); 793 794 // Artifacts of gcov (native-code-coverage) profiles 795 [ "linux-aarch64", "linux-x64", "macosx-x64" ].forEach(function (name) { 796 var o = artifactData[name] 797 var pf = o.platform 798 var jdk_subdir = (o.jdk_subdir != null ? o.jdk_subdir : "jdk-" + data.version); 799 var jdk_suffix = (o.jdk_suffix != null ? o.jdk_suffix : "tar.gz"); 800 var gcovName = name + "-gcov"; 801 profiles[gcovName].artifacts = { 802 jdk: { 803 local: "bundles/\\(jdk.*bin." + jdk_suffix + "\\)", 804 remote: [ 805 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov." + jdk_suffix, 806 ], 807 subdir: jdk_subdir, 808 exploded: "images/jdk", 809 }, 810 test: { 811 local: "bundles/\\(jdk.*bin-tests.tar.gz\\)", 812 remote: [ 813 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov-tests.tar.gz", 814 ], 815 exploded: "images/test" 816 }, 817 jdk_symbols: { 818 local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)", 819 remote: [ 820 "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-gcov-symbols.tar.gz", 821 ], 822 subdir: jdk_subdir, 823 exploded: "images/jdk" 824 }, 825 }; 826 }); 827 828 // Profiles used to run tests. 829 var testOnlyProfiles = { 830 "run-test": { 831 target_os: input.build_os, 832 target_cpu: input.build_cpu, 833 dependencies: [ "jtreg", "gnumake", "boot_jdk", "devkit", "jib" ], 834 labels: "test", 835 environment: { 836 "JT_JAVA": common.boot_jdk_home 837 } 838 } 839 }; 840 profiles = concatObjects(profiles, testOnlyProfiles); 841 842 // Profiles used to run tests using Jib for internal dependencies. 843 var testedProfile = input.testedProfile; 844 if (testedProfile == null) { 845 testedProfile = input.build_os + "-" + input.build_cpu; 846 } 847 var testedProfileJdk = testedProfile + ".jdk"; 848 // Make it possible to use the test image from a different profile 849 var testImageProfile; 850 if (input.testImageProfile != null) { 851 testImageProfile = input.testImageProfile; 852 } else if (testedProfile.endsWith("-jcov")) { 853 testImageProfile = testedProfile.substring(0, testedProfile.length - "-jcov".length); 854 } else { 855 testImageProfile = testedProfile; 856 } 857 var testedProfileTest = testImageProfile + ".test" 858 var testOnlyMake = [ "test-prebuilt", "LOG_CMDLINES=true", "JTREG_VERBOSE=fail,error,time" ]; 859 if (testedProfile.endsWith("-gcov")) { 860 testOnlyMake = concat(testOnlyMake, "GCOV_ENABLED=true") 861 } 862 var testOnlyProfilesPrebuilt = { 863 "run-test-prebuilt": { 864 target_os: input.build_os, 865 target_cpu: input.build_cpu, 866 dependencies: [ 867 "jtreg", "gnumake", "boot_jdk", "devkit", "jib", "jcov", testedProfileJdk, 868 testedProfileTest 869 ], 870 src: "src.conf", 871 make_args: testOnlyMake, 872 environment: { 873 "BOOT_JDK": common.boot_jdk_home, 874 "JT_HOME": input.get("jtreg", "home_path"), 875 "JDK_IMAGE_DIR": input.get(testedProfileJdk, "home_path"), 876 "TEST_IMAGE_DIR": input.get(testedProfileTest, "home_path") 877 }, 878 labels: "test" 879 } 880 }; 881 882 // If actually running the run-test-prebuilt profile, verify that the input 883 // variable is valid and if so, add the appropriate target_* values from 884 // the tested profile. Use testImageProfile value as backup. 885 if (input.profile == "run-test-prebuilt") { 886 if (profiles[testedProfile] == null && profiles[testImageProfile] == null) { 887 error("testedProfile is not defined: " + testedProfile + " " + testImageProfile); 888 } 889 } 890 if (profiles[testedProfile] != null) { 891 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_os"] 892 = profiles[testedProfile]["target_os"]; 893 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"] 894 = profiles[testedProfile]["target_cpu"]; 895 } else if (profiles[testImageProfile] != null) { 896 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_os"] 897 = profiles[testImageProfile]["target_os"]; 898 testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"] 899 = profiles[testImageProfile]["target_cpu"]; 900 } 901 profiles = concatObjects(profiles, testOnlyProfilesPrebuilt); 902 903 // On macosx add the devkit bin dir to the path in all the run-test profiles. 904 // This gives us a guaranteed working version of lldb for the jtreg failure handler. 905 if (input.build_os == "macosx") { 906 macosxRunTestExtra = { 907 environment_path: input.get("devkit", "install_path") 908 + "/Xcode.app/Contents/Developer/usr/bin" 909 }; 910 profiles["run-test"] = concatObjects(profiles["run-test"], macosxRunTestExtra); 911 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], macosxRunTestExtra); 912 } 913 // On windows we want the debug symbols available at test time 914 if (input.build_os == "windows") { 915 windowsRunTestPrebuiltExtra = { 916 dependencies: [ testedProfile + ".jdk_symbols" ], 917 environment: { 918 "SYMBOLS_IMAGE_DIR": input.get(testedProfile + ".jdk_symbols", "home_path"), 919 } 920 }; 921 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], 922 windowsRunTestPrebuiltExtra); 923 } 924 925 // The profile run-test-prebuilt defines src.conf as the src bundle. When 926 // running in Mach 5, this reduces the time it takes to populate the 927 // considerably. But with just src.conf, we cannot actually run any tests, 928 // so if running from a workspace with just src.conf in it, we need to also 929 // get src.full as a dependency, and define the work_dir (where make gets 930 // run) to be in the src.full install path. By running in the install path, 931 // the same cached installation of the full src can be reused for multiple 932 // test tasks. Care must however be taken not to polute that work dir by 933 // setting the appropriate make variables to control output directories. 934 // 935 // Use the existance of the top level README as indication of if this is 936 // the full source or just src.conf. 937 if (!new java.io.File(__DIR__, "../../README").exists()) { 938 var runTestPrebuiltSrcFullExtra = { 939 dependencies: "src.full", 940 work_dir: input.get("src.full", "install_path"), 941 } 942 profiles["run-test-prebuilt"] = concatObjects(profiles["run-test-prebuilt"], 943 runTestPrebuiltSrcFullExtra); 944 } 945 946 // Generate the missing platform attributes 947 profiles = generatePlatformAttributes(profiles); 948 profiles = generateDefaultMakeTargetsConfigureArg(common, profiles); 949 return profiles; 950 }; 951 952 /** 953 * Generate the dependencies part of the configuration 954 * 955 * @param input External data to use for generating the configuration 956 * @param common The common values 957 * @returns {{}} Dependencies part of configuration 958 */ 959 var getJibProfilesDependencies = function (input, common) { 960 961 var devkit_platform_revisions = { 962 linux_x64: "gcc9.2.0-OL6.4+1.0", 963 macosx_x64: "Xcode10.1-MacOSX10.14+1.0", 964 windows_x64: "VS2019-16.5.3+1.0", 965 linux_aarch64: "gcc9.2.0-OL7.6+1.0", 966 linux_arm: "gcc8.2.0-Fedora27+1.0", 967 linux_ppc64le: "gcc8.2.0-Fedora27+1.0", 968 linux_s390x: "gcc8.2.0-Fedora27+1.0" 969 }; 970 971 var devkit_platform = (input.target_cpu == "x86" 972 ? input.target_os + "_x64" 973 : input.target_platform); 974 975 var devkit_cross_prefix = ""; 976 if (!(input.target_os == "windows" && isWsl(input))) { 977 if (input.build_platform != input.target_platform 978 && input.build_platform != devkit_platform) { 979 devkit_cross_prefix = input.build_platform + "-to-"; 980 } 981 } 982 983 var boot_jdk_platform = (input.build_os == "macosx" ? "osx" : input.build_os) 984 + "-" + input.build_cpu; 985 var boot_jdk_ext = (input.build_os == "windows" ? ".zip" : ".tar.gz") 986 // If running in WSL and building for Windows, it will look like Linux, 987 // but we need a Windows boot JDK. 988 if (isWsl(input) && input.target_os == "windows") { 989 boot_jdk_platform = "windows-" + input.build_cpu; 990 boot_jdk_ext = ".zip"; 991 } 992 993 var makeBinDir = (input.build_os == "windows" 994 ? input.get("gnumake", "install_path") + "/cygwin/bin" 995 : input.get("gnumake", "install_path") + "/bin"); 996 997 if (input.build_cpu == 'aarch64') { 998 boot_jdk = { 999 organization: common.organization, 1000 ext: "tar.gz", 1001 module: "jdk-linux_aarch64", 1002 revision: "14+1.0", 1003 configure_args: "--with-boot-jdk=" + common.boot_jdk_home, 1004 environment_path: common.boot_jdk_home + "/bin" 1005 } 1006 } else { 1007 boot_jdk = { 1008 server: "jpg", 1009 product: "jdk", 1010 version: common.boot_jdk_version, 1011 build_number: common.boot_jdk_build_number, 1012 file: "bundles/" + boot_jdk_platform + "/jdk-" + common.boot_jdk_version + "_" 1013 + boot_jdk_platform + "_bin" + boot_jdk_ext, 1014 configure_args: "--with-boot-jdk=" + common.boot_jdk_home, 1015 environment_path: common.boot_jdk_home + "/bin" 1016 } 1017 } 1018 1019 var dependencies = { 1020 boot_jdk: boot_jdk, 1021 1022 devkit: { 1023 organization: common.organization, 1024 ext: "tar.gz", 1025 module: "devkit-" + devkit_cross_prefix + devkit_platform, 1026 revision: devkit_platform_revisions[devkit_platform], 1027 environment: { 1028 "DEVKIT_HOME": input.get("devkit", "home_path"), 1029 } 1030 }, 1031 1032 build_devkit: { 1033 organization: common.organization, 1034 ext: "tar.gz", 1035 module: "devkit-" + input.build_platform, 1036 revision: devkit_platform_revisions[input.build_platform] 1037 }, 1038 1039 cups: { 1040 organization: common.organization, 1041 ext: "tar.gz", 1042 revision: "1.0118+1.0" 1043 }, 1044 1045 jtreg: { 1046 server: "jpg", 1047 product: "jtreg", 1048 version: "5.1", 1049 build_number: "b01", 1050 checksum_file: "MD5_VALUES", 1051 file: "bundles/jtreg_bin-5.1.zip", 1052 environment_name: "JT_HOME", 1053 environment_path: input.get("jtreg", "home_path") + "/bin", 1054 configure_args: "--with-jtreg=" + input.get("jtreg", "home_path"), 1055 }, 1056 1057 jmh: { 1058 organization: common.organization, 1059 ext: "tar.gz", 1060 revision: "1.21+1.0" 1061 }, 1062 1063 jcov: { 1064 // Until an official build of JCov is available, use custom 1065 // build to support classfile version 57. 1066 // See CODETOOLS-7902358 for more info. 1067 // server: "jpg", 1068 // product: "jcov", 1069 // version: "3.0", 1070 // build_number: "b07", 1071 // file: "bundles/jcov-3_0.zip", 1072 organization: common.organization, 1073 revision: "3.0-59-support+1.0", 1074 ext: "zip", 1075 environment_name: "JCOV_HOME", 1076 }, 1077 1078 gnumake: { 1079 organization: common.organization, 1080 ext: "tar.gz", 1081 revision: "4.0+1.0", 1082 1083 module: (input.build_os == "windows" 1084 ? "gnumake-" + input.build_osenv_platform 1085 : "gnumake-" + input.build_platform), 1086 1087 configure_args: "MAKE=" + makeBinDir + "/make", 1088 1089 environment: { 1090 "MAKE": makeBinDir + "/make" 1091 }, 1092 1093 environment_path: makeBinDir 1094 }, 1095 1096 autoconf: { 1097 organization: common.organization, 1098 ext: "tar.gz", 1099 revision: "2.69+1.0.1", 1100 module: (input.build_os == "windows" 1101 ? "autoconf-" + input.build_osenv_platform 1102 : "autoconf-" + input.build_platform), 1103 configure_args: "", 1104 environment_path: input.get("autoconf", "install_path") 1105 }, 1106 1107 graphviz: { 1108 organization: common.organization, 1109 ext: "tar.gz", 1110 revision: "2.38.0-1+1.1", 1111 module: "graphviz-" + input.target_platform, 1112 configure_args: "DOT=" + input.get("graphviz", "install_path") + "/dot", 1113 environment_path: input.get("graphviz", "install_path") 1114 }, 1115 1116 pandoc: { 1117 organization: common.organization, 1118 ext: "tar.gz", 1119 revision: (input.build_cpu == 'aarch64' ? "2.5+1.0" : "2.3.1+1.0"), 1120 module: "pandoc-" + input.build_platform, 1121 configure_args: "PANDOC=" + input.get("pandoc", "install_path") + "/pandoc/pandoc", 1122 environment_path: input.get("pandoc", "install_path") + "/pandoc" 1123 }, 1124 1125 // This adds java jib as a dependency for the test artifacts resolver 1126 jib: { 1127 organization: "com.oracle.java.jib", 1128 ext: "zip", 1129 classifier: "distribution", 1130 revision: "3.0-SNAPSHOT", 1131 environment_name: "JIB_HOME", 1132 environment_value: input.get("jib", "home_path") 1133 }, 1134 1135 ant: { 1136 organization: common.organization, 1137 ext: "zip", 1138 revision: "1.7.1+1.0", 1139 configure_args: "", 1140 }, 1141 1142 graalunit_lib: { 1143 organization: common.organization, 1144 ext: "zip", 1145 revision: "619_Apr_12_2018", 1146 module: "graalunit-lib", 1147 configure_args: "--with-graalunit-lib=" + input.get("graalunit_lib", "install_path"), 1148 environment_name: "GRAALUNIT_LIB" 1149 }, 1150 1151 gtest: { 1152 organization: common.organization, 1153 ext: "tar.gz", 1154 revision: "1.8.1" 1155 }, 1156 }; 1157 1158 return dependencies; 1159 }; 1160 1161 /** 1162 * Generate the missing platform attributes for profiles 1163 * 1164 * @param profiles Profiles map to generate attributes on 1165 * @returns {{}} New profiles map with platform attributes fully filled in 1166 */ 1167 var generatePlatformAttributes = function (profiles) { 1168 var ret = concatObjects(profiles, {}); 1169 for (var profile in profiles) { 1170 if (ret[profile].build_os == null) { 1171 ret[profile].build_os = ret[profile].target_os; 1172 } 1173 if (ret[profile].build_cpu == null) { 1174 ret[profile].build_cpu = ret[profile].target_cpu; 1175 } 1176 ret[profile].target_platform = ret[profile].target_os + "_" + ret[profile].target_cpu; 1177 ret[profile].build_platform = ret[profile].build_os + "_" + ret[profile].build_cpu; 1178 } 1179 return ret; 1180 }; 1181 1182 /** 1183 * The default_make_targets attribute on a profile is not a real Jib attribute. 1184 * This function rewrites that attribute into the corresponding configure arg. 1185 * Calling this function multiple times on the same profiles object is safe. 1186 * 1187 * @param common Common values 1188 * @param profiles Profiles map to rewrite profiles for 1189 * @returns {{}} New map of profiles with the make targets converted 1190 */ 1191 var generateDefaultMakeTargetsConfigureArg = function (common, profiles) { 1192 var ret = concatObjects(profiles, {}); 1193 for (var profile in ret) { 1194 if (ret[profile]["default_make_targets"] != null) { 1195 var targetsString = concat(ret[profile].default_make_targets).join(" "); 1196 // Iterate over all configure args and see if --with-default-make-target 1197 // is already there and change it, otherwise add it. 1198 var found = false; 1199 for (var i in ret[profile].configure_args) { 1200 var arg = ret[profile].configure_args[i]; 1201 if (arg != null && arg.startsWith("--with-default-make-target=")) { 1202 found = true; 1203 ret[profile].configure_args[i] 1204 = "--with-default-make-target=" + targetsString; 1205 } 1206 } 1207 if (!found) { 1208 ret[profile].configure_args = concat( 1209 ret[profile].configure_args, 1210 "--with-default-make-target=" + targetsString); 1211 } 1212 } 1213 } 1214 return ret; 1215 } 1216 1217 var getBuildId = function (input) { 1218 if (input.build_id != null) { 1219 return input.build_id; 1220 } else { 1221 var topdir = new java.io.File(__DIR__, "../..").getCanonicalFile().getName(); 1222 var userName = java.lang.System.getProperty("user.name"); 1223 return userName + "." + topdir; 1224 } 1225 } 1226 1227 /** 1228 * Deep clones an object tree. 1229 * 1230 * @param o Object to clone 1231 * @returns {{}} Clone of o 1232 */ 1233 var clone = function (o) { 1234 return JSON.parse(JSON.stringify(o)); 1235 }; 1236 1237 /** 1238 * Concatenates all arguments into a new array 1239 * 1240 * @returns {Array.<T>} New array containing all arguments 1241 */ 1242 var concat = function () { 1243 return Array.prototype.concat.apply([], arguments); 1244 }; 1245 1246 /** 1247 * Takes a String or Array of Strings and does a replace operation on each 1248 * of them. 1249 * 1250 * @param pattern Pattern to look for 1251 * @param replacement Replacement text to insert 1252 * @param a String or Array of Strings to replace 1253 * @returns {Array} Either a new array or a new string depending on the input 1254 */ 1255 var replaceAll = function (pattern, replacement, a) { 1256 // If a is an array 1257 if (Array === a.constructor) { 1258 var newA = []; 1259 for (var i in a) { 1260 newA.push(a[i].replace(pattern, replacement)); 1261 } 1262 return newA; 1263 } else { 1264 return a.replace(pattern, replacement); 1265 } 1266 }; 1267 1268 /** 1269 * Deep concatenation of two objects. For each node encountered, merge 1270 * the contents with the corresponding node in the other object tree, 1271 * treating all strings as array elements. 1272 * 1273 * @param o1 Object to concatenate 1274 * @param o2 Object to concatenate 1275 * @returns {{}} New object tree containing the concatenation of o1 and o2 1276 */ 1277 var concatObjects = function (o1, o2) { 1278 if (o1 == null) { 1279 return clone(o2); 1280 } 1281 if (o2 == null) { 1282 return clone(o1); 1283 } 1284 var ret = {}; 1285 for (var a in o1) { 1286 if (o2[a] == null) { 1287 ret[a] = clone(o1[a]); 1288 } 1289 } 1290 for (var a in o2) { 1291 if (o1[a] == null) { 1292 ret[a] = clone(o2[a]); 1293 } else { 1294 if (typeof o1[a] == 'string') { 1295 ret[a] = clone([o1[a]].concat(o2[a])); 1296 } else if (Array.isArray(o1[a])) { 1297 ret[a] = clone(o1[a].concat(o2[a])); 1298 } else if (typeof o1[a] == 'object') { 1299 ret[a] = concatObjects(o1[a], o2[a]); 1300 } 1301 } 1302 } 1303 return ret; 1304 }; 1305 1306 /** 1307 * Constructs the numeric version string from reading the 1308 * make/autoconf/version-numbers file and removing all trailing ".0". 1309 * 1310 * @param feature Override feature version 1311 * @param interim Override interim version 1312 * @param update Override update version 1313 * @param patch Override patch version 1314 * @returns {String} The numeric version string 1315 */ 1316 var getVersion = function (feature, interim, update, patch) { 1317 var version_numbers = getVersionNumbers(); 1318 var version = (feature != null ? feature : version_numbers.get("DEFAULT_VERSION_FEATURE")) 1319 + "." + (interim != null ? interim : version_numbers.get("DEFAULT_VERSION_INTERIM")) 1320 + "." + (update != null ? update : version_numbers.get("DEFAULT_VERSION_UPDATE")) 1321 + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH")) 1322 + "." + version_numbers.get("DEFAULT_VERSION_EXTRA1") 1323 + "." + version_numbers.get("DEFAULT_VERSION_EXTRA2") 1324 + "." + version_numbers.get("DEFAULT_VERSION_EXTRA3"); 1325 while (version.match(".*\\.0$")) { 1326 version = version.substring(0, version.length - 2); 1327 } 1328 return version; 1329 }; 1330 1331 /** 1332 * Constructs the common version configure args based on build type and 1333 * other version inputs 1334 */ 1335 var versionArgs = function(input, common) { 1336 var args = ["--with-version-build=" + common.build_number]; 1337 if (input.build_type == "promoted") { 1338 args = concat(args, 1339 "--with-version-pre=" + version_numbers.get("DEFAULT_PROMOTED_VERSION_PRE"), 1340 "--without-version-opt"); 1341 } else if (input.build_type == "ci") { 1342 var optString = input.build_id_data.ciBuildNumber; 1343 var preString = input.build_id_data.projectName; 1344 if (preString == "jdk") { 1345 preString = version_numbers.get("DEFAULT_PROMOTED_VERSION_PRE"); 1346 } 1347 args = concat(args, "--with-version-pre=" + preString, 1348 "--with-version-opt=" + optString); 1349 } else { 1350 args = concat(args, "--with-version-opt=" + common.build_id); 1351 } 1352 return args; 1353 } 1354 1355 // Properties representation of the make/autoconf/version-numbers file. Lazily 1356 // initiated by the function below. 1357 var version_numbers; 1358 1359 /** 1360 * Read the make/autoconf/version-numbers file into a Properties object. 1361 * 1362 * @returns {java.utilProperties} 1363 */ 1364 var getVersionNumbers = function () { 1365 // Read version information from make/autoconf/version-numbers 1366 if (version_numbers == null) { 1367 version_numbers = new java.util.Properties(); 1368 var stream = new java.io.FileInputStream(__DIR__ + "/../autoconf/version-numbers"); 1369 version_numbers.load(stream); 1370 stream.close(); 1371 } 1372 return version_numbers; 1373 } 1374 1375 /** 1376 * Returns true if running in Windows Subsystem for Linux. Jib does not yet 1377 * detect wsl as osenv, so fall back on linux with version containing Microsoft. 1378 */ 1379 var isWsl = function (input) { 1380 return ( input.build_osenv == "wsl" 1381 || (input.build_os == "linux" 1382 && java.lang.System.getProperty("os.version").contains("Microsoft"))); 1383 } 1384 1385 var error = function (s) { 1386 java.lang.System.err.println("[ERROR] " + s); 1387 exit(1); 1388 };