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