forked from adoptium/temurin-build
-
Notifications
You must be signed in to change notification settings - Fork 2
/
configureBuild.sh
executable file
·321 lines (274 loc) · 11.9 KB
/
configureBuild.sh
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
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
#!/bin/bash
################################################################################
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
################################################################################
################################################################################
#
# This script sets up the initial configuration for an (Adopt) OpenJDK Build.
# See the configure_build function and its child functions for details.
# It's sourced by the makejdk-any-platform.sh script.
#
################################################################################
set -eu
# i.e. Where we are
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=sbin/common/constants.sh
source "$SCRIPT_DIR/sbin/common/constants.sh"
# shellcheck source=sbin/common/common.sh
source "$SCRIPT_DIR/sbin/common/common.sh"
# Bring in the source signal handler
sourceSignalHandler() {
#shellcheck source=signalhandler.sh
source "$SCRIPT_DIR/signalhandler.sh"
}
# Parse the command line arguments
parseCommandLineArgs() {
# Defer most of the work to the shared function in common-functions.sh
parseConfigurationArguments "$@"
# this check is to maintain backwards compatibility and allow user to use
# -v rather than the mandatory argument
if [[ "${BUILD_CONFIG[OPENJDK_FOREST_NAME]}" == "" ]]; then
if [[ $# -eq 0 ]]; then
echo "Please provide a java version to build as an argument"
exit 1
fi
while [[ $# -gt 1 ]]; do
shift
done
# Now that we've processed the flags, grab the mandatory argument(s)
setOpenJdkVersion "$1"
setDockerVolumeSuffix "$1"
fi
}
# Extra config for OpenJDK variants such as OpenJ9, SAP et al
# shellcheck disable=SC2153
doAnyBuildVariantOverrides() {
if [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_SAP}" ]]; then
local branch="sapmachine10"
BUILD_CONFIG[BRANCH]=${branch:-${BUILD_CONFIG[BRANCH]}}
fi
}
# Set the working directory for this build
setWorkingDirectory() {
if [ -z "${BUILD_CONFIG[WORKSPACE_DIR]}" ]; then
if [[ "${BUILD_CONFIG[USE_DOCKER]}" == "true" ]]; then
BUILD_CONFIG[WORKSPACE_DIR]="/openjdk/"
else
BUILD_CONFIG[WORKSPACE_DIR]="$PWD/workspace"
mkdir -p "${BUILD_CONFIG[WORKSPACE_DIR]}" || exit
fi
else
echo "Workspace dir is ${BUILD_CONFIG[WORKSPACE_DIR]}"
fi
echo "Working dir is ${BUILD_CONFIG[WORKING_DIR]}"
}
# shellcheck disable=SC2153
determineBuildProperties() {
local build_type=
local default_build_full_name=
# From jdk12 there is no build type in the build output directory name
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK12_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK13_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK14_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK15_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDKHEAD_CORE_VERSION}" ]; then
build_type=normal
default_build_full_name=${BUILD_CONFIG[OS_KERNEL_NAME]}-${BUILD_CONFIG[OS_ARCHITECTURE]}-${BUILD_CONFIG[JVM_VARIANT]}-release
else
default_build_full_name=${BUILD_CONFIG[OS_KERNEL_NAME]}-${BUILD_CONFIG[OS_ARCHITECTURE]}-${build_type}-${BUILD_CONFIG[JVM_VARIANT]}-release
fi
BUILD_CONFIG[BUILD_FULL_NAME]=${BUILD_CONFIG[BUILD_FULL_NAME]:-"$default_build_full_name"}
}
# Set variables that the `configure` command (which builds OpenJDK) will need
# shellcheck disable=SC2153
setVariablesForConfigure() {
local openjdk_core_version=${BUILD_CONFIG[OPENJDK_CORE_VERSION]}
# test-image and debug-image targets are optional - build scripts check whether the directories exist
local openjdk_test_image_path="test"
local openjdk_debug_image_path="debug-image"
if [ "$openjdk_core_version" == "${JDK8_CORE_VERSION}" ]; then
local jdk_path="j2sdk-image"
local jre_path="j2re-image"
case "${BUILD_CONFIG[OS_KERNEL_NAME]}" in
"darwin")
local jdk_path="j2sdk-bundle/jdk*.jdk"
local jre_path="j2re-bundle/jre*.jre"
;;
esac
else
local jdk_path="jdk"
local jre_path="jre"
case "${BUILD_CONFIG[OS_KERNEL_NAME]}" in
"darwin")
local jdk_path="jdk-bundle/jdk-*.jdk"
local jre_path="jre-bundle/jre-*.jre"
;;
esac
fi
BUILD_CONFIG[JDK_PATH]=$jdk_path
BUILD_CONFIG[JRE_PATH]=$jre_path
BUILD_CONFIG[TEST_IMAGE_PATH]=$openjdk_test_image_path
BUILD_CONFIG[DEBUG_IMAGE_PATH]=$openjdk_debug_image_path
}
# Set the repository to build from, defaults to AdoptOpenJDK if not set by the user
# shellcheck disable=SC2153
setRepository() {
local suffix
# Location of Extensions for OpenJ9 project
if [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_OPENJ9}" ]]; then
suffix="ibmruntimes/openj9-openjdk-${BUILD_CONFIG[OPENJDK_CORE_VERSION]}"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_SAP}" ]]; then
# TODO need to map versions to SAP branches going forwards
# sapmachine10 is the current branch for OpenJDK10 mainline
# (equivalent to jdk/jdk10 on hotspot)
suffix="SAP/SapMachine"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_CORRETTO}" ]]; then
suffix="corretto/corretto-${BUILD_CONFIG[OPENJDK_CORE_VERSION]:3}"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_DRAGONWELL}" ]]; then
suffix="alibaba/dragonwell${BUILD_CONFIG[OPENJDK_CORE_VERSION]/jdk/}"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_FAST_STARTUP}" ]]; then
suffix="adoptium/jdk11u-fast-startup-incubator"
elif [[ "${BUILD_CONFIG[BUILD_VARIANT]}" == "${BUILD_VARIANT_BISHENG}" ]]; then
suffix="feilongjiang/bishengjdk-11-mirror"
elif [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "armv7l" ]; then
suffix="adoptopenjdk/openjdk-aarch32-jdk8u";
elif [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && [ "${BUILD_CONFIG[OS_ARCHITECTURE]}" == "aarch64" ]; then
suffix="adoptopenjdk/openjdk-aarch64-jdk8u";
else
suffix="adoptopenjdk/openjdk-${BUILD_CONFIG[OPENJDK_FOREST_NAME]}"
fi
local repository
if [[ "${BUILD_CONFIG[USE_SSH]}" == "true" ]]; then
repository="git@github.com:${suffix}"
else
repository="https://github.com/${suffix}"
fi
repository="$(echo "${repository}" | awk '{print tolower($0)}')"
BUILD_CONFIG[REPOSITORY]="${BUILD_CONFIG[REPOSITORY]:-${repository}}"
}
# Specific architectures need to have special build settings
# shellcheck disable=SC2153
processArgumentsforSpecificArchitectures() {
local jvm_variant=server
local build_full_name=""
local make_args_for_any_platform=""
case "${BUILD_CONFIG[OS_ARCHITECTURE]}" in
"s390x")
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && [ "${BUILD_CONFIG[BUILD_VARIANT]}" != "${BUILD_VARIANT_OPENJ9}" ]; then
jvm_variant=zero
else
jvm_variant=server
fi
if [ "${BUILD_CONFIG[OPENJDK_FEATURE_NUMBER]}" -ge 12 ]; then
build_full_name=linux-s390x-${jvm_variant}-release
else
build_full_name=linux-s390x-normal-${jvm_variant}-release
fi
# This is to ensure consistency with the defaults defined in setMakeArgs()
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" != "${JDK8_CORE_VERSION}" ]; then
make_args_for_any_platform="CONF=${build_full_name} DEBUG_BINARIES=true product-images legacy-jre-image"
else
make_args_for_any_platform="CONF=${build_full_name} DEBUG_BINARIES=true images"
fi
;;
"ppc64le")
jvm_variant=server
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK12_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK13_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK14_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK15_CORE_VERSION}" ] ||
[ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDKHEAD_CORE_VERSION}" ]; then
build_full_name=linux-ppc64-${jvm_variant}-release
else
build_full_name=linux-ppc64-normal-${jvm_variant}-release
fi
if [ "$(command -v rpm)" ]; then
# shellcheck disable=SC1083
BUILD_CONFIG[FREETYPE_FONT_BUILD_TYPE_PARAM]=${BUILD_CONFIG[FREETYPE_FONT_BUILD_TYPE_PARAM]:="--build=$(rpm --eval %{_host})"}
fi
;;
"armv7l")
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ] && isHotSpot; then
jvm_variant=client
make_args_for_any_platform="DEBUG_BINARIES=true images"
else
jvm_variant=server,client
make_args_for_any_platform="DEBUG_BINARIES=true images legacy-jre-image"
fi
if [[ ${BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS]:-""} != *"--with-jobs"* ]]; then
BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS]="--with-jobs=${BUILD_CONFIG[NUM_PROCESSORS]} ${BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS:-''}"
fi
;;
esac
BUILD_CONFIG[JVM_VARIANT]=${BUILD_CONFIG[JVM_VARIANT]:-$jvm_variant}
BUILD_CONFIG[BUILD_FULL_NAME]=${BUILD_CONFIG[BUILD_FULL_NAME]:-$build_full_name}
BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]=${BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]:-$make_args_for_any_platform}
BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS]=${BUILD_CONFIG[USER_SUPPLIED_CONFIGURE_ARGS]:-""}
}
# Different platforms have different default make commands
# shellcheck disable=SC2153
setMakeCommandForOS() {
local make_command_name
case "$OS_KERNEL_NAME" in
"aix")
make_command_name="gmake"
;;
"sunos")
make_command_name="gmake"
;;
esac
BUILD_CONFIG[MAKE_COMMAND_NAME]=${BUILD_CONFIG[MAKE_COMMAND_NAME]:-$make_command_name}
}
function configureMacFreeFont() {
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK9_CORE_VERSION}" ] || [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" == "${JDK8_CORE_VERSION}" ]; then
BUILD_CONFIG[COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG]="true"
BUILD_CONFIG[COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG]="true"
fi
echo "[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG=${BUILD_CONFIG[COPY_MACOSX_FREE_FONT_LIB_FOR_JDK_FLAG]}"
echo "[debug] COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG=${BUILD_CONFIG[COPY_MACOSX_FREE_FONT_LIB_FOR_JRE_FLAG]}"
}
function setMakeArgs() {
echo "JDK Image folder name: ${BUILD_CONFIG[JDK_PATH]}"
echo "JRE Image folder name: ${BUILD_CONFIG[JRE_PATH]}"
if [ "${BUILD_CONFIG[OPENJDK_CORE_VERSION]}" != "${JDK8_CORE_VERSION}" ]; then
case "${BUILD_CONFIG[OS_KERNEL_NAME]}" in
"darwin") BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]=${BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]:-"product-images mac-legacy-jre-bundle"} ;;
*) BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]=${BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]:-"product-images legacy-jre-image"} ;;
esac
# In order to build an exploded image, no other make targets can be used
if [ "${BUILD_CONFIG[MAKE_EXPLODED]}" == "true" ]; then
BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]=""
fi
else
BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]=${BUILD_CONFIG[MAKE_ARGS_FOR_ANY_PLATFORM]:-"images"}
fi
}
################################################################################
configure_build() {
configDefaults
# Parse the CL Args, see ${SCRIPT_DIR}/configureBuild.sh for details
parseCommandLineArgs "$@"
# Update the configuration with the arguments passed in, the platform etc
setVariablesForConfigure
setRepository
processArgumentsforSpecificArchitectures
setMakeCommandForOS
determineBuildProperties
sourceSignalHandler
doAnyBuildVariantOverrides
setWorkingDirectory
configureMacFreeFont
setMakeArgs
setBootJdk
}