forked from acidanthera/OpenCorePkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
macbuild.tool
executable file
·202 lines (175 loc) · 5.87 KB
/
macbuild.tool
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
#!/bin/bash
unset WORKSPACE
unset PACKAGES_PATH
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 Include/OpenCore.h | grep OPEN_CORE_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/ACPI || exit 1
mkdir -p tmp/EFI/OC/Drivers || exit 1
mkdir -p tmp/EFI/OC/Kexts || exit 1
mkdir -p tmp/EFI/OC/Tools || exit 1
mkdir -p tmp/EFI/BOOT || exit 1
mkdir -p tmp/Docs/AcpiSamples || exit 1
mkdir -p tmp/Utilities || exit 1
cp OpenCore.efi tmp/EFI/OC/ || exit 1
cp BOOTx64.efi tmp/EFI/BOOT/ || exit 1
cp "${selfdir}/Docs/Configuration.pdf" tmp/Docs/ || exit 1
cp "${selfdir}/Docs/Differences/Differences.pdf" tmp/Docs/ || exit 1
cp "${selfdir}/Docs/Sample.plist" tmp/Docs/ || exit 1
cp "${selfdir}/Docs/SampleFull.plist" tmp/Docs/ || exit 1
cp "${selfdir}/Changelog.md" tmp/Docs/ || exit 1
cp -r "${selfdir}/Docs/AcpiSamples/" tmp/Docs/AcpiSamples/ || exit 1
cp -r "${selfdir}/UDK/OcSupportPkg/Utilities/BootInstall" tmp/Utilities/ || exit 1
cp -r "${selfdir}/UDK/OcSupportPkg/Utilities/CreateVault" tmp/Utilities/ || exit 1
cp -r "${selfdir}/UDK/OcSupportPkg/Utilities/LogoutHook" tmp/Utilities/ || exit 1
pushd tmp || exit 1
zip -qry -FS ../"OpenCore-${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/"
prompt "Install last tested version automatically?"
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
if [ "$(which mtoc.NEW)" == "" ] || [ "$(which mtoc)" == "" ]; then
echo "Missing mtoc or mtoc.NEW!"
echo "To build mtoc follow: https://github.com/tianocore/tianocore.github.io/wiki/Xcode#mac-os-x-xcode"
prompt "Install prebuilt mtoc and mtoc.NEW automatically?"
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
unzip -q mtoc-mac64.zip mtoc || exit 1
sudo mkdir -p /usr/local/bin || exit 1
sudo cp mtoc /usr/local/bin/mtoc || exit 1
sudo mv mtoc /usr/local/bin/mtoc.NEW || exit 1
popd >/dev/null
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" UDK master || exit 1
cd UDK
updaterepo "https://github.com/acidanthera/EfiPkg" EfiPkg master || exit 1
updaterepo "https://github.com/acidanthera/OcSupportPkg" OcSupportPkg master || exit 1
updaterepo "https://github.com/acidanthera/MacInfoPkg" MacInfoPkg master || exit 1
if [ ! -d OpenCorePkg ]; then
ln -s .. OpenCorePkg || exit 1
fi
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
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