common/conf/jib-profiles.js
changeset 34496 b05757ebc035
parent 34491 307c28cb36c2
child 34595 09596fe63e2d
equal deleted inserted replaced
34495:b8008470cbd0 34496:b05757ebc035
       
     1 /*
       
     2  * Copyright (c) 2015, 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.target_os
       
    59  * input.target_cpu
       
    60  * input.build_os
       
    61  * input.build_cpu
       
    62  * input.target_platform
       
    63  * input.build_platform
       
    64  * // The build_osenv_* variables describe the unix layer on Windows systems,
       
    65  * // i.e. Cygwin, which may also be 32 or 64 bit.
       
    66  * input.build_osenv
       
    67  * input.build_osenv_cpu
       
    68  * input.build_osenv_platform
       
    69  *
       
    70  * For more complex nested attributes, there is a method "get":
       
    71  *
       
    72  * input.get("<dependency>", "<attribute>")
       
    73  *
       
    74  * Valid attributes are:
       
    75  * install_path
       
    76  * download_path
       
    77  * download_dir
       
    78  *
       
    79  *
       
    80  * The output data generated by this configuration file has the following
       
    81  * format:
       
    82  *
       
    83  * data: {
       
    84  *   // Identifies the version of this format to the tool reading it
       
    85  *   format_version: "1.0",
       
    86  *
       
    87  *   // Name of base outputdir. JIB assumes the actual output dir is formed
       
    88  *   // by adding the configuration name: <output_basedir>/<config-name>
       
    89  *   output_basedir: "build",
       
    90  *   // Configure argument to use to specify configuration name
       
    91  *   configuration_configure_arg:
       
    92  *   // Make argument to use to specify configuration name
       
    93  *   configuration_make_arg:
       
    94  *
       
    95  *   profiles: {
       
    96  *     <profile-name>: {
       
    97  *       // Name of os the profile is built to run on
       
    98  *       target_os; <string>
       
    99  *       // Name of cpu the profile is built to run on
       
   100  *       target_cpu; <string>
       
   101  *       // Combination of target_os and target_cpu for convenience
       
   102  *       target_platform; <string>
       
   103  *       // Name of os the profile is built on
       
   104  *       build_os; <string>
       
   105  *       // Name of cpu the profile is built on
       
   106  *       build_cpu; <string>
       
   107  *       // Combination of build_os and build_cpu for convenience
       
   108  *       build_platform; <string>
       
   109  *
       
   110  *       // List of dependencies needed to build this profile
       
   111  *       dependencies: <Array of strings>
       
   112  *
       
   113  *       // List of configure args to use for this profile
       
   114  *       configure_args: <Array of strings>
       
   115  *
       
   116  *       // List of free form labels describing aspects of this profile
       
   117  *       labels: <Array of strings>
       
   118  *     }
       
   119  *   }
       
   120  *
       
   121  *   // Dependencies use a Maven like deployment structure
       
   122  *   dependencies: {
       
   123  *     <dependency-name>: {
       
   124  *       // Organization part of path defining this dependency
       
   125  *       organization: <string>
       
   126  *       // File extension for this dependency
       
   127  *       ext: <string>
       
   128  *       // Module part of path for defining this dependency,
       
   129  *       // defaults to <dependency-name>
       
   130  *       module: <string>
       
   131  *       // Revision part of path for defining this dependency
       
   132  *       revision: <string>
       
   133  *
       
   134  *       // List of configure args to add when using this dependency,
       
   135  *       // defaults to
       
   136  *       // "--with-<dependency-name>=input.get("<dependency-name", "install_path")"
       
   137  *       configure_args: <array of strings>
       
   138  *
       
   139  *       // Name of environment variable to set when using this dependency
       
   140  *       // when running make
       
   141  *       environment_name: <string>
       
   142  *       // Value of environment variable to set when using this dependency
       
   143  *       // when running make
       
   144  *       environment_value: <string>
       
   145  *
       
   146  *       // Value to add to the PATH variable when using this dependency,
       
   147  *       // applies to both make and configure
       
   148  *       environment_path: <string>
       
   149  *     }
       
   150  *
       
   151  *     <dependency-name>: {
       
   152  *       // For certain dependencies where a legacy distribution mechanism is
       
   153  *       // already in place, the "javare" server layout is also supported
       
   154  *       // Indicate that an alternate server source and layout should be used
       
   155  *       server: "javare"
       
   156  *
       
   157  *       // For "javare", a combination of module, revision,
       
   158  *       // build number (optional), files and checksum file is possible for
       
   159  *       // artifacts following the standard layout.
       
   160  *       module: <string>
       
   161  *       revision: <string>
       
   162  *       build_number: <string>
       
   163  *       checksum_file: <string>
       
   164  *       file: <string>
       
   165  *
       
   166  *       // For other files, use checksum path and path instead
       
   167  *       checksum_path: <string>
       
   168  *       path: <string>
       
   169  *     }
       
   170  *   }
       
   171  * }
       
   172  */
       
   173 
       
   174 /**
       
   175  * Main entry to generate the profile configuration
       
   176  *
       
   177  * @param input External data to use for generating the configuration
       
   178  * @returns {{}} Profile configuration
       
   179  */
       
   180 var getJibProfiles = function (input) {
       
   181 
       
   182     var data = {};
       
   183 
       
   184     // Identifies the version of this format to the tool reading it
       
   185     data.format_version = "1.0";
       
   186 
       
   187     // Organization is used when uploading/publishing build results
       
   188     data.organization = "com.oracle.jpg.jdk";
       
   189 
       
   190     // The base directory for the build output. JIB will assume that the
       
   191     // actual build directory will be <output_basedir>/<configuration>
       
   192     data.output_basedir = "build";
       
   193     // The configure argument to use to specify the name of the configuration
       
   194     data.configuration_configure_arg = "--with-conf-name=";
       
   195     // The make argument to use to specify the name of the configuration
       
   196     data.configuration_make_arg = "CONF_NAME=";
       
   197 
       
   198     // Define some common values
       
   199     var common = getJibProfilesCommon(input);
       
   200     // Generate the profiles part of the configuration
       
   201     data.profiles = getJibProfilesProfiles(input, common);
       
   202     // Generate the dependencies part of the configuration
       
   203     data.dependencies = getJibProfilesDependencies(input, common);
       
   204 
       
   205     return data;
       
   206 };
       
   207 
       
   208 /**
       
   209  * Generates some common values
       
   210  *
       
   211  * @param input External data to use for generating the configuration
       
   212  * @returns Common values
       
   213  */
       
   214 var getJibProfilesCommon = function (input) {
       
   215     var common = {
       
   216         dependencies: ["boot_jdk", "gnumake", "jtreg"],
       
   217         configure_args: ["--with-default-make-target=all"],
       
   218         configure_args_32bit: ["--with-target-bits=32", "--with-jvm-variants=client,server"],
       
   219         configure_args_debug: ["--enable-debug"],
       
   220         organization: "jpg.infra.builddeps"
       
   221     };
       
   222 
       
   223     return common;
       
   224 };
       
   225 
       
   226 /**
       
   227  * Generates the profiles part of the configuration.
       
   228  *
       
   229  * @param input External data to use for generating the configuration
       
   230  * @param common The common values
       
   231  * @returns {{}} Profiles part of the configuration
       
   232  */
       
   233 var getJibProfilesProfiles = function (input, common) {
       
   234     var profiles = {};
       
   235 
       
   236     // Main SE profiles
       
   237     var mainProfiles = {
       
   238 
       
   239         "linux-x64": {
       
   240             target_os: "linux",
       
   241             target_cpu: "x64",
       
   242             dependencies: concat(common.dependencies, "devkit"),
       
   243             configure_args: common.configure_args,
       
   244             make_args: common.make_args
       
   245         },
       
   246 
       
   247         "linux-x86": {
       
   248             target_os: "linux",
       
   249             target_cpu: "x86",
       
   250             build_cpu: "x64",
       
   251             dependencies: concat(common.dependencies, "devkit"),
       
   252             configure_args: concat(common.configure_args, common.configure_args_32bit),
       
   253             make_args: common.make_args
       
   254         },
       
   255 
       
   256         "macosx-x64": {
       
   257             target_os: "macosx",
       
   258             target_cpu: "x64",
       
   259             dependencies: concat(common.dependencies, "devkit"),
       
   260             configure_args: concat(common.configure_args, "--with-sdk-name=macosx10.9"),
       
   261             make_args: common.make_args
       
   262         },
       
   263 
       
   264         "solaris-x64": {
       
   265             target_os: "solaris",
       
   266             target_cpu: "x64",
       
   267             dependencies: concat(common.dependencies, "devkit", "cups"),
       
   268             configure_args: common.configure_args,
       
   269             make_args: common.make_args
       
   270         },
       
   271 
       
   272         "solaris-sparcv9": {
       
   273             target_os: "solaris",
       
   274             target_cpu: "sparcv9",
       
   275             dependencies: concat(common.dependencies, "devkit", "cups"),
       
   276             configure_args: common.configure_args,
       
   277             make_args: common.make_args
       
   278         },
       
   279 
       
   280         "windows-x64": {
       
   281             target_os: "windows",
       
   282             target_cpu: "x64",
       
   283             dependencies: concat(common.dependencies, "devkit", "freetype"),
       
   284             configure_args: common.configure_args,
       
   285             make_args: common.make_args
       
   286         },
       
   287 
       
   288         "windows-x86": {
       
   289             target_os: "windows",
       
   290             target_cpu: "x86",
       
   291             build_cpu: "x64",
       
   292             dependencies: concat(common.dependencies, "devkit", "freetype"),
       
   293             configure_args: concat(common.configure_args, common.configure_args_32bit),
       
   294             make_args: common.make_args
       
   295         }
       
   296     };
       
   297     profiles = concatObjects(profiles, mainProfiles);
       
   298     // Generate debug versions of all the main profiles
       
   299     profiles = concatObjects(profiles, generateDebugProfiles(common, mainProfiles));
       
   300 
       
   301     // Specific open profiles needed for JPRT testing
       
   302     var jprtOpenProfiles = {
       
   303 
       
   304         "linux-x64-open": {
       
   305             target_os: mainProfiles["linux-x64"].target_os,
       
   306             target_cpu: mainProfiles["linux-x64"].target_cpu,
       
   307             dependencies: mainProfiles["linux-x64"].dependencies,
       
   308             configure_args: concat(mainProfiles["linux-x64"].configure_args,
       
   309                 "--enable-openjdk-only"),
       
   310             make_args: mainProfiles["linux-x64"].make_args,
       
   311             labels: [ "open" ]
       
   312         },
       
   313 
       
   314         "solaris-x64-open": {
       
   315             target_os: mainProfiles["solaris-x64"].target_os,
       
   316             target_cpu: mainProfiles["solaris-x64"].target_cpu,
       
   317             dependencies: mainProfiles["solaris-x64"].dependencies,
       
   318             configure_args: concat(mainProfiles["solaris-x64"].configure_args,
       
   319                 "--enable-openjdk-only"),
       
   320             make_args: mainProfiles["solaris-x64"].make_args,
       
   321             labels: [ "open" ]
       
   322         }
       
   323     };
       
   324     profiles = concatObjects(profiles, jprtOpenProfiles);
       
   325     // Generate debug profiles for the open jprt profiles
       
   326     profiles = concatObjects(profiles, generateDebugProfiles(common, jprtOpenProfiles));
       
   327 
       
   328     // Profiles used to run tests. Used in JPRT.
       
   329     var testOnlyProfiles = {
       
   330 
       
   331         "run-test": {
       
   332             target_os: input.build_os,
       
   333             target_cpu: input.build_cpu,
       
   334             dependencies: [ "jtreg", "gnumake" ],
       
   335             labels: "test"
       
   336         }
       
   337     };
       
   338     profiles = concatObjects(profiles, testOnlyProfiles);
       
   339 
       
   340     // Generate the missing platform attributes
       
   341     profiles = generatePlatformAttributes(profiles);
       
   342     return profiles;
       
   343 };
       
   344 
       
   345 /**
       
   346  * Generate the dependencies part of the configuration
       
   347  *
       
   348  * @param input External data to use for generating the configuration
       
   349  * @param common The common values
       
   350  * @returns {{}} Dependencies part of configuration
       
   351  */
       
   352 var getJibProfilesDependencies = function (input, common) {
       
   353 
       
   354     var boot_jdk_platform = input.build_os + "-"
       
   355         + (input.build_cpu == "x86" ? "i586" : input.build_cpu);
       
   356 
       
   357     var devkit_platform_revisions = {
       
   358         linux_x64: "gcc4.9.2-OEL6.4+1.0",
       
   359         macosx_x64: "Xcode6.3-MacOSX10.9+1.0",
       
   360         solaris_x64: "SS12u3-Solaris10u10+1.0",
       
   361         solaris_sparcv9: "SS12u3-Solaris10u10+1.0",
       
   362         windows_x64: "VS2013SP4+1.0"
       
   363     };
       
   364 
       
   365     var devkit_platform = (input.target_cpu == "x86"
       
   366         ? input.target_os + "_x64"
       
   367         : input.target_platform);
       
   368 
       
   369     var dependencies = {
       
   370 
       
   371         boot_jdk: {
       
   372             server: "javare",
       
   373             module: "jdk",
       
   374             revision: "8",
       
   375             checksum_file: boot_jdk_platform + "/MD5_VALUES",
       
   376             file: boot_jdk_platform + "/jdk-8-" + boot_jdk_platform + ".tar.gz",
       
   377             configure_args: (input.build_os == "macosx"
       
   378                 ? "--with-boot-jdk=" + input.get("boot_jdk", "install_path") + "/jdk1.8.0.jdk/Contents/Home"
       
   379                 : "--with-boot-jdk=" + input.get("boot_jdk", "install_path") + "/jdk1.8.0")
       
   380         },
       
   381 
       
   382         devkit: {
       
   383             organization: common.organization,
       
   384             ext: "tar.gz",
       
   385             module: "devkit-" + devkit_platform,
       
   386             revision: devkit_platform_revisions[devkit_platform]
       
   387         },
       
   388 
       
   389         build_devkit: {
       
   390             organization: common.organization,
       
   391             ext: "tar.gz",
       
   392             module: "devkit-" + input.build_platform,
       
   393             revision: devkit_platform_revisions[input.build_platform]
       
   394         },
       
   395 
       
   396         cups: {
       
   397             organization: common.organization,
       
   398             ext: "tar.gz",
       
   399             revision: "1.0118+1.0"
       
   400         },
       
   401 
       
   402         jtreg: {
       
   403             server: "javare",
       
   404             revision: "4.1",
       
   405             build_number: "b12",
       
   406             checksum_file: "MD5_VALUES",
       
   407             file: "jtreg_bin-4.1.zip",
       
   408             environment_name: "JT_HOME"
       
   409         },
       
   410 
       
   411         gnumake: {
       
   412             organization: common.organization,
       
   413             ext: "tar.gz",
       
   414             revision: "4.0+1.0",
       
   415 
       
   416             module: (input.build_os == "windows"
       
   417                 ? "gnumake-" + input.build_osenv_platform
       
   418                 : "gnumake-" + input.build_platform),
       
   419 
       
   420             configure_args: (input.build_os == "windows"
       
   421                 ? "MAKE=" + input.get("gnumake", "install_path") + "/cygwin/bin/make"
       
   422                 : "MAKE=" + input.get("gnumake", "install_path") + "/bin/make"),
       
   423 
       
   424             environment_path: (input.build_os == "windows"
       
   425                 ? input.get("gnumake", "install_path") + "/cygwin/bin"
       
   426                 : input.get("gnumake", "install_path") + "/bin")
       
   427         },
       
   428 
       
   429         freetype: {
       
   430             organization: common.organization,
       
   431             ext: "tar.gz",
       
   432             revision: "2.3.4+1.0",
       
   433             module: "freetype-" + input.target_platform
       
   434         }
       
   435     };
       
   436 
       
   437     return dependencies;
       
   438 };
       
   439 
       
   440 /**
       
   441  * Generate the missing platform attributes for profiles
       
   442  *
       
   443  * @param profiles Profiles map to generate attributes on
       
   444  * @returns {{}} New profiles map with platform attributes fully filled in
       
   445  */
       
   446 var generatePlatformAttributes = function (profiles) {
       
   447     var ret = concatObjects(profiles, {});
       
   448     for (var profile in profiles) {
       
   449         if (ret[profile].build_os == null) {
       
   450             ret[profile].build_os = ret[profile].target_os;
       
   451         }
       
   452         if (ret[profile].build_cpu == null) {
       
   453             ret[profile].build_cpu = ret[profile].target_cpu;
       
   454         }
       
   455         ret[profile].target_platform = ret[profile].target_os + "_" + ret[profile].target_cpu;
       
   456         ret[profile].build_platform = ret[profile].build_os + "_" + ret[profile].build_cpu;
       
   457     }
       
   458     return ret;
       
   459 };
       
   460 
       
   461 /**
       
   462  * Generates debug versions of profiles. Clones the given profiles and adds
       
   463  * debug metadata.
       
   464  *
       
   465  * @param common Common values
       
   466  * @param profiles Profiles map to generate debug profiles for
       
   467  * @returns {{}} New map of profiles containing debug profiles
       
   468  */
       
   469 var generateDebugProfiles = function (common, profiles) {
       
   470     var newProfiles = {};
       
   471     for (var profile in profiles) {
       
   472         var debugProfile = profile + "-debug";
       
   473         newProfiles[debugProfile] = clone(profiles[profile]);
       
   474         newProfiles[debugProfile].debug_level = "fastdebug";
       
   475         newProfiles[debugProfile].labels
       
   476             = concat(newProfiles[debugProfile].labels || [], "debug"),
       
   477             newProfiles[debugProfile].configure_args
       
   478                 = concat(newProfiles[debugProfile].configure_args,
       
   479                 common.configure_args_debug);
       
   480     }
       
   481     return newProfiles;
       
   482 };
       
   483 
       
   484 /**
       
   485  * Deep clones an object tree.
       
   486  *
       
   487  * @param o Object to clone
       
   488  * @returns {{}} Clone of o
       
   489  */
       
   490 var clone = function (o) {
       
   491     return JSON.parse(JSON.stringify(o));
       
   492 };
       
   493 
       
   494 /**
       
   495  * Concatenates all arguments into a new array
       
   496  *
       
   497  * @returns {Array.<T>} New array containing all arguments
       
   498  */
       
   499 var concat = function () {
       
   500     return Array.prototype.concat.apply([], arguments);
       
   501 };
       
   502 
       
   503 /**
       
   504  * Copies all elements in an array into a new array but replacing all
       
   505  * occurrences of original with replacement.
       
   506  *
       
   507  * @param original Element to look for
       
   508  * @param replacement Element to replace with
       
   509  * @param a Array to copy
       
   510  * @returns {Array} New array with all occurrences of original replaced
       
   511  *                  with replacement
       
   512  */
       
   513 var replace = function (original, replacement, a) {
       
   514     var newA = [];
       
   515     for (var i in a) {
       
   516         if (original == a[i]) {
       
   517             newA.push(replacement);
       
   518         } else {
       
   519             newA.push(a[i]);
       
   520         }
       
   521     }
       
   522     return newA;
       
   523 };
       
   524 
       
   525 /**
       
   526  * Deep concatenation of two objects. For each node encountered, merge
       
   527  * the contents with the corresponding node in the other object tree,
       
   528  * treating all strings as array elements.
       
   529  *
       
   530  * @param o1 Object to concatenate
       
   531  * @param o2 Object to concatenate
       
   532  * @returns {{}} New object tree containing the concatenation of o1 and o2
       
   533  */
       
   534 var concatObjects = function (o1, o2) {
       
   535     var ret = {};
       
   536     for (var a in o1) {
       
   537         if (o2[a] == null) {
       
   538             ret[a] = o1[a];
       
   539         }
       
   540     }
       
   541     for (var a in o2) {
       
   542         if (o1[a] == null) {
       
   543             ret[a] = o2[a];
       
   544         } else {
       
   545             if (typeof o1[a] == 'string') {
       
   546                 ret[a] = [o1[a]].concat(o2[a]);
       
   547             } else if (Array.isArray(o1[a])) {
       
   548                 ret[a] = o1[a].concat(o2[a]);
       
   549             } else if (typeof o1[a] == 'object') {
       
   550                 ret[a] = concatObjects(o1[a], o2[a]);
       
   551             }
       
   552         }
       
   553     }
       
   554     return ret;
       
   555 };