forked from corretto/corretto-11
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
291 lines (264 loc) · 11 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*
* Copyright (c) 2019, Amazon.com, Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Amazon designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
// Tasks can refer to version information using the project.version
// property. For an example of its usage, see ':installers:linux:rpm:buildLogic'
// where the version numbers are used to populate a templated RPM spec file.
import org.apache.tools.ant.taskdefs.condition.Os
allprojects {
apply plugin: 'base'
configurations {
compile {
transitive = false
}
}
version = {
def full = file('version.txt').text.trim()
def tokens = full.tokenize(".")
[full : full,
major : tokens[0],
minor : tokens[1],
security: tokens[2],
build : tokens[3],
revision: tokens[4],
upstream: "${tokens[0]}.${tokens[1]}.${tokens[2]}.${tokens[3]}"]
}.call()
buildDir = 'corretto-build'
ext {
buildRoot = file("$buildDir/buildRoot")
distributionDir = file("$buildDir/distributions")
packageInfo = [
url : "https://github.com/corretto/corretto-${project.version.major}",
vendor : 'Amazon',
packager : 'Amazon',
description : 'Amazon Corretto\'s packaging of the runtime core elements of the OpenJDK 11 code.',
license : 'ASL 1.1 and ASL 2.0 and BSD and BSD with advertising and GPL+ and GPLv2 and GPLv2 with ' +
'exceptions and IJG and LGPLv2+ and MIT and MPLv2.0 and Public Domain and W3C and zlib and ' +
'ISC and FTL and RSA.',
maintainer: 'Amazon Corretto Team <[email protected]>',
buildHost : 'build.amazon.com'
]
jdkTools = ['java', 'keytool', 'rmid', 'rmiregistry', 'jjs', 'pack200', 'unpack200', 'javac', 'jaotc', 'jlink',
'jmod', 'jhsdb', 'jar', 'jarsigner', 'javadoc', 'javap', 'jcmd', 'jconsole', 'jdb', 'jdeps', 'jdeprscan',
'jimage', 'jinfo', 'jmap', 'jps', 'jrunscript', 'jshell', 'jstack', 'jstat', 'jstatd', 'rmic', 'serialver']
// artifact names
caCerts = "cacerts"
sourceTar = "amazon-corretto-source-${project.version.full}.tar.gz"
def versionOpt = project.findProperty("corretto.versionOpt") ?: "LTS"
correttoCommonFlags = [
"--with-freetype=bundled",
'--with-jvm-features=zgc shenandoahgc',
"--with-version-build=${project.version.build}",
"--with-version-opt=${versionOpt}",
'--with-version-pre=',
"--with-vendor-bug-url=https://github.com/corretto/corretto-${project.version.major}/issues/",
"--with-vendor-vm-bug-url=https://github.com/corretto/corretto-${project.version.major}/issues/",
'--with-vendor-name=Amazon.com Inc.',
'--with-vendor-url=https://aws.amazon.com/corretto/',
"--with-vendor-version-string=Corretto-${project.version.full}"
]
def versionDate = project.findProperty("corretto.versionDate")
if (versionDate) {
correttoCommonFlags += ["--with-version-date=${versionDate}"]
}
is_x86 = false
is_armv7 = false
if (project.hasProperty("x86")) {
is_x86 = Boolean.valueOf("${project.getProperty('x86')}")
}
if (project.hasProperty("armv7")) {
is_armv7 = Boolean.valueOf("${project.getProperty('armv7')}")
}
if (is_x86) {
correttoCommonFlags += ["--with-target-bits=32"]
} else if (!is_armv7) {
// ARMV7 is built from cross-platform compilation with '--openjdk-target'
// flag, which is in conflict with '--with-target-bits'.
correttoCommonFlags += ["--with-target-bits=64"]
}
// Valid value: null, release, debug, fastdebug, slowdebug
def correttoDebugLevel = "release" // Default: release
switch(project.findProperty("corretto.debug_level")) {
case null:
case "release":
correttoCommonFlags += ['--with-debug-level=release', '--with-native-debug-symbols=none']
break
case "fastdebug":
correttoDebugLevel = "fastdebug"
correttoCommonFlags += ['--with-debug-level=fastdebug', '--with-native-debug-symbols=zipped']
break
case "debug":
case "slowdebug":
correttoDebugLevel = "slowdebug"
correttoCommonFlags += ['--with-debug-level=slowdebug', '--with-native-debug-symbols=external']
break
default:
throw new RuntimeException("Invalid corretto.debug_level")
}
// customized flags. Identify the index of double dashes as the start of a flag
String extraConfig = project.findProperty("corretto.extra_config")
def lastIndex = -1
if (extraConfig != null) {
for (int index = extraConfig.indexOf("--"); index >= 0; index = extraConfig.indexOf("--", index + 1)) {
if (lastIndex != -1) {
correttoCommonFlags += extraConfig.substring(lastIndex, index).trim()
}
lastIndex = index
}
if (lastIndex != -1) {
correttoCommonFlags += extraConfig.substring(lastIndex).trim()
}
}
// Determine the system architecture
def jdkArch = ""
def os = ""
if (Os.isFamily(Os.FAMILY_MAC)) {
os = 'macosx'
jdkArch = "x86_64"
} else if (Os.isFamily(Os.FAMILY_UNIX)) {
os = 'linux'
jdkArch = ['uname', '-m'].execute().text.trim()
// `uname -m` returns the host arch in a linux x86 docker instance. Pass a flag
// to enable
if (is_x86) {
jdkArch = "x86"
} else if (is_armv7) {
jdkArch = "armv7"
}
} else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
os = 'windows'
def arch = System.getenv('PROCESSOR_ARCHITECTURE')
if (arch == 'AMD64') {
jdkArch = "x86_64"
} else { //x86
jdkArch = arch
}
} else {
throw new GradleException("OS is not supported")
}
// Ext property: correttoArch
switch (jdkArch) {
case 'x86':
case 'aarch64':
correttoArch = jdkArch
break
case 'x86_64':
correttoArch = 'x64'
break
case 'armv7':
correttoArch = jdkArch
jdkArch = 'arm'
break
default:
throw new GradleException("${jdkArch} is not supported")
}
// Call toString explicitly to avoid lazy evaluation
jdkImageName = "${os}-${jdkArch}-normal-server-${correttoDebugLevel}".toString()
// no debug level suffix for release build
if (correttoDebugLevel == "release") {
correttoJdkArchiveName = "amazon-corretto-${project.version.full}-${os}-${correttoArch}".toString()
} else {
correttoJdkArchiveName =
"amazon-corretto-${project.version.full}-${os}-${correttoArch}-${correttoDebugLevel}".toString()
}
correttoTestImageArchiveName = "amazon-corretto-testimage-${project.version.full}-${os}-${correttoArch}".toString()
}
}
project(':prebuild') {
apply plugin: 'java'
configurations {
cacerts
}
ext {
cacertDir = "$distributionDir/${project.caCerts}"
}
def preBuildSrc = "src"
def classPath = "classes"
def generateToolMain = "build.tools.generatecacerts.GenerateCacerts"
task copyToolSrc(type: Copy) {
description 'Copy utility tool source to the project root'
from fileTree("$rootDir/make/jdk/src/classes") {
include 'build/tools/generatecacerts/*'
}
into preBuildSrc
}
task buildTool(type: JavaCompile) {
dependsOn copyToolSrc
source = fileTree(dir: preBuildSrc, include: '**/*.java')
destinationDir = file(classPath)
classpath = files(classPath)
}
task generateJdkCacerts(type: JavaExec) {
dependsOn buildTool
def jdkCaDir = "$rootDir/make/data/cacerts"
description = 'Generate Cacerts from JDK source'
classpath = files(classPath)
main = generateToolMain
args = [jdkCaDir, project.caCerts]
}
task importAmazonCacerts(type: Exec) {
dependsOn generateJdkCacerts
// Default password for JSSE key store
def keystore_password = "changeit"
commandLine 'keytool', '-importkeystore', '-noprompt',
'-srckeystore', "$rootDir/amazon-cacerts",
'-srcstorepass', keystore_password,
'-destkeystore', caCerts,
'-deststorepass', keystore_password
}
task copyCacerts(type: Copy) {
dependsOn importAmazonCacerts
from caCerts
into distributionDir
}
artifacts {
cacerts file: file("$distributionDir/${caCerts}"), builtBy: copyCacerts
}
}
project(':openjdksrc') {
/**
* Compresses a snapshot of the source code used to perform the build.
*/
task sourceDistributionTarball(type: Tar) {
description 'Assemble source files required for building and distributing Corretto.'
compression Compression.GZIP
archiveName sourceTar
from fileTree(rootDir) {
include 'LICENSE',
'ADDITIONAL_LICENSE_INFO',
'README',
'README.md',
'ASSEMBLY_EXCEPTION',
'commitId.txt',
'version.txt',
'amazon-cacerts',
'configure',
'Makefile',
'bin/**',
'doc/**',
'make/**',
'src/**',
'test/**'
}
}
artifacts {
archives sourceDistributionTarball
}
}