forked from CloverHackyColor/CloverBootloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
xbuildme
executable file
·284 lines (247 loc) · 5.58 KB
/
xbuildme
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
#!/bin/bash
# created by vector sigma on July 15 2019
# github version
# Linux users should be able to use this wrapper, although the following are needed:
# gcc (check for ./build_gcc8.sh or newer)
# python (sudo apt-get install python)
# uuid-dev (sudo apt-get install uuid-dev)
# git (sudo apt-get install git)
# $1 argument override MYTOOLCHAIN variable, in case you want GCC53 for example
cd "$(dirname $0)"
declare -r CLOVERROOT="$PWD"
declare -r MYTOOLCHAIN=${1:-GCC53}
TOOLCHAIN_DIR=${TOOLCHAIN_DIR:-$(dirname $CLOVERROOT)/opt/local}
# Functions
pathmunge() {
if [[ ! $PATH =~ (^|:)$1(:|$) ]]; then
if [[ "${2:-}" = "after" ]]; then
export PATH=$PATH:$1
else
export PATH=$1:$PATH
fi
fi
}
checkXCODE() {
echo "[CHECK XCODE]"
if [[ ! -x /usr/bin/xcodebuild ]]; then
echo "ERROR: Install Xcode Tools from Apple before using this script."
exit 1
fi
if [[ ! -d "$(xcode-select --print-path)" ]]; then
echo "ERROR: Xcode Command Line Tools not selected:"
echo " open Xcode.app and go in Preferences->Locations,"
echo " and select the Command Line Tools"
exit 1
fi
}
checkGETTEXT() {
if [[ ! -x $(which gettext) ]]; then
"${CLOVERROOT}"/buildgettext.sh
fi
}
exportPaths() {
if [[ "$(uname)" == Darwin ]]; then
pathmunge "$(xcode-select --print-path)"/usr/bin
fi
pathmunge "$TOOLCHAIN_DIR"/bin
export TOOLCHAIN_DIR=$TOOLCHAIN_DIR
export DIR_MAIN=${DIR_MAIN:-$(dirname $CLOVERROOT)}
export DIR_TOOLS=${DIR_TOOLS:-$DIR_MAIN/tools}
export DIR_DOWNLOADS=${DIR_DOWNLOADS:-$DIR_TOOLS/download}
export DIR_LOGS=${DIR_LOGS:-$DIR_TOOLS/logs}
}
checkTools() {
if [[ "$(uname)" == Darwin && $MYTOOLCHAIN != GCC* ]]; then
checkXCODE
fi
exportPaths
if [[ "$(uname)" == Darwin ]]; then
checkGETTEXT
fi
}
updateClover() {
echo "[UPDATE CLOVER]"
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch --all
git pull origin master
else
echo "Error: this is not a git repository, can't update!"
fi
}
updateResetClover() {
echo "[UPDATE RESET CLOVER]"
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch --all
git reset --hard origin/master
git pull origin master
else
echo "Error: this is not a git repository, can't update!"
fi
}
buildClover() {
checkTools
cd "${CLOVERROOT}"
if [[ -z "$WORKSPACE" ]]; then
export EDK_TOOLS_PATH="${PWD}"/BaseTools
set +u
source ./edksetup.sh BaseTools
set -u
cd "$CLOVERROOT"
WORKSPACE="${PWD}"
fi
echo "[BUILD CLOVER]"
# Run a custom build script if exist (~/src/tools/Scripts/build.sh)
# This allow the user to run ebuild.sh with own parameters
if [[ -x "${DIR_TOOLS}"/Scripts/build.sh ]]; then
echo "Running custom build script"
"${DIR_TOOLS}"/Scripts/build.sh "${CLOVERROOT}" $MYTOOLCHAIN
else
./ebuild.sh -fr -t $MYTOOLCHAIN
./ebuild.sh -fr -mc --no-usb -D NO_GRUB_DRIVERS_EMBEDDED -t $MYTOOLCHAIN
fi
# Run a post build script if exist (~/src/tools/Scripts/postbuild.sh)
if [[ -x "${DIR_TOOLS}"/Scripts/postbuild.sh ]]; then
echo "Running postbuild script"
"${DIR_TOOLS}"/Scripts/postbuild.sh "${CLOVERROOT}" $MYTOOLCHAIN
fi
}
buildCloverTest() {
checkTools
cd "${CLOVERROOT}"
if [[ -z "$WORKSPACE" ]]; then
export EDK_TOOLS_PATH="${PWD}"/BaseTools
set +u
source ./edksetup.sh BaseTools
set -u
cd "$CLOVERROOT"
WORKSPACE="${PWD}"
fi
echo "[BUILD CLOVER TEST]"
./ebuild.sh -t $MYTOOLCHAIN
}
buildPkg() {
cd "${CLOVERROOT}"/CloverPackage
echo "[BUILD PKG]"
make pkg
}
buildIso() {
cd "${CLOVERROOT}"/CloverPackage
echo "[BUILD ISO]"
make iso
}
checkStatus() {
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch origin
git status
else
echo "Error: this is not a git repository, can't get info!"
fi
}
showdiff() {
cd "${CLOVERROOT}"
if [[ -d .git ]]; then
git fetch origin
git diff
else
echo "Error: this is not a git repository, can't get info!"
fi
}
cleanBaseTools() {
cd "${CLOVERROOT}"/BaseTools
make clean
}
menu() {
echo
echo '------------------------------------------------------------------------'
cd "${CLOVERROOT}"
local lsha1="not a git repo"
if [[ -d .git ]]; then
lsha1=$(git rev-parse --short HEAD)
fi
echo "buildme, Clover v2.5k r$(cat vers.txt) (SHA: $lsha1)"
echo "TOOLCHAIN: $MYTOOLCHAIN (override example: './buildme GCC53')"
echo
PS3='Please enter your choice: '
options=( 'build Clover'
'make pkg'
'make iso'
'build all'
'test build (no autogen, no boot files)'
'status'
'update Clover'
'update Clover (reset changes)'
'show diff'
'open drivers directory'
'clean BaseTools'
'quit')
select opt in "${options[@]}"
do
case $opt in
"build Clover")
buildClover
break
;;
"make pkg")
buildPkg
break
;;
"make iso")
buildIso
break
;;
"build all")
buildClover
buildPkg
buildIso
break
;;
"test build (no autogen, no boot files)")
buildCloverTest
break
;;
"update Clover")
updateClover
break
;;
"update Clover (reset changes)")
updateResetClover
break
;;
"status")
checkStatus
break
;;
"show diff")
showdiff
break
;;
"open drivers directory")
if [[ -d "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers ]]; then
open "${CLOVERROOT}"/CloverPackage/CloverV2/EFI/CLOVER/drivers
else
echo && echo "Directory not found. Compile Clover first!!"
sleep 2
fi
break
;;
"clean BaseTools")
cleanBaseTools
break
;;
"quit")
exit 0
;;
*)
echo "invalid option $REPLY"
break
;;
esac
done
menu
}
# Main
set -e
menu