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