1 | #!/bin/bash
|
---|
2 | #
|
---|
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
|
---|
4 | # Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
---|
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 |
|
---|
40 | #
|
---|
41 | # Configure defaults for various options
|
---|
42 | #
|
---|
43 |
|
---|
44 | PROCESSOR=X64
|
---|
45 | BUILDTARGET=DEBUG
|
---|
46 | BUILD_OPTIONS=
|
---|
47 | PLATFORMFILE=
|
---|
48 | LAST_ARG=
|
---|
49 | RUN_QEMU=no
|
---|
50 |
|
---|
51 | #
|
---|
52 | # Pick a default tool type for a given OS
|
---|
53 | #
|
---|
54 | TARGET_TOOLS=MYTOOLS
|
---|
55 | case `uname` in
|
---|
56 | CYGWIN*)
|
---|
57 | echo Cygwin not fully supported yet.
|
---|
58 | ;;
|
---|
59 | Darwin*)
|
---|
60 | Major=$(uname -r | cut -f 1 -d '.')
|
---|
61 | if [[ $Major == 9 ]]
|
---|
62 | then
|
---|
63 | echo OvmfPkg requires Snow Leopard or later OS
|
---|
64 | exit 1
|
---|
65 | else
|
---|
66 | TARGET_TOOLS=XCODE32
|
---|
67 | fi
|
---|
68 | ;;
|
---|
69 | Linux*)
|
---|
70 | gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
|
---|
71 | case $gcc_version in
|
---|
72 | 4.5.*)
|
---|
73 | TARGET_TOOLS=GCC45
|
---|
74 | ;;
|
---|
75 | 4.6.*)
|
---|
76 | TARGET_TOOLS=GCC46
|
---|
77 | ;;
|
---|
78 | *)
|
---|
79 | TARGET_TOOLS=GCC44
|
---|
80 | ;;
|
---|
81 | esac
|
---|
82 | esac
|
---|
83 |
|
---|
84 | #
|
---|
85 | # Scan command line to override defaults
|
---|
86 | #
|
---|
87 |
|
---|
88 | for arg in "$@"
|
---|
89 | do
|
---|
90 | if [ -z "$LAST_ARG" ]; then
|
---|
91 | case $arg in
|
---|
92 | -a|-b|-t|-p)
|
---|
93 | LAST_ARG=$arg
|
---|
94 | ;;
|
---|
95 | qemu)
|
---|
96 | RUN_QEMU=yes
|
---|
97 | shift
|
---|
98 | break
|
---|
99 | ;;
|
---|
100 | *)
|
---|
101 | BUILD_OPTIONS="$BUILD_OPTIONS $arg"
|
---|
102 | ;;
|
---|
103 | esac
|
---|
104 | else
|
---|
105 | case $LAST_ARG in
|
---|
106 | -a)
|
---|
107 | PROCESSOR=$arg
|
---|
108 | ;;
|
---|
109 | -b)
|
---|
110 | BUILDTARGET=$arg
|
---|
111 | ;;
|
---|
112 | -p)
|
---|
113 | PLATFORMFILE=$arg
|
---|
114 | ;;
|
---|
115 | -t)
|
---|
116 | TARGET_TOOLS=$arg
|
---|
117 | ;;
|
---|
118 | *)
|
---|
119 | BUILD_OPTIONS="$BUILD_OPTIONS $arg"
|
---|
120 | ;;
|
---|
121 | esac
|
---|
122 | LAST_ARG=
|
---|
123 | fi
|
---|
124 | shift
|
---|
125 | done
|
---|
126 |
|
---|
127 | case $PROCESSOR in
|
---|
128 | IA32)
|
---|
129 | Processor=Ia32
|
---|
130 | QEMU_COMMAND=qemu
|
---|
131 | ;;
|
---|
132 | X64)
|
---|
133 | Processor=X64
|
---|
134 | QEMU_COMMAND=qemu-system-x86_64
|
---|
135 | ;;
|
---|
136 | *)
|
---|
137 | echo Unsupported processor architecture: $PROCESSOR
|
---|
138 | echo Only IA32 or X64 is supported
|
---|
139 | exit 1
|
---|
140 | ;;
|
---|
141 | esac
|
---|
142 |
|
---|
143 | if [ -z "$PLATFORMFILE" ]; then
|
---|
144 | PLATFORMFILE=$WORKSPACE/OvmfPkg/OvmfPkg$Processor.dsc
|
---|
145 | fi
|
---|
146 |
|
---|
147 | ADD_QEMU_HDA=yes
|
---|
148 | for arg in "$@"
|
---|
149 | do
|
---|
150 | case $arg in
|
---|
151 | -hd[a-d]|-fd[ab]|-cdrom)
|
---|
152 | ADD_QEMU_HDA=no
|
---|
153 | break
|
---|
154 | ;;
|
---|
155 | esac
|
---|
156 | done
|
---|
157 |
|
---|
158 | #
|
---|
159 | # Uncomment this block for parameter parsing debug
|
---|
160 | #
|
---|
161 | #echo RUN_QEMU=$RUN_QEMU
|
---|
162 | #echo BUILD_OPTIONS=$BUILD_OPTIONS
|
---|
163 | #echo BUILDTARGET=$BUILDTARGET
|
---|
164 | #echo TARGET_TOOLS=$TARGET_TOOLS
|
---|
165 | #echo PROCESSOR=$PROCESSOR
|
---|
166 | #echo Remaining for qemu: $*
|
---|
167 | #exit 1
|
---|
168 |
|
---|
169 | BUILD_ROOT=$WORKSPACE/Build/Ovmf$Processor/"$BUILDTARGET"_"$TARGET_TOOLS"
|
---|
170 | FV_DIR=$BUILD_ROOT/FV
|
---|
171 | BUILD_ROOT_ARCH=$BUILD_ROOT/$PROCESSOR
|
---|
172 | QEMU_FIRMWARE_DIR=$BUILD_ROOT/QEMU
|
---|
173 |
|
---|
174 | if [[ ! -f `which build` || ! -f `which GenFv` ]];
|
---|
175 | then
|
---|
176 | # build the tools if they don't yet exist. Bin scheme
|
---|
177 | echo Building tools as they are not in the path
|
---|
178 | make -C $WORKSPACE/BaseTools
|
---|
179 | elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
|
---|
180 | then
|
---|
181 | # build the tools if they don't yet exist. BinWrapper scheme
|
---|
182 | echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
|
---|
183 | make -C $WORKSPACE/BaseTools
|
---|
184 | else
|
---|
185 | echo using prebuilt tools
|
---|
186 | fi
|
---|
187 |
|
---|
188 |
|
---|
189 | if [[ "$RUN_QEMU" == "yes" ]]; then
|
---|
190 | if [[ ! -d $QEMU_FIRMWARE_DIR ]]; then
|
---|
191 | mkdir $QEMU_FIRMWARE_DIR
|
---|
192 | fi
|
---|
193 | ln -sf $FV_DIR/OVMF.fd $QEMU_FIRMWARE_DIR/bios.bin
|
---|
194 | ln -sf $FV_DIR/OvmfVideo.rom $QEMU_FIRMWARE_DIR/vgabios-cirrus.bin
|
---|
195 | if [[ "$ADD_QEMU_HDA" == "yes" ]]; then
|
---|
196 | AUTO_QEMU_HDA="-hda fat:$BUILD_ROOT_ARCH"
|
---|
197 | else
|
---|
198 | AUTO_QEMU_HDA=
|
---|
199 | fi
|
---|
200 | QEMU_COMMAND="$QEMU_COMMAND -L $QEMU_FIRMWARE_DIR $AUTO_QEMU_HDA $*"
|
---|
201 | echo Running: $QEMU_COMMAND
|
---|
202 | $QEMU_COMMAND
|
---|
203 | exit $?
|
---|
204 | fi
|
---|
205 |
|
---|
206 | #
|
---|
207 | # Build the edk2 OvmfPkg
|
---|
208 | #
|
---|
209 | echo Running edk2 build for OvmfPkg$Processor
|
---|
210 | build -p $PLATFORMFILE $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS
|
---|
211 | exit $?
|
---|
212 |
|
---|