This repository has been archived by the owner on May 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
/
macbuild.tool
executable file
·167 lines (141 loc) · 4.68 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
#!/bin/bash
BUILDDIR=$(dirname "$0")
pushd "$BUILDDIR" >/dev/null
BUILDDIR=$(pwd)
popd >/dev/null
NASMVER="2.13.03"
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
popd >/dev/null
}
package() {
if [ ! -d "$1" ]; then
echo "Missing package directory"
exit 1
fi
local ver=$(cat Include/AppleSupportPkgVersion.h | grep APPLE_SUPPORT_VERSION | cut -f4 -d' ' | cut -f2 -d'"' | grep -E '^[0-9.]+$')
if [ "$ver" = "" ]; then
echo "Invalid version $ver"
fi
pushd "$1" || exit 1
rm -rf tmp || exit 1
mkdir -p tmp/Drivers || exit 1
mkdir -p tmp/Tools || exit 1
cp ApfsDriverLoader.efi tmp/Drivers/ || exit 1
# FIXME: return this back once we fix UEFI Secure Boot compatible Apple image loading.
# cp AppleImageLoader.efi tmp/Drivers/ || exit 1
cp AppleUiSupport.efi tmp/Drivers/ || exit 1
cp UsbKbDxe.efi tmp/Drivers/ || exit 1
pushd tmp || exit 1
zip -qry ../"AppleSupport-v${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 "Last tested with nasm $NASMVER. Install it automatically?"
pushd /tmp >/dev/null
rm -rf "nasm-${NASMVER}-macosx.zip" "nasm-${NASMVER}"
curl -OL "http://www.nasm.us/pub/nasm/releasebuilds/${NASMVER}/macosx/nasm-${NASMVER}-macosx.zip" || exit 1
unzip -q "nasm-${NASMVER}-macosx.zip" "nasm-${NASMVER}/nasm" "nasm-${NASMVER}/ndisasm" || exit 1
sudo mkdir -p /usr/local/bin || exit 1
sudo mv "nasm-${NASMVER}/nasm" /usr/local/bin/ || exit 1
sudo mv "nasm-${NASMVER}/ndisasm" /usr/local/bin/ || exit 1
rm -rf "nasm-${NASMVER}-macosx.zip" "nasm-${NASMVER}"
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?"
rm -f mtoc mtoc.NEW
unzip -q external/mtoc-mac64.zip mtoc.NEW || exit 1
sudo mkdir -p /usr/local/bin || exit 1
sudo cp mtoc.NEW /usr/local/bin/mtoc || exit 1
sudo mv mtoc.NEW /usr/local/bin/ || exit 1
fi
if [ ! -d "Binaries" ]; then
mkdir Binaries || exit 1
cd Binaries || exit 1
ln -s ../UDK/Build/AppleSupportPkg/RELEASE_XCODE5/X64 RELEASE || exit 1
ln -s ../UDK/Build/AppleSupportPkg/DEBUG_XCODE5/X64 DEBUG || exit 1
ln -s ../UDK/Build/AppleSupportPkg/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
fi
updaterepo "https://github.com/tianocore/edk2" UDK UDK2018 || exit 1
cd UDK
updaterepo "https://github.com/acidanthera/EfiPkg" EfiPkg master || exit 1
updaterepo "https://github.com/acidanthera/OcSupportPkg" OcSupportPkg master || exit 1
if [ ! -d AppleSupportPkg ]; then
ln -s .. AppleSupportPkg || 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 AppleSupportPkg/AppleSupportPkg.dsc || exit 1
fi
if [ "$MODE" = "" ] || [ "$MODE" = "DEBUG" ]; then
build -a X64 -b NOOPT -t XCODE5 -p AppleSupportPkg/AppleSupportPkg.dsc || exit 1
fi
if [ "$MODE" = "" ] || [ "$MODE" = "RELEASE" ]; then
build -a X64 -b RELEASE -t XCODE5 -p AppleSupportPkg/AppleSupportPkg.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