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