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