3 # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 # Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
14 # Setup workspace if it is not set
16 if [ -z "$WORKSPACE" ]
18 echo Initializing workspace
19 if [ ! -e `pwd`/edksetup.sh
]
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
29 source edksetup.sh BaseTools
31 echo Building from
: $WORKSPACE
35 # Configure defaults for various options
49 # Pick a default tool type for a given OS
54 echo Cygwin not fully supported yet.
57 Major
=$
(uname
-r | cut
-f 1 -d '.')
58 # Major is Darwin version, not OS X version.
59 # OS X Yosemite 10.10.2 returns 14.
62 echo OvmfPkg requires OS X Snow Leopard
10.6 or newer OS
72 # Mavericks and future assume XCODE5 (clang + lldb)
78 gcc_version
=$
(gcc
-v 2>&1 |
tail -1 |
awk '{print $3}')
81 echo OvmfPkg requires GCC4.8 or later
97 # Scan command line to override defaults
102 if [ -z "$LAST_ARG" ]; then
116 BUILD_OPTIONS
="$BUILD_OPTIONS $arg"
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
142 BUILD_OPTIONS
="$BUILD_OPTIONS $arg"
150 if [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "yes" ]]; then
153 BUILD_OPTIONS
="$BUILD_OPTIONS -a IA32 -a X64"
154 PLATFORM_BUILD_DIR
=Ovmf3264
156 elif [[ "$ARCH_IA32" == "yes" && "$ARCH_X64" == "no" ]]; then
159 BUILD_OPTIONS
="$BUILD_OPTIONS -a IA32"
160 PLATFORM_BUILD_DIR
=Ovmf
$Processor
161 BUILD_ROOT_ARCH
=$PROCESSOR
165 BUILD_OPTIONS
="$BUILD_OPTIONS -a X64"
166 PLATFORM_BUILD_DIR
=Ovmf
$Processor
172 if [ -n "$QEMU_COMMAND" ]; then
174 # The user set the QEMU_COMMAND variable. We'll use it to run QEMU.
177 elif [ -x `which qemu-system-i386` ]; then
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
184 echo Unable to
find QEMU
for IA32 architecture
!
189 if [ -z "$QEMU_COMMAND" ]; then
191 # The user didn't set the QEMU_COMMAND variable.
193 QEMU_COMMAND
=qemu-system-x86_64
197 echo Unsupported processor architecture
: $PROCESSOR
198 echo Only IA32 or X64 is supported
203 if [ -z "$PLATFORMFILE" ]; then
204 PLATFORMFILE
=$WORKSPACE/OvmfPkg
/OvmfPkg
$Processor.dsc
207 if [[ "$RUN_QEMU" == "yes" ]]; then
208 qemu_version
=$
($QEMU_COMMAND -version 2>&1 | \
209 grep -o -E 'version [0-9]+\.[0-9]+\.[0-9]+' | \
211 case $qemu_version in
212 1.
[6-9].
*|
[2-9].
*.
*|
[1-9][0-9]*.
*.
*)
221 -hd[a-d
]|
-fd[ab
]|
-cdrom)
230 # Uncomment this block for parameter parsing debug
232 #echo RUN_QEMU=$RUN_QEMU
233 #echo BUILD_OPTIONS=$BUILD_OPTIONS
234 #echo BUILDTARGET=$BUILDTARGET
235 #echo TARGET_TOOLS=$TARGET_TOOLS
236 #echo PROCESSOR=$PROCESSOR
237 #echo Remaining for qemu: $*
240 BUILD_ROOT
=$WORKSPACE/Build
/$PLATFORM_BUILD_DIR/"$BUILDTARGET"_
"$TARGET_TOOLS"
241 FV_DIR
=$BUILD_ROOT/FV
242 BUILD_ROOT_ARCH
=$BUILD_ROOT/$BUILD_ROOT_ARCH
243 QEMU_FIRMWARE_DIR
=$BUILD_ROOT/QEMU
245 if [[ ! -f `which build` ||
! -f `which GenFv` ]];
247 # build the tools if they don't yet exist. Bin scheme
248 echo Building tools as they are not
in the path
249 make -C $WORKSPACE/BaseTools
250 elif [[ ( -f `which build` ||
-f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source
/C
/bin
]];
252 # build the tools if they don't yet exist. BinWrapper scheme
253 echo Building tools no
$EDK_TOOLS_PATH/Source
/C
/bin directory
254 make -C $WORKSPACE/BaseTools
256 echo using prebuilt tools
260 if [[ "$RUN_QEMU" == "yes" ]]; then
261 if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
262 mkdir
$QEMU_FIRMWARE_DIR
264 ln -sf $FV_DIR/OVMF.fd
$QEMU_FIRMWARE_DIR/bios.bin
265 if [[ "$ENABLE_FLASH" == "yes" ]]; then
266 QEMU_COMMAND
="$QEMU_COMMAND -pflash $QEMU_FIRMWARE_DIR/bios.bin"
268 QEMU_COMMAND
="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR"
270 if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
271 QEMU_COMMAND
="$QEMU_COMMAND -hda fat:$BUILD_ROOT_ARCH"
273 echo Running
: $QEMU_COMMAND "$@"
279 # Build the edk2 OvmfPkg
281 echo Running edk2 build
for OvmfPkg
$Processor
282 build
-p $PLATFORMFILE $BUILD_OPTIONS -b $BUILDTARGET -t $TARGET_TOOLS -n $THREADNUMBER