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