forked from n-d-k/NdkBootPicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathndk-macbuild.tool
More file actions
executable file
·227 lines (195 loc) · 6.63 KB
/
ndk-macbuild.tool
File metadata and controls
executable file
·227 lines (195 loc) · 6.63 KB
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
#!/bin/bash
BUILDDIR=$(dirname "$0")
pushd "$BUILDDIR" >/dev/null
BUILDDIR=$(pwd)
popd >/dev/null
cd "$BUILDDIR"
prompt() {
echo "$1"
if [ "$FORCE_INSTALL" != "1" ]; then
read -p "Enter [Y]es to continue: " v
if [ "$v" != "Y" ] && [ "$v" != "y" ]; then
exit 1
fi
fi
}
updaterepo() {
if [ ! -d "$2" ]; then
git clone "$1" -b "$3" --depth=1 "$2" || exit 1
fi
pushd "$2" >/dev/null
git pull
if [ "$2" != "UDK" ]; then
sym=$(find . -not -type d -exec file "{}" ";" | grep CRLF)
if [ "${sym}" != "" ]; then
echo "Repository $1 named $2 contains CRLF line endings"
exit 1
fi
fi
popd >/dev/null
}
package() {
if [ ! -d "$1" ]; then
echo "Missing package directory"
exit 1
fi
local ver=$(cat NdkBootPicker.h | grep NDK_BOOTPICKER_VERSION | sed 's/.*"\(.*\)".*/\1/' | grep -E '^[0-9.]+$')
if [ "$ver" = "" ]; then
echo "Invalid version $ver"
fi
selfdir=$(pwd)
pushd "$1" || exit 1
rm -rf tmp || exit 1
mkdir -p tmp/EFI || exit 1
mkdir -p tmp/EFI/OC || exit 1
mkdir -p tmp/EFI/OC/Icons || exit 1
mkdir -p tmp/EFI/OC/Drivers || exit 1
cp NdkBootPicker.efi tmp/EFI/OC/Drivers/ || exit 1
cp -r "${selfdir}/Themes/Default/Light/Icons/" tmp/EFI/OC/Icons/ || exit 1
pushd tmp || exit 1
zip -qry -FS ../"NdkBootPicker-${ver}-${2}.zip" * || exit 1
popd || exit 1
rm -rf tmp || exit 1
popd || exit 1
}
if [ "$BUILDDIR" != "$(printf "%s\n" $BUILDDIR)" ]; then
echo "EDK2 build system may still fail to support directories with spaces!"
exit 1
fi
if [ "$(which clang)" = "" ] || [ "$(which git)" = "" ] || [ "$(clang -v 2>&1 | grep "no developer")" != "" ] || [ "$(git -v 2>&1 | grep "no developer")" != "" ]; then
echo "Missing Xcode tools, please install them!"
exit 1
fi
if [ "$(nasm -v)" = "" ] || [ "$(nasm -v | grep Apple)" != "" ]; then
echo "Missing or incompatible nasm!"
echo "Download the latest nasm from http://www.nasm.us/pub/nasm/releasebuilds/"
pushd /tmp >/dev/null
rm -rf nasm-mac64.zip
curl -OL "https://github.com/acidanthera/ocbuild/raw/master/external/nasm-mac64.zip" || exit 1
nasmzip=$(cat nasm-mac64.zip)
rm -rf nasm-*
curl -OL "https://github.com/acidanthera/ocbuild/raw/master/external/${nasmzip}" || exit 1
unzip -q "${nasmzip}" nasm*/nasm nasm*/ndisasm || exit 1
sudo mkdir -p /usr/local/bin || exit 1
sudo mv nasm*/nasm /usr/local/bin/ || exit 1
sudo mv nasm*/ndisasm /usr/local/bin/ || exit 1
rm -rf "${nasmzip}" nasm-*
popd >/dev/null
fi
mtoc_hash=$(curl -L "https://github.com/acidanthera/ocbuild/raw/master/external/mtoc-mac64.sha256") || exit 1
if [ "${mtoc_hash}" = "" ]; then
echo "Cannot obtain the latest compatible mtoc hash!"
exit 1
fi
valid_mtoc=false
if [ "$(which mtoc)" != "" ]; then
mtoc_path=$(which mtoc)
mtoc_hash_user=$(shasum -a 256 "${mtoc_path}" | cut -d' ' -f1)
if [ "${mtoc_hash}" = "${mtoc_hash_user}" ]; then
valid_mtoc=true
elif [ "${IGNORE_MTOC_VERSION}" = "1" ]; then
echo "Forcing the use of UNKNOWN mtoc version due to IGNORE_MTOC_VERSION=1"
valid_mtoc=true
elif [ "${mtoc_path}" != "/usr/local/bin/mtoc" ]; then
echo "Custom UNKNOWN mtoc is installed to ${mtoc_path}!"
echo "Hint: Remove this mtoc or use IGNORE_MTOC_VERSION=1 at your own risk."
exit 1
else
echo "Found incompatible mtoc installed to ${mtoc_path}!"
echo "Expected SHA-256: ${mtoc_hash}"
echo "Found SHA-256: ${mtoc_hash_user}"
echo "Hint: Reinstall this mtoc or use IGNORE_MTOC_VERSION=1 at your own risk."
fi
fi
if ! $valid_mtoc; then
echo "Missing or incompatible mtoc!"
echo "To build mtoc follow: https://github.com/tianocore/tianocore.github.io/wiki/Xcode#mac-os-x-xcode"
pushd /tmp >/dev/null
rm -f mtoc mtoc-mac64.zip
curl -OL "https://github.com/acidanthera/ocbuild/raw/master/external/mtoc-mac64.zip" || exit 1
mtoczip=$(cat mtoc-mac64.zip)
rm -rf mtoc-*
curl -OL "https://github.com/acidanthera/ocbuild/raw/master/external/${mtoczip}" || exit 1
unzip -q "${mtoczip}" mtoc || exit 1
sudo mkdir -p /usr/local/bin || exit 1
sudo rm -f /usr/local/bin/mtoc /usr/local/bin/mtoc.NEW || exit 1
sudo cp mtoc /usr/local/bin/mtoc || exit 1
popd >/dev/null
mtoc_path=$(which mtoc)
mtoc_hash_user=$(shasum -a 256 "${mtoc_path}" | cut -d' ' -f1)
if [ "${mtoc_hash}" != "${mtoc_hash_user}" ]; then
echo "Failed to install a compatible version of mtoc!"
echo "Expected SHA-256: ${mtoc_hash}"
echo "Found SHA-256: ${mtoc_hash_user}"
exit 1
fi
fi
if [ ! -d "Binaries" ]; then
mkdir Binaries || exit 1
cd Binaries || exit 1
ln -s ../UDK/Build/OpenCorePkg/RELEASE_XCODE5/X64 RELEASE || exit 1
ln -s ../UDK/Build/OpenCorePkg/DEBUG_XCODE5/X64 DEBUG || exit 1
ln -s ../UDK/Build/OpenCorePkg/NOOPT_XCODE5/X64 NOOPT || exit 1
cd .. || exit 1
fi
while true; do
if [ "$1" == "--skip-tests" ]; then
SKIP_TESTS=1
shift
elif [ "$1" == "--skip-build" ]; then
SKIP_BUILD=1
shift
elif [ "$1" == "--skip-package" ]; then
SKIP_PACKAGE=1
shift
else
break
fi
done
if [ "$1" != "" ]; then
MODE="$1"
shift
fi
if [ ! -f UDK/UDK.ready ]; then
rm -rf UDK
sym=$(find . -not -type d -exec file "{}" ";" | grep CRLF)
if [ "${sym}" != "" ]; then
echo "Repository CRLF line endings"
exit 1
fi
fi
updaterepo "https://github.com/acidanthera/audk.git" UDK master || exit 1
cd UDK
updaterepo "https://github.com/acidanthera/EfiPkg" EfiPkg master || exit 1
updaterepo "https://github.com/acidanthera/MacInfoPkg" MacInfoPkg master || exit 1
updaterepo "https://github.com/acidanthera/OpenCorePkg.git" OpenCorePkg master || exit 1
if [ ! -d $(pwd)/OpenCorePkg/Application/NdkBootPicker ]; then
ln -s ../../.. OpenCorePkg/Application/NdkBootPicker || exit 1
fi
sed -i '' 's/BootKicker/NdkBootPicker/g' $(pwd)/OpenCorePkg/OpenCorePkg.dsc
source edksetup.sh || exit 1
if [ "$SKIP_TESTS" != "1" ]; then
make -C BaseTools || exit 1
touch UDK.ready
fi
if [ "$SKIP_BUILD" != "1" ]; then
if [ "$MODE" = "" ] || [ "$MODE" = "DEBUG" ]; then
build -a X64 -b DEBUG -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc || exit 1
fi
if [ "$MODE" = "" ] || [ "$MODE" = "DEBUG" ]; then
build -a X64 -b NOOPT -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc || exit 1
fi
if [ "$MODE" = "" ] || [ "$MODE" = "RELEASE" ]; then
build -a X64 -b RELEASE -t XCODE5 -p OpenCorePkg/OpenCorePkg.dsc || exit 1
fi
fi
sed -i '' 's/NdkBootPicker/BootKicker/g' $(pwd)/OpenCorePkg/OpenCorePkg.dsc
cd .. || exit 1
if [ "$SKIP_PACKAGE" != "1" ]; then
if [ "$PACKAGE" = "" ] || [ "$PACKAGE" = "DEBUG" ]; then
package "Binaries/DEBUG" "DEBUG" || exit 1
fi
if [ "$PACKAGE" = "" ] || [ "$PACKAGE" = "RELEASE" ]; then
package "Binaries/RELEASE" "RELEASE" || exit 1
fi
fi