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