common/conf/jib-profiles.js
changeset 42848 27ad8b2418f7
parent 42425 57cde06ae8d6
child 42980 4ab3d4b67cc0
equal deleted inserted replaced
42845:17469f16fbb4 42848:27ad8b2418f7
    53  *
    53  *
    54  * If the active profile is set, the following data from it must also
    54  * If the active profile is set, the following data from it must also
    55  * be provided:
    55  * be provided:
    56  *
    56  *
    57  * input.profile
    57  * input.profile
       
    58  * input.build_id
    58  * input.target_os
    59  * input.target_os
    59  * input.target_cpu
    60  * input.target_cpu
    60  * input.build_os
    61  * input.build_os
    61  * input.build_cpu
    62  * input.build_cpu
    62  * input.target_platform
    63  * input.target_platform
   179  */
   180  */
   180 var getJibProfiles = function (input) {
   181 var getJibProfiles = function (input) {
   181 
   182 
   182     var data = {};
   183     var data = {};
   183 
   184 
   184     // Identifies the version of this format to the tool reading it
   185     // Identifies the version of this format to the tool reading it.
   185     data.format_version = "1.0";
   186     // 1.1 signifies that the publish, publish-src and get-src features are usable.
   186 
   187     data.format_version = "1.1";
   187     // Organization is used when uploading/publishing build results
   188 
   188     data.organization = "com.oracle.jpg.jdk";
   189     // Organization, product and version are used when uploading/publishing build results
       
   190     data.organization = "";
       
   191     data.product = "jdk";
       
   192     data.version = getVersion();
   189 
   193 
   190     // The base directory for the build output. JIB will assume that the
   194     // The base directory for the build output. JIB will assume that the
   191     // actual build directory will be <output_basedir>/<configuration>
   195     // actual build directory will be <output_basedir>/<configuration>
   192     data.output_basedir = "build";
   196     data.output_basedir = "build";
   193     // The configure argument to use to specify the name of the configuration
   197     // The configure argument to use to specify the name of the configuration
   194     data.configuration_configure_arg = "--with-conf-name=";
   198     data.configuration_configure_arg = "--with-conf-name=";
   195     // The make argument to use to specify the name of the configuration
   199     // The make argument to use to specify the name of the configuration
   196     data.configuration_make_arg = "CONF_NAME=";
   200     data.configuration_make_arg = "CONF_NAME=";
   197 
   201 
       
   202     // Exclude list to use when Jib creates a source bundle
       
   203     data.src_bundle_excludes = "./build webrev .hg */.hg */*/.hg */*/*/.hg";
       
   204     // Include list to use when creating a minimal jib source bundle which
       
   205     // contains just the jib configuration files.
       
   206     data.conf_bundle_includes = "*/conf/jib-profiles.* common/autoconf/version-numbers"
       
   207 
   198     // Define some common values
   208     // Define some common values
   199     var common = getJibProfilesCommon(input);
   209     var common = getJibProfilesCommon(input, data);
   200     // Generate the profiles part of the configuration
   210     // Generate the profiles part of the configuration
   201     data.profiles = getJibProfilesProfiles(input, common);
   211     data.profiles = getJibProfilesProfiles(input, common, data);
   202     // Generate the dependencies part of the configuration
   212     // Generate the dependencies part of the configuration
   203     data.dependencies = getJibProfilesDependencies(input, common);
   213     data.dependencies = getJibProfilesDependencies(input, common, data);
   204 
   214 
   205     return data;
   215     return data;
   206 };
   216 };
   207 
   217 
   208 /**
   218 /**
   209  * Generates some common values
   219  * Generates some common values
   210  *
   220  *
   211  * @param input External data to use for generating the configuration
   221  * @param input External data to use for generating the configuration
   212  * @returns Common values
   222  * @returns Common values
   213  */
   223  */
   214 var getJibProfilesCommon = function (input) {
   224 var getJibProfilesCommon = function (input, data) {
   215     var common = {};
   225     var common = {};
   216 
   226 
   217     common.dependencies = ["boot_jdk", "gnumake", "jtreg"],
   227     common.organization = "jpg.infra.builddeps";
   218     common.default_make_targets = ["product-bundles", "test-bundles"],
   228     common.build_id = getBuildId(input);
   219     common.default_make_targets_debug = common.default_make_targets;
   229     common.build_number = input.build_number != null ? input.build_number : "0";
   220     common.default_make_targets_slowdebug = common.default_make_targets;
   230 
   221     common.configure_args = ["--enable-jtreg-failure-handler"],
   231     // List of the main profile names used for iteration
   222     common.configure_args_32bit = ["--with-target-bits=32"],
   232     common.main_profile_names = [
   223     common.configure_args_debug = ["--enable-debug"],
   233         "linux-x64", "linux-x86", "macosx-x64", "solaris-x64",
   224     common.configure_args_slowdebug = ["--with-debug-level=slowdebug"],
   234         "solaris-sparcv9", "windows-x64", "windows-x86"
   225     common.organization = "jpg.infra.builddeps"
   235     ];
       
   236 
       
   237     // These are the base setttings for all the main build profiles.
       
   238     common.main_profile_base = {
       
   239         dependencies: ["boot_jdk", "gnumake", "jtreg"],
       
   240         default_make_targets: ["product-bundles", "test-bundles"],
       
   241         configure_args: [
       
   242             "--with-version-opt=" + common.build_id,
       
   243             "--enable-jtreg-failure-handler",
       
   244             "--with-version-build=" + common.build_number
       
   245         ]
       
   246     };
       
   247     // Extra settings for debug profiles
       
   248     common.debug_suffix = "-debug";
       
   249     common.debug_profile_base = {
       
   250         configure_args: ["--enable-debug"],
       
   251         labels: "debug"
       
   252     };
       
   253     // Extra settings for slowdebug profiles
       
   254     common.slowdebug_suffix = "-slowdebug";
       
   255     common.slowdebug_profile_base = {
       
   256         configure_args: ["--with-debug-level=slowdebug"],
       
   257         labels: "slowdebug"
       
   258     };
       
   259     // Extra settings for openjdk only profiles
       
   260     common.open_suffix = "-open";
       
   261     common.open_profile_base = {
       
   262         configure_args: ["--enable-openjdk-only"],
       
   263         labels: "open"
       
   264     };
       
   265 
       
   266     common.configure_args_32bit = ["--with-target-bits=32"];
       
   267 
       
   268     /**
       
   269      * Define common artifacts template for all main profiles
       
   270      * @param pf - Name of platform in bundle names
       
   271      * @param demo_ext - Type of extension for demo bundle
       
   272      */
       
   273     common.main_profile_artifacts = function (pf, demo_ext) {
       
   274         return {
       
   275             artifacts: {
       
   276                 jdk: {
       
   277                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
       
   278                     remote: [
       
   279                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin.tar.gz",
       
   280                         "bundles/" + pf + "/\\1"
       
   281                     ],
       
   282                     subdir: "jdk-" + data.version,
       
   283                     exploded: "images/jdk"
       
   284                 },
       
   285                 jre: {
       
   286                     local: "bundles/\\(jre.*bin.tar.gz\\)",
       
   287                     remote: [
       
   288                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin.tar.gz",
       
   289                         "bundles/" + pf + "/\\1"
       
   290                     ],
       
   291                     subdir: "jre-" + data.version,
       
   292                     exploded: "images/jre"
       
   293                 },
       
   294                 test: {
       
   295                     local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
       
   296                     remote: [
       
   297                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests.tar.gz",
       
   298                         "bundles/" + pf + "/\\1"
       
   299                     ],
       
   300                     exploded: "images/test"
       
   301                 },
       
   302                 jdk_symbols: {
       
   303                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
       
   304                     remote: [
       
   305                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
       
   306                         "bundles/" + pf + "/\\1"
       
   307                     ],
       
   308                     subdir: "jdk-" + data.version,
       
   309                     exploded: "images/jdk"
       
   310                 },
       
   311                 jre_symbols: {
       
   312                     local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
       
   313                     remote: [
       
   314                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-symbols.tar.gz",
       
   315                         "bundles/" + pf + "/\\1"
       
   316                     ],
       
   317                     subdir: "jre-" + data.version,
       
   318                     exploded: "images/jre"
       
   319                 },
       
   320                 demo: {
       
   321                     local: "bundles/\\(jdk.*demo." + demo_ext + "\\)",
       
   322                     remote: [
       
   323                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_demo." + demo_ext,
       
   324                         "bundles/" + pf + "/\\1"
       
   325                     ],
       
   326                 }
       
   327             }
       
   328         };
       
   329     };
       
   330 
       
   331 
       
   332     /**
       
   333      * Define common artifacts template for all debug profiles
       
   334      * @param pf - Name of platform in bundle names
       
   335      */
       
   336     common.debug_profile_artifacts = function (pf) {
       
   337         return {
       
   338             artifacts: {
       
   339                 jdk: {
       
   340                     local: "bundles/\\(jdk.*bin-debug.tar.gz\\)",
       
   341                     remote: [
       
   342                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug.tar.gz",
       
   343                         "bundles/" + pf + "/\\1"
       
   344                     ],
       
   345                     subdir: "jdk-" + data.version,
       
   346                     exploded: "images/jdk"
       
   347                 },
       
   348                 jre: {
       
   349                     local: "bundles/\\(jre.*bin-debug.tar.gz\\)",
       
   350                     remote: [
       
   351                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug.tar.gz",
       
   352                         "bundles/" + pf + "/\\1"
       
   353                     ],
       
   354                     subdir: "jre-" + data.version,
       
   355                     exploded: "images/jre"
       
   356                 },
       
   357                 test: {
       
   358                     local: "bundles/\\(jdk.*bin-tests-debug.tar.gz\\)",
       
   359                     remote: [
       
   360                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-tests-debug.tar.gz",
       
   361                         "bundles/" + pf + "/\\1"
       
   362                     ],
       
   363                     exploded: "images/test"
       
   364                 },
       
   365                 jdk_symbols: {
       
   366                     local: "bundles/\\(jdk.*bin-debug-symbols.tar.gz\\)",
       
   367                     remote: [
       
   368                         "bundles/" + pf + "/jdk-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
       
   369                         "bundles/" + pf + "/\\1"
       
   370                     ],
       
   371                     subdir: "jdk-" + data.version,
       
   372                     exploded: "images/jdk"
       
   373                 },
       
   374                 jre_symbols: {
       
   375                     local: "bundles/\\(jre.*bin-debug-symbols.tar.gz\\)",
       
   376                     remote: [
       
   377                         "bundles/" + pf + "/jre-" + data.version + "_" + pf + "_bin-debug-symbols.tar.gz",
       
   378                         "bundles/" + pf + "/\\1"
       
   379                     ],
       
   380                     subdir: "jre-" + data.version,
       
   381                     exploded: "images/jre"
       
   382                 }
       
   383             }
       
   384         };
       
   385     };
   226 
   386 
   227     var boot_jdk_revision = "8";
   387     var boot_jdk_revision = "8";
   228     var boot_jdk_subdirpart = "1.8.0";
   388     var boot_jdk_subdirpart = "1.8.0";
   229     // JDK 8 does not work on sparc M7 cpus, need a newer update when building
   389     // JDK 8 does not work on sparc M7 cpus, need a newer update when building
   230     // on such hardware.
   390     // on such hardware.
   249  *
   409  *
   250  * @param input External data to use for generating the configuration
   410  * @param input External data to use for generating the configuration
   251  * @param common The common values
   411  * @param common The common values
   252  * @returns {{}} Profiles part of the configuration
   412  * @returns {{}} Profiles part of the configuration
   253  */
   413  */
   254 var getJibProfilesProfiles = function (input, common) {
   414 var getJibProfilesProfiles = function (input, common, data) {
   255     var profiles = {};
       
   256 
       
   257     // Main SE profiles
   415     // Main SE profiles
   258     var mainProfiles = {
   416     var profiles = {
   259 
   417 
   260         "linux-x64": {
   418         "linux-x64": {
   261             target_os: "linux",
   419             target_os: "linux",
   262             target_cpu: "x64",
   420             target_cpu: "x64",
   263             dependencies: concat(common.dependencies, "devkit"),
   421             dependencies: ["devkit"],
   264             configure_args: concat(common.configure_args, "--with-zlib=system"),
   422             configure_args: ["--with-zlib=system"],
   265             default_make_targets: concat(common.default_make_targets, "docs-bundles")
   423             default_make_targets: ["docs-bundles"],
   266         },
   424         },
   267 
   425 
   268         "linux-x86": {
   426         "linux-x86": {
   269             target_os: "linux",
   427             target_os: "linux",
   270             target_cpu: "x86",
   428             target_cpu: "x86",
   271             build_cpu: "x64",
   429             build_cpu: "x64",
   272             dependencies: concat(common.dependencies, "devkit"),
   430             dependencies: ["devkit"],
   273             configure_args: concat(common.configure_args, common.configure_args_32bit,
   431             configure_args: concat(common.configure_args_32bit,
   274                 "--with-jvm-variants=minimal,server", "--with-zlib=system"),
   432                 "--with-jvm-variants=minimal,server", "--with-zlib=system"),
   275             default_make_targets: common.default_make_targets
       
   276         },
   433         },
   277 
   434 
   278         "macosx-x64": {
   435         "macosx-x64": {
   279             target_os: "macosx",
   436             target_os: "macosx",
   280             target_cpu: "x64",
   437             target_cpu: "x64",
   281             dependencies: concat(common.dependencies, "devkit"),
   438             dependencies: ["devkit"],
   282             configure_args: concat(common.configure_args, "--with-zlib=system"),
   439             configure_args: concat(common.configure_args, "--with-zlib=system"),
   283             default_make_targets: common.default_make_targets
       
   284         },
   440         },
   285 
   441 
   286         "solaris-x64": {
   442         "solaris-x64": {
   287             target_os: "solaris",
   443             target_os: "solaris",
   288             target_cpu: "x64",
   444             target_cpu: "x64",
   289             dependencies: concat(common.dependencies, "devkit", "cups"),
   445             dependencies: ["devkit", "cups"],
   290             configure_args: concat(common.configure_args, "--with-zlib=system",
   446             configure_args: ["--with-zlib=system", "--enable-dtrace"],
   291                 "--enable-dtrace"),
       
   292             default_make_targets: common.default_make_targets
       
   293         },
   447         },
   294 
   448 
   295         "solaris-sparcv9": {
   449         "solaris-sparcv9": {
   296             target_os: "solaris",
   450             target_os: "solaris",
   297             target_cpu: "sparcv9",
   451             target_cpu: "sparcv9",
   298             dependencies: concat(common.dependencies, "devkit", "cups"),
   452             dependencies: ["devkit", "cups"],
   299             configure_args: concat(common.configure_args, "--with-zlib=system",
   453             configure_args: ["--with-zlib=system", "--enable-dtrace"],
   300                 "--enable-dtrace"),
       
   301             default_make_targets: common.default_make_targets
       
   302         },
   454         },
   303 
   455 
   304         "windows-x64": {
   456         "windows-x64": {
   305             target_os: "windows",
   457             target_os: "windows",
   306             target_cpu: "x64",
   458             target_cpu: "x64",
   307             dependencies: concat(common.dependencies, "devkit", "freetype"),
   459             dependencies: ["devkit", "freetype"],
   308             configure_args: concat(common.configure_args),
       
   309             default_make_targets: common.default_make_targets
       
   310         },
   460         },
   311 
   461 
   312         "windows-x86": {
   462         "windows-x86": {
   313             target_os: "windows",
   463             target_os: "windows",
   314             target_cpu: "x86",
   464             target_cpu: "x86",
   315             build_cpu: "x64",
   465             build_cpu: "x64",
   316             dependencies: concat(common.dependencies, "devkit", "freetype"),
   466             dependencies: ["devkit", "freetype"],
   317             configure_args: concat(common.configure_args, common.configure_args_32bit),
   467             configure_args: concat(common.configure_args_32bit),
   318             default_make_targets: common.default_make_targets
   468         }
   319         }
   469     };
   320     };
   470     // Add the base settings to all the main profiles
   321     profiles = concatObjects(profiles, mainProfiles);
   471     common.main_profile_names.forEach(function (name) {
       
   472         profiles[name] = concatObjects(common.main_profile_base, profiles[name]);
       
   473     });
       
   474 
   322     // Generate debug versions of all the main profiles
   475     // Generate debug versions of all the main profiles
   323     profiles = concatObjects(profiles, generateDebugProfiles(common, mainProfiles));
   476     common.main_profile_names.forEach(function (name) {
       
   477         var debugName = name + common.debug_suffix;
       
   478         profiles[debugName] = concatObjects(profiles[name],
       
   479                                             common.debug_profile_base);
       
   480     });
   324     // Generate slowdebug versions of all the main profiles
   481     // Generate slowdebug versions of all the main profiles
   325     profiles = concatObjects(profiles, generateSlowdebugProfiles(common, mainProfiles));
   482     common.main_profile_names.forEach(function (name) {
       
   483         var debugName = name + common.slowdebug_suffix;
       
   484         profiles[debugName] = concatObjects(profiles[name],
       
   485                                             common.slowdebug_profile_base);
       
   486     });
   326 
   487 
   327     // Generate open only profiles for all the main profiles for JPRT and reference
   488     // Generate open only profiles for all the main profiles for JPRT and reference
   328     // implementation builds.
   489     // implementation builds.
   329     var openOnlyProfiles = generateOpenOnlyProfiles(common, mainProfiles);
   490     common.main_profile_names.forEach(function (name) {
       
   491         var openName = name + common.open_suffix;
       
   492         profiles[openName] = concatObjects(profiles[name],
       
   493                                            common.open_profile_base);
       
   494     });
   330     // The open only profiles on linux are used for reference builds and should
   495     // The open only profiles on linux are used for reference builds and should
   331     // produce the compact profile images by default. This adds "profiles" as an
   496     // produce the compact profile images by default. This adds "profiles" as an
   332     // extra default target.
   497     // extra default target.
   333     var openOnlyProfilesExtra = {
   498     var openOnlyProfilesExtra = {
   334         "linux-x64-open": {
       
   335             default_make_targets: "profiles"
       
   336         },
       
   337 
       
   338         "linux-x86-open": {
   499         "linux-x86-open": {
   339             default_make_targets: "profiles",
   500             default_make_targets: "profiles",
   340             configure_args: "--with-jvm-variants=client,server"
   501             configure_args: "--with-jvm-variants=client,server"
   341         }
   502         }
   342     };
   503     };
   343     var openOnlyProfiles = concatObjects(openOnlyProfiles, openOnlyProfilesExtra);
   504     profiles = concatObjects(profiles, openOnlyProfilesExtra);
   344 
   505 
   345     profiles = concatObjects(profiles, openOnlyProfiles);
   506     // Generate debug profiles for the open only profiles
   346     // Generate debug profiles for the open jprt profiles
   507     common.main_profile_names.forEach(function (name) {
   347     profiles = concatObjects(profiles, generateDebugProfiles(common, openOnlyProfiles));
   508         var openName = name + common.open_suffix;
       
   509         var openDebugName = openName + common.debug_suffix;
       
   510         profiles[openDebugName] = concatObjects(profiles[openName],
       
   511                                                 common.debug_profile_base);
       
   512     });
   348 
   513 
   349     // Profiles for building the zero jvm variant. These are used for verification
   514     // Profiles for building the zero jvm variant. These are used for verification
   350     // in JPRT.
   515     // in JPRT.
   351     var zeroProfiles = {
   516     var zeroProfiles = {
   352         "linux-x64-zero": {
   517         "linux-x64-zero": {
   353             target_os: "linux",
   518             target_os: "linux",
   354             target_cpu: "x64",
   519             target_cpu: "x64",
   355             dependencies: concat(common.dependencies, "devkit"),
   520             dependencies: ["devkit"],
   356             configure_args: concat(common.configure_args,
   521             configure_args: [
   357                 "--with-zlib=system",
   522                 "--with-zlib=system",
   358                 "--with-jvm-variants=zero",
   523                 "--with-jvm-variants=zero",
   359                 "--enable-libffi-bundling"),
   524                 "--enable-libffi-bundling"
   360             default_make_targets: common.default_make_targets
   525             ]
   361         },
   526         },
   362 
   527 
   363         "linux-x86-zero": {
   528         "linux-x86-zero": {
   364             target_os: "linux",
   529             target_os: "linux",
   365             target_cpu: "x86",
   530             target_cpu: "x86",
   366             build_cpu: "x64",
   531             build_cpu: "x64",
   367             dependencies: concat(common.dependencies, "devkit"),
   532             dependencies: ["devkit"],
   368             configure_args: concat(common.configure_args, common.configure_args_32bit,
   533             configure_args:  concat(common.configure_args_32bit, [
   369                 "--with-zlib=system",
   534                 "--with-zlib=system",
   370                 "--with-jvm-variants=zero",
   535                 "--with-jvm-variants=zero",
   371                 "--enable-libffi-bundling"),
   536                 "--enable-libffi-bundling"
   372             default_make_targets: common.default_make_targets
   537             ])
   373         },
   538         }
   374     }
   539     }
   375     profiles = concatObjects(profiles, zeroProfiles);
   540     profiles = concatObjects(profiles, zeroProfiles);
   376     profiles = concatObjects(profiles, generateDebugProfiles(common, zeroProfiles));
   541 
   377 
   542     // Add the base settings to the zero profiles and generate debug profiles
   378     // Profiles used to run tests. Used in JPRT.
   543     Object.keys(zeroProfiles).forEach(function (name) {
       
   544         var debugName = name + common.debug_suffix;
       
   545         profiles[name] = concatObjects(common.main_profile_base, profiles[name]);
       
   546         profiles[debugName] = concatObjects(profiles[name], common.debug_profile_base);
       
   547     });
       
   548 
       
   549     // Profiles used to run tests. Used in JPRT and Mach 5.
   379     var testOnlyProfiles = {
   550     var testOnlyProfiles = {
       
   551         "run-test-jprt": {
       
   552             target_os: input.build_os,
       
   553             target_cpu: input.build_cpu,
       
   554             dependencies: [ "jtreg", "gnumake", "boot_jdk" ],
       
   555             labels: "test",
       
   556             environment: {
       
   557                 "JT_JAVA": common.boot_jdk_home
       
   558             }
       
   559         },
   380 
   560 
   381         "run-test": {
   561         "run-test": {
   382             target_os: input.build_os,
   562             target_os: input.build_os,
   383             target_cpu: input.build_cpu,
   563             target_cpu: input.build_cpu,
   384             dependencies: [ "jtreg", "gnumake", "boot_jdk" ],
   564             dependencies: [ "jtreg", "gnumake", "boot_jdk" ],
   387                 "JT_JAVA": common.boot_jdk_home
   567                 "JT_JAVA": common.boot_jdk_home
   388             }
   568             }
   389         }
   569         }
   390     };
   570     };
   391     profiles = concatObjects(profiles, testOnlyProfiles);
   571     profiles = concatObjects(profiles, testOnlyProfiles);
       
   572 
       
   573     // Profiles used to run tests using Jib for internal dependencies.
       
   574     var testedProfile = input.testedProfile;
       
   575     if (testedProfile == null) {
       
   576         testedProfile = input.build_os + "-" + input.build_cpu;
       
   577     }
       
   578     var testOnlyProfilesPrebuilt = {
       
   579         "run-test-prebuilt": {
       
   580             src: "src.conf",
       
   581             dependencies: [ "jtreg", "gnumake", testedProfile + ".jdk",
       
   582                 testedProfile + ".test", "src.full"
       
   583             ],
       
   584             work_dir: input.get("src.full", "install_path") + "/test",
       
   585             environment: {
       
   586                 "PRODUCT_HOME": input.get(testedProfile + ".jdk", "home_path"),
       
   587                 "TEST_IMAGE_DIR": input.get(testedProfile + ".test", "home_path"),
       
   588                 "TEST_OUTPUT_DIR": input.src_top_dir
       
   589             },
       
   590             labels: "test"
       
   591         }
       
   592     };
       
   593     // If actually running the run-test-prebuilt profile, verify that the input
       
   594     // variable is valid and if so, add the appropriate target_* values from
       
   595     // the tested profile.
       
   596     if (input.profile == "run-test-prebuilt") {
       
   597         if (profiles[testedProfile] == null) {
       
   598             error("testedProfile is not defined: " + testedProfile);
       
   599         } else {
       
   600             testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_os"]
       
   601                 = profiles[testedProfile]["target_os"];
       
   602             testOnlyProfilesPrebuilt["run-test-prebuilt"]["target_cpu"]
       
   603                 = profiles[testedProfile]["target_cpu"];
       
   604         }
       
   605     }
       
   606     profiles = concatObjects(profiles, testOnlyProfilesPrebuilt);
       
   607 
       
   608     //
       
   609     // Define artifacts for profiles
       
   610     //
       
   611     // Macosx bundles are named osx and Windows demo bundles use zip instead of
       
   612     // tar.gz.
       
   613     var artifactData = {
       
   614         "linux-x64": {
       
   615             platform: "linux-x64",
       
   616             demo_ext: "tar.gz"
       
   617         },
       
   618         "linux-x86": {
       
   619             platform: "linux-x86",
       
   620             demo_ext: "tar.gz"
       
   621         },
       
   622         "macosx-x64": {
       
   623             platform: "osx-x64",
       
   624             demo_ext: "tar.gz"
       
   625         },
       
   626         "solaris-x64": {
       
   627             platform: "solaris-x64",
       
   628             demo_ext: "tar.gz"
       
   629         },
       
   630         "solaris-sparcv9": {
       
   631             platform: "solaris-sparcv9",
       
   632             demo_ext: "tar.gz"
       
   633         },
       
   634         "windows-x64": {
       
   635             platform: "windows-x64",
       
   636             demo_ext: "zip"
       
   637         },
       
   638         "windows-x86": {
       
   639             platform: "windows-x86",
       
   640             demo_ext: "zip"
       
   641         }
       
   642     }
       
   643     // Generate common artifacts for all main profiles
       
   644     common.main_profile_names.forEach(function (name) {
       
   645         profiles[name] = concatObjects(profiles[name],
       
   646             common.main_profile_artifacts(artifactData[name].platform, artifactData[name].demo_ext));
       
   647     });
       
   648 
       
   649     // Generate common artifacts for all debug profiles
       
   650     common.main_profile_names.forEach(function (name) {
       
   651         var debugName = name + common.debug_suffix;
       
   652         profiles[debugName] = concatObjects(profiles[debugName],
       
   653             common.debug_profile_artifacts(artifactData[name].platform));
       
   654     });
       
   655 
       
   656     // Extra profile specific artifacts
       
   657     profilesArtifacts = {
       
   658         "linux-x64": {
       
   659             artifacts: {
       
   660                 doc_api_spec: {
       
   661                     local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)",
       
   662                     remote: [
       
   663                         "bundles/common/jdk-" + data.version + "_doc-api-spec.tar.gz",
       
   664                         "bundles/linux-x64/\\1"
       
   665                     ],
       
   666                 },
       
   667             }
       
   668         },
       
   669 
       
   670         "linux-x64-open": {
       
   671             artifacts: {
       
   672                 jdk: {
       
   673                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
       
   674                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   675                 },
       
   676                 jre: {
       
   677                     local: "bundles/\\(jre.*bin.tar.gz\\)",
       
   678                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   679                 },
       
   680                 test: {
       
   681                     local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
       
   682                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   683                 },
       
   684                 jdk_symbols: {
       
   685                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
       
   686                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   687                 },
       
   688                 jre_symbols: {
       
   689                     local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
       
   690                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   691                 },
       
   692                 demo: {
       
   693                     local: "bundles/\\(jdk.*demo.tar.gz\\)",
       
   694                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   695                 },
       
   696                 doc_api_spec: {
       
   697                     local: "bundles/\\(jdk.*doc-api-spec.tar.gz\\)",
       
   698                     remote: "bundles/openjdk/GPL/linux-x64/\\1",
       
   699                 },
       
   700             }
       
   701         },
       
   702 
       
   703         "linux-x86-open": {
       
   704             artifacts: {
       
   705                 jdk: {
       
   706                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
       
   707                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   708                 },
       
   709                 jre: {
       
   710                     local: "bundles/\\(jre.*[0-9]_linux-x86_bin.tar.gz\\)",
       
   711                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   712                 },/* The build does not create these
       
   713                 jre_compact1: {
       
   714                     local: "bundles/\\(jre.*-compact1_linux-x86_bin.tar.gz\\)",
       
   715                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   716                 },
       
   717                 jre_compact2: {
       
   718                     local: "bundles/\\(jre.*-compact2_linux-x86_bin.tar.gz\\)",
       
   719                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   720                 },
       
   721                 jre_compact3: {
       
   722                     local: "bundles/\\(jre.*-compact3_linux-x86_bin.tar.gz\\)",
       
   723                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   724                 },*/
       
   725             }
       
   726         },
       
   727 
       
   728         "windows-x86-open": {
       
   729             artifacts: {
       
   730                 jdk: {
       
   731                     local: "bundles/\\(jdk.*bin.tar.gz\\)",
       
   732                     remote: "bundles/openjdk/GPL/windows-x86/\\1",
       
   733                 },
       
   734                 jre: {
       
   735                     local: "bundles/\\(jre.*bin.tar.gz\\)",
       
   736                     remote: "bundles/openjdk/GPL/windows-x86/\\1"
       
   737                 },
       
   738                 test: {
       
   739                     local: "bundles/\\(jdk.*bin-tests.tar.gz\\)",
       
   740                     remote: "bundles/openjdk/GPL/windows-x86/\\1",
       
   741                 },
       
   742                 jdk_symbols: {
       
   743                     local: "bundles/\\(jdk.*bin-symbols.tar.gz\\)",
       
   744                     remote: "bundles/openjdk/GPL/windows-x86/\\1"
       
   745                 },
       
   746                 jre_symbols: {
       
   747                     local: "bundles/\\(jre.*bin-symbols.tar.gz\\)",
       
   748                     remote: "bundles/openjdk/GPL/windows-x86/\\1",
       
   749                 },
       
   750                 demo: {
       
   751                     local: "bundles/\\(jdk.*demo.zip\\)",
       
   752                     remote: "bundles/openjdk/GPL/windows-x86/\\1",
       
   753                 }
       
   754             }
       
   755         },
       
   756 
       
   757         "linux-x86-open-debug": {
       
   758             artifacts: {
       
   759                 jdk: {
       
   760                     local: "bundles/\\(jdk.*bin-debug.tar.gz\\)",
       
   761                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   762                 },
       
   763                 jre: {
       
   764                     local: "bundles/\\(jre.*bin-debug.tar.gz\\)",
       
   765                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   766                 },
       
   767                 jdk_symbols: {
       
   768                     local: "bundles/\\(jdk.*bin-debug-symbols.tar.gz\\)",
       
   769                     remote: "bundles/openjdk/GPL/profile/linux-x86/\\1",
       
   770                 },
       
   771             }
       
   772         },
       
   773 
       
   774     };
       
   775     profiles = concatObjects(profiles, profilesArtifacts);
       
   776 
       
   777 
       
   778     // Define the reference implementation profiles. These are basically the same
       
   779     // as the open profiles, but upload artifacts to a different location and
       
   780     // are only defined for specific platforms.
       
   781     profiles["linux-x64-ri"] = clone(profiles["linux-x64-open"]);
       
   782     profiles["linux-x86-ri"] = clone(profiles["linux-x86-open"]);
       
   783     profiles["linux-x86-ri-debug"] = clone(profiles["linux-x86-open-debug"]);
       
   784     profiles["windows-x86-ri"] = clone(profiles["windows-x86-open"]);
       
   785 
       
   786     // Generate artifacts for ri profiles
       
   787     [ "linux-x64-ri", "linux-x86-ri", "linux-x86-ri-debug", "windows-x86-ri" ]
       
   788         .forEach(function (name) {
       
   789             // Rewrite all remote dirs to "bundles/openjdk/BCL/..."
       
   790             for (artifactName in profiles[name].artifacts) {
       
   791                 var artifact = profiles[name].artifacts[artifactName];
       
   792                 artifact.remote = replaceAll("\/GPL\/", "/BCL/",
       
   793                     (artifact.remote != null ? artifact.remote : artifact.local));
       
   794             }
       
   795         });
   392 
   796 
   393     // Generate the missing platform attributes
   797     // Generate the missing platform attributes
   394     profiles = generatePlatformAttributes(profiles);
   798     profiles = generatePlatformAttributes(profiles);
   395     profiles = generateDefaultMakeTargetsConfigureArg(common, profiles);
   799     profiles = generateDefaultMakeTargetsConfigureArg(common, profiles);
   396     return profiles;
   800     return profiles;
   512     }
   916     }
   513     return ret;
   917     return ret;
   514 };
   918 };
   515 
   919 
   516 /**
   920 /**
   517  * Generates debug versions of profiles. Clones the given profiles and adds
       
   518  * debug metadata.
       
   519  *
       
   520  * @param common Common values
       
   521  * @param profiles Profiles map to generate debug profiles for
       
   522  * @returns {{}} New map of profiles containing debug profiles
       
   523  */
       
   524 var generateDebugProfiles = function (common, profiles) {
       
   525     var newProfiles = {};
       
   526     for (var profile in profiles) {
       
   527         var debugProfile = profile + "-debug";
       
   528         newProfiles[debugProfile] = clone(profiles[profile]);
       
   529         newProfiles[debugProfile].debug_level = "fastdebug";
       
   530         newProfiles[debugProfile].default_make_targets
       
   531             = common.default_make_targets_debug;
       
   532         newProfiles[debugProfile].labels
       
   533             = concat(newProfiles[debugProfile].labels || [], "debug"),
       
   534             newProfiles[debugProfile].configure_args
       
   535                 = concat(newProfiles[debugProfile].configure_args,
       
   536                 common.configure_args_debug);
       
   537     }
       
   538     return newProfiles;
       
   539 };
       
   540 
       
   541 /**
       
   542  * Generates slowdebug versions of profiles. Clones the given profiles and adds
       
   543  * debug metadata.
       
   544  *
       
   545  * @param common Common values
       
   546  * @param profiles Profiles map to generate debug profiles for
       
   547  * @returns {{}} New map of profiles containing debug profiles
       
   548  */
       
   549 var generateSlowdebugProfiles = function (common, profiles) {
       
   550     var newProfiles = {};
       
   551     for (var profile in profiles) {
       
   552         var debugProfile = profile + "-slowdebug";
       
   553         newProfiles[debugProfile] = clone(profiles[profile]);
       
   554         newProfiles[debugProfile].debug_level = "slowdebug";
       
   555         newProfiles[debugProfile].default_make_targets
       
   556             = common.default_make_targets_slowdebug;
       
   557         newProfiles[debugProfile].labels
       
   558             = concat(newProfiles[debugProfile].labels || [], "slowdebug"),
       
   559             newProfiles[debugProfile].configure_args
       
   560                 = concat(newProfiles[debugProfile].configure_args,
       
   561                 common.configure_args_slowdebug);
       
   562     }
       
   563     return newProfiles;
       
   564 };
       
   565 
       
   566 /**
       
   567  * Generates open only versions of profiles. Clones the given profiles and adds
       
   568  * open metadata.
       
   569  *
       
   570  * @param common Common values
       
   571  * @param profiles Profiles map to generate open only profiles for
       
   572  * @returns {{}} New map of profiles containing open only profiles
       
   573  */
       
   574 var generateOpenOnlyProfiles = function (common, profiles) {
       
   575     var newProfiles = {};
       
   576     for (var profile in profiles) {
       
   577         var openProfile = profile + "-open";
       
   578         newProfiles[openProfile] = clone(profiles[profile]);
       
   579         newProfiles[openProfile].labels
       
   580             = concat(newProfiles[openProfile].labels || [], "open"),
       
   581             newProfiles[openProfile].configure_args
       
   582                 = concat(newProfiles[openProfile].configure_args,
       
   583                 "--enable-openjdk-only");
       
   584     }
       
   585     return newProfiles;
       
   586 };
       
   587 
       
   588 /**
       
   589  * The default_make_targets attribute on a profile is not a real Jib attribute.
   921  * The default_make_targets attribute on a profile is not a real Jib attribute.
   590  * This function rewrites that attribute into the corresponding configure arg.
   922  * This function rewrites that attribute into the corresponding configure arg.
   591  * Calling this function multiple times on the same profiles object is safe.
   923  * Calling this function multiple times on the same profiles object is safe.
   592  *
   924  *
   593  * @param common Common values
   925  * @param common Common values
   600         if (ret[profile]["default_make_targets"] != null) {
   932         if (ret[profile]["default_make_targets"] != null) {
   601             var targetsString = concat(ret[profile].default_make_targets).join(" ");
   933             var targetsString = concat(ret[profile].default_make_targets).join(" ");
   602             // Iterate over all configure args and see if --with-default-make-target
   934             // Iterate over all configure args and see if --with-default-make-target
   603             // is already there and change it, otherwise add it.
   935             // is already there and change it, otherwise add it.
   604             var found = false;
   936             var found = false;
   605             for (var arg in ret[profile].configure_args) {
   937             for (var i in ret[profile].configure_args) {
   606                 if (arg.startsWith("--with-default-make-target")) {
   938                 var arg = ret[profile].configure_args[i];
       
   939                 if (arg != null && arg.startsWith("--with-default-make-target=")) {
   607                     found = true;
   940                     found = true;
   608                     arg.replace(/=.*/, "=" + targetsString);
   941                     ret[profile].configure_args[i]
       
   942                         = "--with-default-make-target=" + targetsString;
   609                 }
   943                 }
   610             }
   944             }
   611             if (!found) {
   945             if (!found) {
   612                 ret[profile].configure_args = concat(
   946                 ret[profile].configure_args = concat(
   613                     ret[profile].configure_args,
   947                     ret[profile].configure_args,
   616         }
   950         }
   617     }
   951     }
   618     return ret;
   952     return ret;
   619 }
   953 }
   620 
   954 
       
   955 var getBuildId = function (input) {
       
   956     if (input.build_id != null) {
       
   957         return input.build_id;
       
   958     } else {
       
   959         var topdir = new java.io.File(__DIR__, "../..").getCanonicalFile().getName();
       
   960         var userName = java.lang.System.getProperty("user.name");
       
   961         return userName + "." + topdir;
       
   962     }
       
   963 }
       
   964 
   621 /**
   965 /**
   622  * Deep clones an object tree.
   966  * Deep clones an object tree.
   623  *
   967  *
   624  * @param o Object to clone
   968  * @param o Object to clone
   625  * @returns {{}} Clone of o
   969  * @returns {{}} Clone of o
   636 var concat = function () {
   980 var concat = function () {
   637     return Array.prototype.concat.apply([], arguments);
   981     return Array.prototype.concat.apply([], arguments);
   638 };
   982 };
   639 
   983 
   640 /**
   984 /**
   641  * Copies all elements in an array into a new array but replacing all
   985  * Takes a String or Array of Strings and does a replace operation on each
   642  * occurrences of original with replacement.
   986  * of them.
   643  *
   987  *
   644  * @param original Element to look for
   988  * @param pattern Pattern to look for
   645  * @param replacement Element to replace with
   989  * @param replacement Replacement text to insert
   646  * @param a Array to copy
   990  * @param a String or Array of Strings to replace
   647  * @returns {Array} New array with all occurrences of original replaced
   991  * @returns {Array} Either a new array or a new string depending on the input
   648  *                  with replacement
   992  */
   649  */
   993 var replaceAll = function (pattern, replacement, a) {
   650 var replace = function (original, replacement, a) {
   994     // If a is an array
       
   995     if (Array === a.constructor) {
   651     var newA = [];
   996     var newA = [];
   652     for (var i in a) {
   997     for (var i in a) {
   653         if (original == a[i]) {
   998             newA.push(a[i].replace(pattern, replacement));
   654             newA.push(replacement);
   999         }
       
  1000         return newA;
   655         } else {
  1001         } else {
   656             newA.push(a[i]);
  1002         return a.replace(pattern, replacement);
   657         }
  1003     }
   658     }
       
   659     return newA;
       
   660 };
  1004 };
   661 
  1005 
   662 /**
  1006 /**
   663  * Deep concatenation of two objects. For each node encountered, merge
  1007  * Deep concatenation of two objects. For each node encountered, merge
   664  * the contents with the corresponding node in the other object tree,
  1008  * the contents with the corresponding node in the other object tree,
   667  * @param o1 Object to concatenate
  1011  * @param o1 Object to concatenate
   668  * @param o2 Object to concatenate
  1012  * @param o2 Object to concatenate
   669  * @returns {{}} New object tree containing the concatenation of o1 and o2
  1013  * @returns {{}} New object tree containing the concatenation of o1 and o2
   670  */
  1014  */
   671 var concatObjects = function (o1, o2) {
  1015 var concatObjects = function (o1, o2) {
       
  1016     if (o1 == null) {
       
  1017         return clone(o2);
       
  1018     }
       
  1019     if (o2 == null) {
       
  1020         return clone(o1);
       
  1021     }
   672     var ret = {};
  1022     var ret = {};
   673     for (var a in o1) {
  1023     for (var a in o1) {
   674         if (o2[a] == null) {
  1024         if (o2[a] == null) {
   675             ret[a] = o1[a];
  1025             ret[a] = clone(o1[a]);
   676         }
  1026         }
   677     }
  1027     }
   678     for (var a in o2) {
  1028     for (var a in o2) {
   679         if (o1[a] == null) {
  1029         if (o1[a] == null) {
   680             ret[a] = o2[a];
  1030             ret[a] = clone(o2[a]);
   681         } else {
  1031         } else {
   682             if (typeof o1[a] == 'string') {
  1032             if (typeof o1[a] == 'string') {
   683                 ret[a] = [o1[a]].concat(o2[a]);
  1033                 ret[a] = clone([o1[a]].concat(o2[a]));
   684             } else if (Array.isArray(o1[a])) {
  1034             } else if (Array.isArray(o1[a])) {
   685                 ret[a] = o1[a].concat(o2[a]);
  1035                 ret[a] = clone(o1[a].concat(o2[a]));
   686             } else if (typeof o1[a] == 'object') {
  1036             } else if (typeof o1[a] == 'object') {
   687                 ret[a] = concatObjects(o1[a], o2[a]);
  1037                 ret[a] = concatObjects(o1[a], o2[a]);
   688             }
  1038             }
   689         }
  1039         }
   690     }
  1040     }
   691     return ret;
  1041     return ret;
   692 };
  1042 };
       
  1043 
       
  1044 /**
       
  1045  * Constructs the numeric version string from reading the
       
  1046  * common/autoconf/version-numbers file and removing all trailing ".0".
       
  1047  *
       
  1048  * @param major Override major version
       
  1049  * @param minor Override minor version
       
  1050  * @param security Override security version
       
  1051  * @param patch Override patch version
       
  1052  * @returns {String} The numeric version string
       
  1053  */
       
  1054 var getVersion = function (major, minor, security, patch) {
       
  1055     var version_numbers = getVersionNumbers();
       
  1056     var version = (major != null ? major : version_numbers.get("DEFAULT_VERSION_MAJOR"))
       
  1057         + "." + (minor != null ? minor : version_numbers.get("DEFAULT_VERSION_MINOR"))
       
  1058         + "." + (security != null ? security :  version_numbers.get("DEFAULT_VERSION_SECURITY"))
       
  1059         + "." + (patch != null ? patch : version_numbers.get("DEFAULT_VERSION_PATCH"));
       
  1060     while (version.match(".*\.0$")) {
       
  1061         version = version.substring(0, version.length - 2);
       
  1062     }
       
  1063     return version;
       
  1064 };
       
  1065 
       
  1066 // Properties representation of the common/autoconf/version-numbers file. Lazily
       
  1067 // initiated by the function below.
       
  1068 var version_numbers;
       
  1069 
       
  1070 /**
       
  1071  * Read the common/autoconf/version-numbers file into a Properties object.
       
  1072  *
       
  1073  * @returns {java.utilProperties}
       
  1074  */
       
  1075 var getVersionNumbers = function () {
       
  1076     // Read version information from common/autoconf/version-numbers
       
  1077     if (version_numbers == null) {
       
  1078         version_numbers = new java.util.Properties();
       
  1079         var stream = new java.io.FileInputStream(__DIR__ + "/../../common/autoconf/version-numbers");
       
  1080         version_numbers.load(stream);
       
  1081         stream.close();
       
  1082     }
       
  1083     return version_numbers;
       
  1084 }