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