forked from adoptium/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildJDKWin.sh
executable file
·134 lines (120 loc) · 3.71 KB
/
buildJDKWin.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
#!/bin/bash
set -eu
setJDKVars() {
wget -q https://api.adoptopenjdk.net/v3/info/available_releases
JDK_MAX=$(awk -F: '/tip_version/{print$2}' < available_releases | tr -d ,)
JDK_GA=$(awk -F: '/most_recent_feature_release/{print$2}' < available_releases | tr -d ,)
rm available_releases
}
processArgs() {
while [[ $# -gt 0 ]] && [[ ."$1" = .-* ]] ; do
local opt="$1";
shift;
case "$opt" in
"--version" | "-v" )
if [ $1 == "jdk" ]; then
JAVA_TO_BUILD=$JDK_MAX
else
JAVA_TO_BUILD=$(echo $1 | tr -d [:alpha:])
fi
checkJDK
shift;;
"--fork" | "-f" )
GIT_FORK="$1"; shift;;
"--branch" | "-b" )
GIT_BRANCH="$1"; shift;;
"--hotspot" | "-hs" )
export VARIANT=hotspot;;
"--clean-workspace" | "-c" )
CLEAN_WORKSPACE=true;;
"--help" | "-h" )
usage; exit 0;;
*) echo >&2 "Invalid option: ${opt}"; echo "This option was unrecognised."; usage; exit 1;;
esac
done
if [ -z "$JAVA_TO_BUILD:-}" ]; then
echo "You must use the '-v' option"
exit 1
fi
if [ -z "${WORKSPACE:-}" ]; then
echo "WORKSPACE not found, setting it to /tmp"
WORKSPACE=/tmp/
fi
if [ $CLEAN_WORKSPACE == true ]; then
echo "Cleaning workspace"
rm -rf $WORKSPACE/openjdk-build
fi
}
usage() {
echo "Usage: ./buildJDK.sh <options> (-v <JDK>)
Options:
--version | -v <JDK> Specify the JDK version to build
--fork | -f Specify the fork of openjdk-build to build from (Default: adoptopenjdk)
--branch | -b Specify the branch of the fork to build from (Default: master)
--hotspot | -hs Builds hotspot, instead of openj9 (Default: openj9)
--clean-workspace | -c Removes old openjdk-build folder before cloning
--help | -h Shows this message
If not specified, JDK8-J9 will be built with the standard openjdk-build repo"
echo
}
checkJDK() {
if ! ((JAVA_TO_BUILD >= 8 && JAVA_TO_BUILD <= JDK_MAX)); then
echo "Please input a JDK between 8 & ${JDK_MAX}, or 'jdk'"
echo "i.e. The following formats will work for jdk8: 'jdk8u', 'jdk8' , '8'"
exit 1
fi
if ((JAVA_TO_BUILD == 8)); then
export JAVA_TO_BUILD="jdk8u"
elif ((JAVA_TO_BUILD > JDK_GA)); then
export JDK_BOOT_DIR=/cygdrive/c/openjdk/jdk-${JDK_GA}
if ((JAVA_TO_BUILD == JDK_MAX)); then
export JAVA_TO_BUILD="jdk"
else
export JAVA_TO_BUILD="jdk${JAVA_TO_BUILD}"
fi
else
export JAVA_TO_BUILD="jdk${JAVA_TO_BUILD}u"
fi
}
cloneRepo() {
if [ -d $WORKSPACE/openjdk-build ]; then
echo "Found existing openjdk-build folder"
cd $WORKSPACE/openjdk-build && git pull
else
echo "Cloning new openjdk-build directory"
local isRepoTemurin=$(curl https://api.github.com/repos/$GIT_FORK/temurin-build | grep "Not Found")
local isRepoOpenjdk=$(curl https://api.github.com/repos/$GIT_FORK/openjdk-build | grep "Not Found")
if [[ -z "$isRepoTemurin" ]]; then
GIT_REPO="https://github.com/${GIT_FORK}/temurin-build"
elif [[ -z "$isRepoOpenjdk" ]]; then
GIT_REPO="https://github.com/${GIT_FORK}/openjdk-build"
else
echo "Repository not found - the fork must be named temurin-build or openjdk-build"
exit 1
fi
git clone -b ${GIT_BRANCH} --single-branch $GIT_REPO $WORKSPACE/openjdk-build
fi
}
# Set defaults
export JAVA_HOME=/cygdrive/c/openjdk/jdk-8
GIT_FORK=adoptopenjdk
GIT_BRANCH=master
CLEAN_WORKSPACE=false
JDK_GA=
JDK_MAX=
setJDKVars
processArgs $*
cloneRepo
echo "buildJDKWin.sh DEBUG:
TARGET_OS=${TARGET_OS:-}
ARCHITECTURE=${ARCHITECTURE:-}
JAVA_TO_BUILD=${JAVA_TO_BUILD:-}
VARIANT=${VARIANT:-}
JDK_BOOT_DIR=${JDK_BOOT_DIR:-}
JAVA_HOME=${JAVA_HOME:-}
WORKSPACE=${WORKSPACE:-}
FORK=${GIT_FORK:-}
BRANCH=${GIT_BRANCH:-}
FILENAME=${FILENAME:-}"
echo "Running $WORKSPACE/openjdk-build/build-farm/make-adopt-build-farm.sh"
$WORKSPACE/openjdk-build/build-farm/make-adopt-build-farm.sh