-
Notifications
You must be signed in to change notification settings - Fork 4
/
build17.sh
executable file
·330 lines (277 loc) · 6.58 KB
/
build17.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
322
323
324
325
326
327
328
329
#!/bin/bash
# define JDK and repo
JDK_VER=17u
JDK_BASE=jdk$JDK_VER-dev
#JDK_TAG=
# set true to build Shanendoah, false for normal build
BUILD_SHENANDOAH=true
# set true to build javaFX, false for no javaFX
BUILD_JAVAFX=false
INCLUDE_JAVAFX=$BUILD_JAVAFX
## release, fastdebug, slowdebug
DEBUG_LEVEL=fastdebug
RUN_UNDER_ROSETTA=false
CONFIGURE_JDK=true
CLEAN_JDK=false
BUILD_JDK=true
TEST_JDK=false
# NOTE: always true - downloading tools also adds them to the path
DOWNLOAD_TOOLS=true
CLEAN_TOOLS=false
usage()
{
script=`basename $0`
echo "usage : $script [ aarch64 | x86_64 ]"
exit 1
}
if [ $# -gt 1 ]; then
usage
fi
if [ $# -gt 0 ] ; then
if [ $1 == "x86_64" ] ; then
echo "build target x86_64"
export BUILD_TARGET_ARCH=x86_64
elif [ $1 == "aarch64" ] ; then
echo "build target aarch64"
export BUILD_TARGET_ARCH=aarch64
else
usage
fi
fi
# aarch64 or x86_64
if [ .$BUILD_TARGET_ARCH == . ] ; then
# default to build system architecture
if [ "`uname -m`" = "arm64" ] ; then
echo "defaulting to build aarch64"
export BUILD_TARGET_ARCH=aarch64
else
echo "defaulting to build x86_64"
export BUILD_TARGET_ARCH=x86_64
fi
fi
RUN_UNDER_ROSETTA=false
if [ "`uname -m`" = "arm64" ] ; then
if [ "$BUILD_TARGET_ARCH" = "x86_64" ] ; then
RUN_UNDER_ROSETTA=true
fi
fi
# if we're on a macos arm64 machine, we can run in x86_64 or native aarch64/arm64 mode.
if $RUN_UNDER_ROSETTA ; then
if [ "`uname`" = "Darwin" ] ; then
if [ "`uname -m`" = "arm64" ] ; then
echo "building on aarch64 - restarting in x86_64 mode"
arch -x86_64 "$0" $BUILD_TARGET_ARCH
exit $?
fi
fi
fi
if [ .$BUILD_TARGET_ARCH == .aarch64 ] ; then
TARGET_ARGS="--host=aarch64-apple-darwin"
fi
### no need to change anything below this line unless something went wrong
set -e
# define build environment
BUILD_DIR=`pwd`
pushd `dirname $0`
SCRIPT_DIR=`pwd`
PATCH_DIR="$SCRIPT_DIR/jdk$JDK_VER-patch"
TOOL_DIR="$BUILD_DIR/tools"
popd
JDK_DIR="$BUILD_DIR/$JDK_BASE"
JDK_CONF=macos-$BUILD_TARGET_ARCH-server-$DEBUG_LEVEL
JDK_REPO=https://github.com/openjdk/$JDK_BASE
if $BUILD_JAVAFX ; then
JAVAFX_VER=17u
JAVAFX_REPO=https://github.com/openjdk/jfx$JAVAFX_VER.git
JAVAFX_BUILD_DIR="$BUILD_DIR/jfx$JAVAFX_VER"
fi
### JDK
clone_jdk() {
progress "cloning jdk repo"
if ! test -d "$JDK_DIR" ; then
git clone $JDK_REPO "$JDK_DIR"
else
pushd "$JDK_DIR"
git pull
popd
fi
if [ "x$JDK_TAG" != "x" ] ; then
pushd "$JDK_DIR"
git checkout "$JDK_TAG"
popd
fi
}
patch_jdk() {
progress "patching jdk repo"
if test -f "$PATCH_DIR/mac-jdk$JDK_VER.patch" ; then
pushd "$JDK_DIR"
git apply "$PATCH_DIR/mac-jdk$JDK_VER.patch"
popd
fi
}
configure_jdk() {
progress "configuring jdk build"
pushd "$JDK_DIR"
if $INCLUDE_JAVAFX ; then
CONFIG_ARGS=--with-import-modules=$JAVAFX_BUILD_DIR/build/modular-sdk
fi
if $BUILD_SHENANDOAH ; then
CONFIG_ARGS="$CONFIG_ARGS --enable-jvm-feature-shenandoahgc"
fi
# --with-jtreg="$TOOL_DIR/jtreg"
chmod 755 ./configure
./configure --with-toolchain-type=clang \
--includedir=$XCODE_DEVELOPER_PREFIX/Toolchains/XcodeDefault.xctoolchain/usr/include \
--with-debug-level=$DEBUG_LEVEL \
--with-conf-name=$JDK_CONF \
--disable-warnings-as-errors \
--with-boot-jdk=$JAVA_HOME $CONFIG_ARGS $TARGET_ARGS
popd
}
clean_jdk() {
progress "cleaning jdk repo"
rm -fr "$JDK_DIR/build"
find "$JDK_DIR" -name \*.rej -exec rm {} \; 2>/dev/null || true
find "$JDK_DIR" -name \*.orig -exec rm {} \; 2>/dev/null || true
}
revert_jdk() {
progress "reverting jdk repo"
pushd "$JDK_DIR"
git restore .
popd
}
build_jdk() {
progress "building jdk"
pushd "$JDK_DIR"
#IMAGES="bootcycle-images"
IMAGES="images"
#MAKELOGLEVEL=LOG=debug
make $IMAGES CONF=$JDK_CONF $MAKELOGLEVEL
popd
}
test_jdk() {
TESTS=$*
JDK_HOME="$JDK_DIR/build/$JDK_CONF/images/jdk"
JT_WORK="$BUILD_DIR/jtreg"
pushd "$JDK_DIR"
jtreg -w "$JT_WORK/work" -r "$JT_WORK/report" -jdk:$JDK_HOME $TESTS
popd
}
test_tier1() {
TESTS=$*
JDK_HOME="$JDK_DIR/build/$JDK_CONF/images/jdk"
pushd "$JDK_DIR"
# make run-test-tier1
make run-test TEST="jtreg:test/hotspot:tier1"
popd
}
test_gtest() {
TESTS=$*
JDK_HOME="$JDK_DIR/build/$JDK_CONF/images/jdk"
pushd "$JDK_DIR"
make test-hotspot-gtest
popd
}
#### Java FX
clone_javafx() {
if [ ! -d $JAVAFX_BUILD_DIR ] ; then
progress "cloning javafx repo"
cd `dirname $JAVAFX_BUILD_DIR`
git clone $JAVAFX_REPO "$JAVAFX_BUILD_DIR"
fi
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
}
patch_javafx() {
progress "patch javafx repo"
pushd "$JAVAFX_BUILD_DIR"
if [ -f "$SCRIPT_DIR/javafx11.patch" ] ; then
git apply "$SCRIPT_DIR/javafx11.patch"
fi
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
popd
}
revert_javafx() {
progress "revert javafx repo"
pushd "$JAVAFX_BUILD_DIR"
git restore .
popd
}
test_javafx() {
progress "test javafx"
cd "$JAVAFX_BUILD_DIR"
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
./gradlew --info cleanTest :base:test
}
build_javafx() {
progress "build javafx"
cd "$JAVAFX_BUILD_DIR"
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
uname -m
./gradlew
}
build_javafx_demos() {
progress "build javafx demos"
cd "$JAVAFX_BUILD_DIR"
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
./gradlew :apps:build
}
clean_javafx() {
progress "cleaning javafx"
cd "$JAVAFX_BUILD_DIR"
chmod 755 "$JAVAFX_BUILD_DIR/gradlew"
./gradlew clean
rm -fr build
}
progress() {
echo $1
}
#### build the world
if $DOWNLOAD_TOOLS ; then
if $BUILD_JAVAFX ; then
JAVAFX_TOOLS="ant cmake mvn"
else
unset JAVAFX_TOOLS
fi
. "$SCRIPT_DIR/tools.sh" "$TOOL_DIR" autoconf bootstrap_jdk17 jtreg $JAVAFX_TOOLS
fi
set -x
# build JavaFX using boot JDK
if $BUILD_JAVAFX ; then
# export JDK_HOME=$JDK_IMAGE_DIR
# export PATH=$JDK_HOME/bin:$PATH
clone_javafx
revert_javafx
patch_javafx
clean_javafx
time build_javafx
#test_javafx
build_javafx_demos
fi
if $BUILD_JDK ; then
clone_jdk
clean_jdk
#revert_jdk
#patch_jdk
configure_jdk
time build_jdk
fi
if $TEST_JDK ; then
test_gtest test/hotspot/gtest/classfile/test_symbolTable.cpp
test_jdk jdk/java/net/httpclient/ByteArrayPublishers.java
test_tier1
fi
JDK_IMAGE_DIR="$JDK_DIR/build/$JDK_CONF/images/jdk"
if $BUILD_JAVAFX ; then
WITH_JAVAFX_STR=-javafx
fi
if $BUILD_SHENANDOAH ; then
WITH_SHENANDOAH_STR=-shenandoah
fi
# create distribution zip
pushd "$JDK_IMAGE_DIR/.."
IMAGE_DIR=$JDK_BASE-${BUILD_TARGET_ARCH}${WITH_JAVAFX_STR}${WITH_SHENANDOAH_STR}
mv "$JDK_IMAGE_DIR" $IMAGE_DIR
zip -r "$BUILD_DIR/$IMAGE_DIR.zip" $IMAGE_DIR
zip "$BUILD_DIR/$IMAGE_DIR-debug.zip" `find . | grep -v \*\.dSYM`
mv $IMAGE_DIR "$JDK_IMAGE_DIR"
popd