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", "--enable-jtreg-failure-handler"], 218 configure_args_32bit: ["--with-target-bits=32", "--with-jvm-variants=client,server"], 219 configure_args_debug: ["--enable-debug"], 220 configure_args_slowdebug: ["--with-debug-level=slowdebug"], 221 organization: "jpg.infra.builddeps" 222 }; 223 224 return common; 225 }; 226 227 /** 228 * Generates the profiles part of the configuration. 229 * 230 * @param input External data to use for generating the configuration 231 * @param common The common values 232 * @returns {{}} Profiles part of the configuration 233 */ 234 var getJibProfilesProfiles = function (input, common) { 235 var profiles = {}; 236 237 // Main SE profiles 238 var mainProfiles = { 239 240 "linux-x64": { 241 target_os: "linux", 242 target_cpu: "x64", 243 dependencies: concat(common.dependencies, "devkit"), 244 configure_args: concat(common.configure_args, "--with-zlib=system"), 245 make_args: common.make_args 246 }, 247 248 "linux-x86": { 249 target_os: "linux", 250 target_cpu: "x86", 251 build_cpu: "x64", 252 dependencies: concat(common.dependencies, "devkit"), 253 configure_args: concat(common.configure_args, common.configure_args_32bit, 254 "--with-zlib=system"), 255 make_args: common.make_args 256 }, 257 258 "macosx-x64": { 259 target_os: "macosx", 260 target_cpu: "x64", 261 dependencies: concat(common.dependencies, "devkit"), 262 configure_args: concat(common.configure_args, "--with-zlib=system"), 263 make_args: common.make_args 264 }, 265 266 "solaris-x64": { 267 target_os: "solaris", 268 target_cpu: "x64", 269 dependencies: concat(common.dependencies, "devkit", "cups"), 270 configure_args: concat(common.configure_args, "--with-zlib=system"), 271 make_args: common.make_args 272 }, 273 274 "solaris-sparcv9": { 275 target_os: "solaris", 276 target_cpu: "sparcv9", 277 dependencies: concat(common.dependencies, "devkit", "cups"), 278 configure_args: concat(common.configure_args, "--with-zlib=system"), 279 make_args: common.make_args 280 }, 281 282 "windows-x64": { 283 target_os: "windows", 284 target_cpu: "x64", 285 dependencies: concat(common.dependencies, "devkit", "freetype"), 286 configure_args: common.configure_args, 287 make_args: common.make_args 288 }, 289 290 "windows-x86": { 291 target_os: "windows", 292 target_cpu: "x86", 293 build_cpu: "x64", 294 dependencies: concat(common.dependencies, "devkit", "freetype"), 295 configure_args: concat(common.configure_args, common.configure_args_32bit), 296 make_args: common.make_args 297 } 298 }; 299 profiles = concatObjects(profiles, mainProfiles); 300 // Generate debug versions of all the main profiles 301 profiles = concatObjects(profiles, generateDebugProfiles(common, mainProfiles)); 302 // Generate slowdebug versions of all the main profiles 303 profiles = concatObjects(profiles, generateSlowdebugProfiles(common, mainProfiles)); 304 305 // Generate open only profiles for all the main profiles for JPRT and reference 306 // implementation builds. 307 var openOnlyProfiles = generateOpenOnlyProfiles(common, mainProfiles); 308 // The open only profiles on linux are used for reference builds and should 309 // produce the compact profile images by default. 310 var openOnlyProfilesExtra = { 311 "linux-x64-open": { 312 configure_args: ["--with-default-make-target=all profiles"], 313 }, 314 315 "linux-x86-open": { 316 configure_args: ["--with-default-make-target=all profiles"], 317 } 318 }; 319 var openOnlyProfiles = concatObjects(openOnlyProfiles, openOnlyProfilesExtra); 320 321 profiles = concatObjects(profiles, openOnlyProfiles); 322 // Generate debug profiles for the open jprt profiles 323 profiles = concatObjects(profiles, generateDebugProfiles(common, openOnlyProfiles)); 324 325 // Profiles used to run tests. Used in JPRT. 326 var testOnlyProfiles = { 327 328 "run-test": { 329 target_os: input.build_os, 330 target_cpu: input.build_cpu, 331 dependencies: [ "jtreg", "gnumake" ], 332 labels: "test" 333 } 334 }; 335 profiles = concatObjects(profiles, testOnlyProfiles); 336 337 // Generate the missing platform attributes 338 profiles = generatePlatformAttributes(profiles); 339 return profiles; 340 }; 341 342 /** 343 * Generate the dependencies part of the configuration 344 * 345 * @param input External data to use for generating the configuration 346 * @param common The common values 347 * @returns {{}} Dependencies part of configuration 348 */ 349 var getJibProfilesDependencies = function (input, common) { 350 351 var boot_jdk_platform = input.build_os + "-" 352 + (input.build_cpu == "x86" ? "i586" : input.build_cpu); 353 354 var devkit_platform_revisions = { 355 linux_x64: "gcc4.9.2-OEL6.4+1.0", 356 macosx_x64: "Xcode6.3-MacOSX10.9+1.0", 357 solaris_x64: "SS12u4-Solaris11u1+1.0", 358 solaris_sparcv9: "SS12u4-Solaris11u1+1.0", 452 ret[profile].target_platform = ret[profile].target_os + "_" + ret[profile].target_cpu; 453 ret[profile].build_platform = ret[profile].build_os + "_" + ret[profile].build_cpu; 454 } 455 return ret; 456 }; 457 458 /** 459 * Generates debug versions of profiles. Clones the given profiles and adds 460 * debug metadata. 461 * 462 * @param common Common values 463 * @param profiles Profiles map to generate debug profiles for 464 * @returns {{}} New map of profiles containing debug profiles 465 */ 466 var generateDebugProfiles = function (common, profiles) { 467 var newProfiles = {}; 468 for (var profile in profiles) { 469 var debugProfile = profile + "-debug"; 470 newProfiles[debugProfile] = clone(profiles[profile]); 471 newProfiles[debugProfile].debug_level = "fastdebug"; 472 newProfiles[debugProfile].labels 473 = concat(newProfiles[debugProfile].labels || [], "debug"), 474 newProfiles[debugProfile].configure_args 475 = concat(newProfiles[debugProfile].configure_args, 476 common.configure_args_debug); 477 } 478 return newProfiles; 479 }; 480 481 /** 482 * Generates slowdebug versions of profiles. Clones the given profiles and adds 483 * debug metadata. 484 * 485 * @param common Common values 486 * @param profiles Profiles map to generate debug profiles for 487 * @returns {{}} New map of profiles containing debug profiles 488 */ 489 var generateSlowdebugProfiles = function (common, profiles) { 490 var newProfiles = {}; 491 for (var profile in profiles) { 492 var debugProfile = profile + "-slowdebug"; 493 newProfiles[debugProfile] = clone(profiles[profile]); 494 newProfiles[debugProfile].debug_level = "slowdebug"; 495 newProfiles[debugProfile].labels 496 = concat(newProfiles[debugProfile].labels || [], "slowdebug"), 497 newProfiles[debugProfile].configure_args 498 = concat(newProfiles[debugProfile].configure_args, 499 common.configure_args_slowdebug); 500 } 501 return newProfiles; 502 }; 503 504 /** 505 * Generates open only versions of profiles. Clones the given profiles and adds 506 * open metadata. 507 * 508 * @param common Common values 509 * @param profiles Profiles map to generate open only profiles for 510 * @returns {{}} New map of profiles containing open only profiles 511 */ 512 var generateOpenOnlyProfiles = function (common, profiles) { 513 var newProfiles = {}; 514 for (var profile in profiles) { 515 var openProfile = profile + "-open"; 516 newProfiles[openProfile] = clone(profiles[profile]); 517 newProfiles[openProfile].labels 518 = concat(newProfiles[openProfile].labels || [], "open"), 519 newProfiles[openProfile].configure_args 520 = concat(newProfiles[openProfile].configure_args, 521 "--enable-openjdk-only"); 522 } 523 return newProfiles; 524 }; 525 526 /** 527 * Deep clones an object tree. 528 * 529 * @param o Object to clone 530 * @returns {{}} Clone of o 531 */ 532 var clone = function (o) { 533 return JSON.parse(JSON.stringify(o)); 534 }; 535 536 /** 537 * Concatenates all arguments into a new array 538 * 539 * @returns {Array.<T>} New array containing all arguments 540 */ 541 var concat = function () { 542 return Array.prototype.concat.apply([], arguments); 543 }; 544 | 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 217 common.dependencies = ["boot_jdk", "gnumake", "jtreg"], 218 common.default_make_targets = ["product-images", "test-image"], 219 common.default_make_targets_debug = common.default_make_targets; 220 common.default_make_targets_slowdebug = common.default_make_targets; 221 common.configure_args = ["--enable-jtreg-failure-handler"], 222 common.configure_args_32bit = ["--with-target-bits=32", "--with-jvm-variants=client,server"], 223 common.configure_args_debug = ["--enable-debug"], 224 common.configure_args_slowdebug = ["--with-debug-level=slowdebug"], 225 common.organization = "jpg.infra.builddeps" 226 227 return common; 228 }; 229 230 /** 231 * Generates the profiles part of the configuration. 232 * 233 * @param input External data to use for generating the configuration 234 * @param common The common values 235 * @returns {{}} Profiles part of the configuration 236 */ 237 var getJibProfilesProfiles = function (input, common) { 238 var profiles = {}; 239 240 // Main SE profiles 241 var mainProfiles = { 242 243 "linux-x64": { 244 target_os: "linux", 245 target_cpu: "x64", 246 dependencies: concat(common.dependencies, "devkit"), 247 configure_args: concat(common.configure_args, "--with-zlib=system"), 248 default_make_targets: concat(common.default_make_targets, "docs-image") 249 }, 250 251 "linux-x86": { 252 target_os: "linux", 253 target_cpu: "x86", 254 build_cpu: "x64", 255 dependencies: concat(common.dependencies, "devkit"), 256 configure_args: concat(common.configure_args, common.configure_args_32bit, 257 "--with-zlib=system"), 258 default_make_targets: common.default_make_targets 259 }, 260 261 "macosx-x64": { 262 target_os: "macosx", 263 target_cpu: "x64", 264 dependencies: concat(common.dependencies, "devkit"), 265 configure_args: concat(common.configure_args, "--with-zlib=system"), 266 default_make_targets: common.default_make_targets 267 }, 268 269 "solaris-x64": { 270 target_os: "solaris", 271 target_cpu: "x64", 272 dependencies: concat(common.dependencies, "devkit", "cups"), 273 configure_args: concat(common.configure_args, "--with-zlib=system"), 274 default_make_targets: common.default_make_targets 275 }, 276 277 "solaris-sparcv9": { 278 target_os: "solaris", 279 target_cpu: "sparcv9", 280 dependencies: concat(common.dependencies, "devkit", "cups"), 281 configure_args: concat(common.configure_args, "--with-zlib=system"), 282 default_make_targets: common.default_make_targets 283 }, 284 285 "windows-x64": { 286 target_os: "windows", 287 target_cpu: "x64", 288 dependencies: concat(common.dependencies, "devkit", "freetype"), 289 configure_args: concat(common.configure_args), 290 default_make_targets: common.default_make_targets 291 }, 292 293 "windows-x86": { 294 target_os: "windows", 295 target_cpu: "x86", 296 build_cpu: "x64", 297 dependencies: concat(common.dependencies, "devkit", "freetype"), 298 configure_args: concat(common.configure_args, common.configure_args_32bit), 299 default_make_targets: common.default_make_targets 300 } 301 }; 302 profiles = concatObjects(profiles, mainProfiles); 303 // Generate debug versions of all the main profiles 304 profiles = concatObjects(profiles, generateDebugProfiles(common, mainProfiles)); 305 // Generate slowdebug versions of all the main profiles 306 profiles = concatObjects(profiles, generateSlowdebugProfiles(common, mainProfiles)); 307 308 // Generate open only profiles for all the main profiles for JPRT and reference 309 // implementation builds. 310 var openOnlyProfiles = generateOpenOnlyProfiles(common, mainProfiles); 311 // The open only profiles on linux are used for reference builds and should 312 // produce the compact profile images by default. This adds "profiles" as an 313 // extra default target. 314 var openOnlyProfilesExtra = { 315 "linux-x64-open": { 316 default_make_targets: "profiles" 317 }, 318 319 "linux-x86-open": { 320 default_make_targets: "profiles" 321 } 322 }; 323 var openOnlyProfiles = concatObjects(openOnlyProfiles, openOnlyProfilesExtra); 324 325 profiles = concatObjects(profiles, openOnlyProfiles); 326 // Generate debug profiles for the open jprt profiles 327 profiles = concatObjects(profiles, generateDebugProfiles(common, openOnlyProfiles)); 328 329 // Profiles used to run tests. Used in JPRT. 330 var testOnlyProfiles = { 331 332 "run-test": { 333 target_os: input.build_os, 334 target_cpu: input.build_cpu, 335 dependencies: [ "jtreg", "gnumake" ], 336 labels: "test" 337 } 338 }; 339 profiles = concatObjects(profiles, testOnlyProfiles); 340 341 // Generate the missing platform attributes 342 profiles = generatePlatformAttributes(profiles); 343 profiles = generateDefaultMakeTargetsConfigureArg(common, profiles); 344 return profiles; 345 }; 346 347 /** 348 * Generate the dependencies part of the configuration 349 * 350 * @param input External data to use for generating the configuration 351 * @param common The common values 352 * @returns {{}} Dependencies part of configuration 353 */ 354 var getJibProfilesDependencies = function (input, common) { 355 356 var boot_jdk_platform = input.build_os + "-" 357 + (input.build_cpu == "x86" ? "i586" : input.build_cpu); 358 359 var devkit_platform_revisions = { 360 linux_x64: "gcc4.9.2-OEL6.4+1.0", 361 macosx_x64: "Xcode6.3-MacOSX10.9+1.0", 362 solaris_x64: "SS12u4-Solaris11u1+1.0", 363 solaris_sparcv9: "SS12u4-Solaris11u1+1.0", 457 ret[profile].target_platform = ret[profile].target_os + "_" + ret[profile].target_cpu; 458 ret[profile].build_platform = ret[profile].build_os + "_" + ret[profile].build_cpu; 459 } 460 return ret; 461 }; 462 463 /** 464 * Generates debug versions of profiles. Clones the given profiles and adds 465 * debug metadata. 466 * 467 * @param common Common values 468 * @param profiles Profiles map to generate debug profiles for 469 * @returns {{}} New map of profiles containing debug profiles 470 */ 471 var generateDebugProfiles = function (common, profiles) { 472 var newProfiles = {}; 473 for (var profile in profiles) { 474 var debugProfile = profile + "-debug"; 475 newProfiles[debugProfile] = clone(profiles[profile]); 476 newProfiles[debugProfile].debug_level = "fastdebug"; 477 newProfiles[debugProfile].default_make_targets 478 = common.default_make_targets_debug; 479 newProfiles[debugProfile].labels 480 = concat(newProfiles[debugProfile].labels || [], "debug"), 481 newProfiles[debugProfile].configure_args 482 = concat(newProfiles[debugProfile].configure_args, 483 common.configure_args_debug); 484 } 485 return newProfiles; 486 }; 487 488 /** 489 * Generates slowdebug versions of profiles. Clones the given profiles and adds 490 * debug metadata. 491 * 492 * @param common Common values 493 * @param profiles Profiles map to generate debug profiles for 494 * @returns {{}} New map of profiles containing debug profiles 495 */ 496 var generateSlowdebugProfiles = function (common, profiles) { 497 var newProfiles = {}; 498 for (var profile in profiles) { 499 var debugProfile = profile + "-slowdebug"; 500 newProfiles[debugProfile] = clone(profiles[profile]); 501 newProfiles[debugProfile].debug_level = "slowdebug"; 502 newProfiles[debugProfile].default_make_targets 503 = common.default_make_targets_slowdebug; 504 newProfiles[debugProfile].labels 505 = concat(newProfiles[debugProfile].labels || [], "slowdebug"), 506 newProfiles[debugProfile].configure_args 507 = concat(newProfiles[debugProfile].configure_args, 508 common.configure_args_slowdebug); 509 } 510 return newProfiles; 511 }; 512 513 /** 514 * Generates open only versions of profiles. Clones the given profiles and adds 515 * open metadata. 516 * 517 * @param common Common values 518 * @param profiles Profiles map to generate open only profiles for 519 * @returns {{}} New map of profiles containing open only profiles 520 */ 521 var generateOpenOnlyProfiles = function (common, profiles) { 522 var newProfiles = {}; 523 for (var profile in profiles) { 524 var openProfile = profile + "-open"; 525 newProfiles[openProfile] = clone(profiles[profile]); 526 newProfiles[openProfile].labels 527 = concat(newProfiles[openProfile].labels || [], "open"), 528 newProfiles[openProfile].configure_args 529 = concat(newProfiles[openProfile].configure_args, 530 "--enable-openjdk-only"); 531 } 532 return newProfiles; 533 }; 534 535 /** 536 * The default_make_targets attribute on a profile is not a real Jib attribute. 537 * This function rewrites that attribute into the corresponding configure arg. 538 * Calling this function multiple times on the same profiles object is safe. 539 * 540 * @param common Common values 541 * @param profiles Profiles map to rewrite profiles for 542 * @returns {{}} New map of profiles with the make targets converted 543 */ 544 var generateDefaultMakeTargetsConfigureArg = function (common, profiles) { 545 var ret = concatObjects(profiles, {}); 546 for (var profile in ret) { 547 if (ret[profile]["default_make_targets"] != null) { 548 var targetsString = concat(ret[profile].default_make_targets).join(" "); 549 // Iterate over all configure args and see if --with-default-make-target 550 // is already there and change it, otherwise add it. 551 var found = false; 552 for (var arg in ret[profile].configure_args) { 553 if (arg.startsWith("--with-default-make-target")) { 554 found = true; 555 arg.replace(/=.*/, "=" + targetsString); 556 } 557 } 558 if (!found) { 559 ret[profile].configure_args = concat( 560 ret[profile].configure_args, 561 "--with-default-make-target=" + targetsString); 562 } 563 } 564 } 565 return ret; 566 } 567 568 /** 569 * Deep clones an object tree. 570 * 571 * @param o Object to clone 572 * @returns {{}} Clone of o 573 */ 574 var clone = function (o) { 575 return JSON.parse(JSON.stringify(o)); 576 }; 577 578 /** 579 * Concatenates all arguments into a new array 580 * 581 * @returns {Array.<T>} New array containing all arguments 582 */ 583 var concat = function () { 584 return Array.prototype.concat.apply([], arguments); 585 }; 586 |