]>
Commit | Line | Data |
---|---|---|
7a84729f | 1 | #!/usr/bin/env bash |
5a9745b9 | 2 | # |
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR> | |
bf91082f | 4 | # Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR> |
5a9745b9 | 5 | # |
b26f0cf9 | 6 | # SPDX-License-Identifier: BSD-2-Clause-Patent |
5a9745b9 | 7 | # |
8 | ||
9 | set -e | |
10 | shopt -s nocasematch | |
11 | ||
12 | ||
13 | # | |
14 | # Setup workspace if it is not set | |
15 | # | |
16 | if [ -z "$WORKSPACE" ] | |
17 | then | |
18 | echo Initializing workspace | |
19 | if [ ! -e `pwd`/edksetup.sh ] | |
20 | then | |
21 | cd .. | |
22 | fi | |
23 | # This version is for the tools in the BaseTools project. | |
24 | # this assumes svn pulls have the same root dir | |
25 | # export EDK_TOOLS_PATH=`pwd`/../BaseTools | |
26 | # This version is for the tools source in edk2 | |
27 | export EDK_TOOLS_PATH=`pwd`/BaseTools | |
28 | echo $EDK_TOOLS_PATH | |
29 | source edksetup.sh BaseTools | |
30 | else | |
31 | echo Building from: $WORKSPACE | |
32 | fi | |
33 | ||
66325870 | 34 | # |
35 | # Configure defaults for various options | |
36 | # | |
37 | ||
3f35b140 JJ |
38 | ARCH_IA32=no |
39 | ARCH_X64=no | |
66325870 | 40 | BUILDTARGET=DEBUG |
41 | BUILD_OPTIONS= | |
04629652 | 42 | PLATFORMFILE= |
0dd8d7d5 | 43 | THREADNUMBER=0 |
66325870 | 44 | LAST_ARG= |
45 | RUN_QEMU=no | |
bc9be821 | 46 | ENABLE_FLASH=no |
5a9745b9 | 47 | |
48 | # | |
49 | # Pick a default tool type for a given OS | |
50 | # | |
51 | TARGET_TOOLS=MYTOOLS | |
52 | case `uname` in | |
66325870 | 53 | CYGWIN*) |
54 | echo Cygwin not fully supported yet. | |
55 | ;; | |
5a9745b9 | 56 | Darwin*) |
429c05fa | 57 | Major=$(uname -r | cut -f 1 -d '.') |
cbe2e9ee AF |
58 | # Major is Darwin version, not OS X version. |
59 | # OS X Yosemite 10.10.2 returns 14. | |
429c05fa | 60 | case $Major in |
cbe2e9ee AF |
61 | [156789]) |
62 | echo OvmfPkg requires OS X Snow Leopard 10.6 or newer OS | |
63 | exit 1 | |
64 | ;; | |
429c05fa | 65 | 10) |
66 | TARGET_TOOLS=XCODE32 | |
67 | ;; | |
68 | 1[12]) | |
69 | TARGET_TOOLS=XCLANG | |
70 | ;; | |
71 | *) | |
cbe2e9ee AF |
72 | # Mavericks and future assume XCODE5 (clang + lldb) |
73 | TARGET_TOOLS=XCODE5 | |
429c05fa | 74 | ;; |
75 | esac | |
76 | ;; | |
5a9745b9 | 77 | Linux*) |
8567a8ca | 78 | gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}') |
79 | case $gcc_version in | |
8d7cdfae LE |
80 | [1-3].*|4.[0-7].*) |
81 | echo OvmfPkg requires GCC4.8 or later | |
2667ad40 KRW |
82 | exit 1 |
83 | ;; | |
595a5bc9 | 84 | 4.8.*) |
d0115279 JJ |
85 | TARGET_TOOLS=GCC48 |
86 | ;; | |
656ac0c7 | 87 | 4.9.*|6.[0-2].*) |
595a5bc9 JJ |
88 | TARGET_TOOLS=GCC49 |
89 | ;; | |
8567a8ca | 90 | *) |
2667ad40 | 91 | TARGET_TOOLS=GCC5 |
8567a8ca | 92 | ;; |
93 | esac | |
66325870 | 94 | esac |
95 | ||
96 | # | |
97 | # Scan command line to override defaults | |
98 | # | |
5a9745b9 | 99 | |
66325870 | 100 | for arg in "$@" |
101 | do | |
102 | if [ -z "$LAST_ARG" ]; then | |
103 | case $arg in | |
57863080 | 104 | -a|-b|-t|-p|-n) |
66325870 | 105 | LAST_ARG=$arg |
106 | ;; | |
107 | qemu) | |
108 | RUN_QEMU=yes | |
109 | shift | |
110 | break | |
111 | ;; | |
bc9be821 JJ |
112 | --enable-flash) |
113 | ENABLE_FLASH=yes | |
114 | ;; | |
66325870 | 115 | *) |
116 | BUILD_OPTIONS="$BUILD_OPTIONS $arg" | |
117 | ;; | |
118 | esac | |
119 | else | |
120 | case $LAST_ARG in | |
121 | -a) | |
3f35b140 JJ |
122 | if [[ x"$arg" != x"IA32" && x"$arg" != x"X64" ]]; then |
123 | echo Unsupported processor architecture: $arg | |
124 | echo Only IA32 or X64 is supported | |
125 | exit 1 | |
126 | fi | |
127 | eval ARCH_$arg=yes | |
66325870 | 128 | ;; |
129 | -b) | |
130 | BUILDTARGET=$arg | |
131 | ;; | |
04629652 | 132 | -p) |
133 | PLATFORMFILE=$arg | |
134 | ;; | |
66325870 | 135 | -t) |
136 | TARGET_TOOLS=$arg | |
137 | ;; | |
57863080 | 138 | -n) |
139 | THREADNUMBER=$arg | |
140 | ;; | |
66325870 | 141 | *) |
142 | BUILD_OPTIONS="$BUILD_OPTIONS $arg" | |
143 | ;; | |
144 | esac | |
145 | LAST_ARG= | |
146 | fi | |
147 | shift | |
148 | done | |
149 | ||
3f35b140 JJ |
150 | if [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "yes" ]]; then |
151 | PROCESSOR=IA32X64 | |
152 | Processor=Ia32X64 | |
153 | BUILD_OPTIONS="$BUILD_OPTIONS -a IA32 -a X64" | |
154 | PLATFORM_BUILD_DIR=Ovmf3264 | |
155 | BUILD_ROOT_ARCH=X64 | |
156 | elif [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "no" ]]; then | |
157 | PROCESSOR=IA32 | |
158 | Processor=Ia32 | |
159 | BUILD_OPTIONS="$BUILD_OPTIONS -a IA32" | |
160 | PLATFORM_BUILD_DIR=Ovmf$Processor | |
161 | BUILD_ROOT_ARCH=$PROCESSOR | |
162 | else | |
163 | PROCESSOR=X64 | |
164 | Processor=X64 | |
165 | BUILD_OPTIONS="$BUILD_OPTIONS -a X64" | |
166 | PLATFORM_BUILD_DIR=Ovmf$Processor | |
167 | BUILD_ROOT_ARCH=X64 | |
168 | fi | |
169 | ||
66325870 | 170 | case $PROCESSOR in |
171 | IA32) | |
7e73a64f JJ |
172 | if [ -n "$QEMU_COMMAND" ]; then |
173 | # | |
174 | # The user set the QEMU_COMMAND variable. We'll use it to run QEMU. | |
175 | # | |
176 | : | |
177 | elif [ -x `which qemu-system-i386` ]; then | |
0aedc542 | 178 | QEMU_COMMAND=qemu-system-i386 |
179 | elif [ -x `which qemu-system-x86_64` ]; then | |
180 | QEMU_COMMAND=qemu-system-x86_64 | |
181 | elif [ -x `which qemu` ]; then | |
182 | QEMU_COMMAND=qemu | |
183 | else | |
184 | echo Unable to find QEMU for IA32 architecture! | |
185 | exit 1 | |
186 | fi | |
66325870 | 187 | ;; |
3f35b140 | 188 | X64|IA32X64) |
7e73a64f JJ |
189 | if [ -z "$QEMU_COMMAND" ]; then |
190 | # | |
191 | # The user didn't set the QEMU_COMMAND variable. | |
192 | # | |
193 | QEMU_COMMAND=qemu-system-x86_64 | |
194 | fi | |
66325870 | 195 | ;; |
196 | *) | |
197 | echo Unsupported processor architecture: $PROCESSOR | |
198 | echo Only IA32 or X64 is supported | |
199 | exit 1 | |
200 | ;; | |
5a9745b9 | 201 | esac |
202 | ||
04629652 | 203 | if [ -z "$PLATFORMFILE" ]; then |
204 | PLATFORMFILE=$WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc | |
205 | fi | |
206 | ||
d48ec970 | 207 | if [[ "$RUN_QEMU" == "yes" ]]; then |
2a5d278b JJ |
208 | qemu_version=$($QEMU_COMMAND -version 2>&1 | \ |
209 | grep -o -E 'version [0-9]+\.[0-9]+\.[0-9]+' | \ | |
210 | awk '{print $2}') | |
d48ec970 | 211 | case $qemu_version in |
bf91082f | 212 | 1.[6-9].*|[2-9].*.*|[1-9][0-9]*.*.*) |
d48ec970 | 213 | ENABLE_FLASH=yes |
66325870 | 214 | ;; |
215 | esac | |
d48ec970 | 216 | fi |
66325870 | 217 | |
218 | # | |
219 | # Uncomment this block for parameter parsing debug | |
220 | # | |
221 | #echo RUN_QEMU=$RUN_QEMU | |
222 | #echo BUILD_OPTIONS=$BUILD_OPTIONS | |
223 | #echo BUILDTARGET=$BUILDTARGET | |
224 | #echo TARGET_TOOLS=$TARGET_TOOLS | |
225 | #echo PROCESSOR=$PROCESSOR | |
226 | #echo Remaining for qemu: $* | |
227 | #exit 1 | |
228 | ||
3f35b140 | 229 | BUILD_ROOT=$WORKSPACE/Build/$PLATFORM_BUILD_DIR/"$BUILDTARGET"_"$TARGET_TOOLS" |
5a9745b9 | 230 | FV_DIR=$BUILD_ROOT/FV |
3f35b140 | 231 | BUILD_ROOT_ARCH=$BUILD_ROOT/$BUILD_ROOT_ARCH |
5a9745b9 | 232 | QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU |
233 | ||
234 | if [[ ! -f `which build` || ! -f `which GenFv` ]]; | |
235 | then | |
236 | # build the tools if they don't yet exist. Bin scheme | |
237 | echo Building tools as they are not in the path | |
238 | make -C $WORKSPACE/BaseTools | |
239 | elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]]; | |
240 | then | |
241 | # build the tools if they don't yet exist. BinWrapper scheme | |
242 | echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory | |
243 | make -C $WORKSPACE/BaseTools | |
244 | else | |
245 | echo using prebuilt tools | |
246 | fi | |
247 | ||
248 | ||
66325870 | 249 | if [[ "$RUN_QEMU" == "yes" ]]; then |
250 | if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then | |
251 | mkdir $QEMU_FIRMWARE_DIR | |
5a9745b9 | 252 | fi |
eaf4f336 | 253 | ln -sf $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin |
bc9be821 | 254 | if [[ "$ENABLE_FLASH" == "yes" ]]; then |
8fed4e47 | 255 | QEMU_COMMAND="$QEMU_COMMAND -drive if=pflash,format=raw,file=$QEMU_FIRMWARE_DIR/bios.bin" |
66325870 | 256 | else |
bc9be821 JJ |
257 | QEMU_COMMAND="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR" |
258 | fi | |
0d696b78 JJ |
259 | echo Running: $QEMU_COMMAND "$@" |
260 | $QEMU_COMMAND "$@" | |
66325870 | 261 | exit $? |
262 | fi | |
5a9745b9 | 263 | |
264 | # | |
265 | # Build the edk2 OvmfPkg | |
266 | # | |
267 | echo Running edk2 build for OvmfPkg$Processor | |
3f35b140 | 268 | build -p $PLATFORMFILE $BUILD_OPTIONS -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER |
5a9745b9 | 269 | exit $? |
270 |