forked from stooke/macos-build-openjdk8u
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools.sh
executable file
·366 lines (330 loc) · 8.77 KB
/
tools.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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
#!/bin/bash
# usage: . ./tools.sh tooldir [tool]...
OLDPATH="$PATH"
set_os() {
IS_LINUX=false
if [ "`uname`" = "Linux" ] ; then
IS_LINUX=true
fi
IS_DARWIN=false
if [ "`uname`" = "Darwin" ] ; then
IS_DARWIN=true
fi
}
# define toolchain
find_xcode() {
XCODE_APP=`dirname \`dirname \\\`xcode-select -p \\\`\``
XCODE_VERSION=`/usr/bin/xcodebuild -version | sed -En 's/Xcode[[:space:]]+([0-9\.]*)/\1/p' | sed s/[.][0-9]*//`
XCODE_DEVELOPER_PREFIX=$XCODE_APP/Contents/Developer
CCTOOLCHAIN_PREFIX=$XCODE_APP/Contents/Developer/Toolchains/XcodeDefault.xctoolchain
OLDPATH=$PATH
export PATH=$CCTOOLCHAIN_PREFIX/usr/bin:$PATH
export PATH=$TOOL_PREFIX/usr/bin:$PATH
echo Using xcode version $XCODE_VERSION installed in $XCODE_APP
}
set_os
if $IS_DARWIN ; then
find_xcode
fi
# define build environment
TOOL_DIR="$1"
if test ".$TOOL_DIR" = "." ; then
TOOL_DIR="`pwd`/tools"
fi
if test ".$DOWNLOAD_DIR" = "." ; then
DOWNLOAD_DIR="$TOOL_DIR/downloads"
fi
if test ".$TOOL_INSTALL_ROOT" = "." ; then
TOOL_INSTALL_ROOT="$TOOL_DIR/local"
fi
if test ".$TMP" = "." ; then
TMP=/tmp
fi
if test ".$TMP_DIR" = "." ; then
TMP_DIR="$TMP/$$.work"
fi
download_and_open() {
URL="$1"
FILE="$DOWNLOAD_DIR/`basename $URL`"
DEST="$2"
if ! test -f "$FILE" ; then
echo "downloading $1"
pushd "$DOWNLOAD_DIR"
curl -O -L --insecure "$URL"
popd
fi
if test -d "$DEST" ; then
return
fi
rm -fr "$TMP_DIR/dno"
mkdir -p "$TMP_DIR/dno"
pushd "$TMP_DIR/dno"
tar -xvf "$FILE"
mv * "$DEST"
popd
rm -fr "$TMP_DIR/dno"
}
clone_or_update() {
URL="$1"
DEST="$2"
if ! test -d "$DEST" ; then
echo "cloning $1"
git clone "$URL" "$DEST"
else
pushd "$DEST"
git pull
popd
fi
}
check_arch() {
FILE="$1"
ARCH="$2"
set +e
if [[ "`file \"$FILE\"`" != *"$ARCH"* ]] ; then
echo "$FILE is not built for $ARCH"
set -e
return 1
fi
set -e
return 0
}
build_ant() {
download_and_open https://mirror.dsrg.utoronto.ca/apache/ant/binaries/apache-ant-1.10.9-bin.tar.gz "$TOOL_DIR/ant"
}
build_autoconf() {
if test -d "$TOOL_DIR/autoconf" ; then
return
fi
download_and_open http://ftpmirror.gnu.org/autoconf/autoconf-2.69.tar.gz "$TOOL_DIR/autoconf"
pushd "$TOOL_DIR/autoconf"
./configure --prefix=$TOOL_INSTALL_ROOT
make install
popd
}
build_automake() {
if test -d "$TOOL_DIR/automake" ; then
return
fi
download_and_open http://ftp.gnu.org/gnu/automake/automake-1.16.tar.gz "$TOOL_DIR/automake"
pushd "$TOOL_DIR/automake"
OLDPATH="$PATH"
PATH="$TOOL_INSTALL_ROOT/bin:$PATH"
./configure --prefix=$TOOL_INSTALL_ROOT
make install
PATH="$OLDPATH"
popd
}
build_bison() {
echo bison is already in macOS
}
build_cmake() {
if $IS_DARWIN ; then
if test -d "$TOOL_DIR/cmake" ; then
return
fi
download_and_open https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3-Darwin-x86_64.tar.gz "$TOOL_DIR/cmake"
fi
}
build_libtool() {
echo libtool is already in macOS
}
build_mvn() {
if test -d "$TOOL_DIR/apache-maven"; then
return
fi
download_and_open https://mirror.dsrg.utoronto.ca/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz "$TOOL_DIR/apache-maven"
}
build_mx() {
clone_or_update https://github.com/graalvm/mx.git "$TOOL_DIR/mx"
}
build_ninja() {
clone_or_update https://github.com/ninja-build/ninja.git "$TOOL_DIR/ninja" && cd ninja
git checkout release
#cat README
}
build_freetype() {
if check_arch "$TOOL_DIR/freetype/objs/.libs/libfreetype.6.dylib" $BUILD_TARGET_ARCH ; then
return 0
fi
download_and_open https://nongnu.freemirror.org/nongnu/freetype/freetype-2.9.tar.gz "$TOOL_DIR/freetype"
pushd "$TOOL_DIR/freetype"
./configure
make clean
make
if $IS_DARWIN ; then
set -x
cd objs/.libs
otool -L libfreetype.6.dylib
install_name_tool -change /usr/local/lib/libfreetype.6.dylib @rpath/libfreetype.6.dylib libfreetype.6.dylib
otool -L libfreetype.6.dylib
set +x
fi
popd
}
build_mercurial() {
if test -f "$TOOL_DIR/mercurial/hg" ; then
return
fi
download_and_open https://www.mercurial-scm.org/release/mercurial-5.3.tar.gz "$TOOL_DIR/mercurial"
pushd "$TOOL_DIR/mercurial"
make local
popd
}
build_re2c() {
clone_or_update https://github.com/skvadrik/re2c.git "$TOOL_DIR/re2c"
cd "$TOOL_DIR/re2c"
./autogen.sh
mkdir builddir && cd builddir
../configure --prefix=$TOOL_INSTALL_ROOT
make
make install
}
build_bootstrap_jdk8() {
if $IS_DARWIN ; then
if test -d "$TOOL_DIR/jdk8u" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u265-b01/OpenJDK8U-jdk_x64_mac_hotspot_8u265b01.tar.gz "$TOOL_DIR/jdk8u"
fi
}
build_bootstrap_jdk10() {
if $IS_DARWIN ; then
if test -d "$TOOL_DIR/jdk10u" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jdk_x64_mac_hotspot_8u202b08.tar.gz "$TOOL_DIR/jdk10u"
fi
}
build_bootstrap_jdk11() {
if $IS_DARWIN ; then
if test -d "$TOOL_DIR/jdk11u" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.2%2B9/OpenJDK11U-jdk_x64_mac_hotspot_11.0.2_9.tar.gz "$TOOL_DIR/jdk11u"
fi
}
build_bootstrap_jdk12() {
if $IS_DARWIN ; then
if test -d "$TOOL_DIR/jdk12u" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk12-binaries/releases/download/jdk-12%2B33/OpenJDK12U-jdk_x64_mac_hotspot_12_33.tar.gz "$TOOL_DIR/jdk12u"
fi
}
build_bootstrap_jdk13() {
if test -d "$TOOL_DIR/jdk13u" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk13-binaries/releases/download/jdk13u-2019-12-03-14-28/OpenJDK13U-jdk_x64_mac_hotspot_2019-12-03-14-28.tar.gz "$TOOL_DIR/jdk13u"
}
build_bootstrap_jdk15() {
if test -d "$TOOL_DIR/jdk15" ; then
return
fi
download_and_open https://github.com/AdoptOpenJDK/openjdk15-binaries/releases/download/jdk-15.0.2%2B7/OpenJDK15U-jdk_x64_mac_hotspot_15.0.2_7.tar.gz "$TOOL_DIR/jdk15"
}
build_bootstrap_jdk_latest() {
if test -d "$TOOL_DIR/jdk-latest" ; then
return
fi
download_and_open ???? "$TOOL_DIR/jdk-latest"
}
build_make() {
# make is already in macos, but kind of old
if test -d "$TOOL_DIR/make-4.2.1" ; then
return
fi
download_and_open "https://ftp.gnu.org/gnu/make/make-4.2.1.tar.gz" "$TOOL_DIR/make-4.2.1"
pushd "$TOOL_DIR/make-4.2.1"
mkdir -p "builddir" && cd "builddir"
../configure --prefix=$TOOL_INSTALL_ROOT
make all
make check
make install
popd
}
build_webrev() {
if test -f "$TOOL_DIR/webrev/webrev.ksh" ; then
return
fi
pushd "$TOOL_DIR"
mkdir -p "$TOOL_DIR/webrev"
cd "$TOOL_DIR/webrev"
curl -O -L https://hg.openjdk.java.net/code-tools/webrev/raw-file/tip/webrev.ksh
chmod 755 webrev.ksh
popd
}
build_jtreg() {
JTREG_URL=https://ci.adoptopenjdk.net/view/Dependencies/job/dependency_pipeline/lastSuccessfulBuild/artifact/jtreg/jtreg-6.1+1.tar.gz
if test -d "$TOOL_DIR/jtreg" ; then
return
fi
download_and_open $JTREG_URL "$TOOL_DIR/jtreg"
}
junk_build_jtreg() {
# does not work, so just download a built jtreg for now
## requires Ant Mercurial, wget and a JDK 7 or 8
# build_ant
build_wget
cd "$TOOL_DIR"
clone_or_update http://hg.openjdk.java.net/code-tools/jtreg jtreg
cd jtreg
sh make/build-all.sh "$1"
}
buildtools() {
mkdir -p "$DOWNLOAD_DIR"
mkdir -p "$TOOL_DIR"
for tool in $* ; do
echo "building $tool"
build_$tool
if $IS_DARWIN ; then
if test $tool == "bootstrap_jdk8" ; then
export JAVA_HOME=$TOOL_DIR/jdk8u/Contents/Home
fi
if test $tool = "bootstrap_jdk9" ; then
export JAVA_HOME=$TOOL_DIR/jdk9u/Contents/Home
fi
if test $tool = "bootstrap_jdk10" ; then
export JAVA_HOME=$TOOL_DIR/jdk10u/Contents/Home
fi
if test $tool = "bootstrap_jdk11" ; then
export JAVA_HOME=$TOOL_DIR/jdk11u/Contents/Home
fi
if test $tool = "bootstrap_jdk12" ; then
export JAVA_HOME=$TOOL_DIR/jdk12u/Contents/Home
fi
if test $tool = "bootstrap_jdk13" ; then
export JAVA_HOME=$TOOL_DIR/jdk13u/Contents/Home
fi
if test $tool = "bootstrap_jdk15" ; then
export JAVA_HOME=$TOOL_DIR/jdk15/Contents/Home
fi
if test $tool = "bootstrap_jdk_latest" ; then
export JAVA_HOME=$TOOL_DIR/jdk-latest/Contents/Home
fi
fi
done
}
build_tool_path() {
export PATH=$OLDPATH
export PATH=$TOOL_DIR/ant/bin:$PATH
export PATH=$TOOL_DIR/apache-maven/bin:$PATH
if $IS_DARWIN ; then
export PATH=$TOOL_DIR/cmake/CMake.app/Contents/bin:$PATH
else
export PATH=$TOOL_DIR/cmake/CMake.app/bin:$PATH
fi
export PATH=$TOOL_DIR/jtreg/bin:$PATH
export PATH=$TOOL_DIR/mercurial:$PATH
export PATH=$TOOL_DIR/mx:$PATH
export PATH=$TOOL_DIR/ninja:$PATH
export PATH=$TOOL_DIR/re2c/builddir/dist/bin:$PATH
export PATH=$TOOL_DIR/webrev:$PATH
export PATH=$JAVA_HOME/bin:$PATH
export PATH=$TOOL_INSTALL_ROOT/bin:$PATH
}
mkdir -p "$TMP_DIR"
shift
buildtools $*
build_tool_path
rm -fr "$TMP_DIR"