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