]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/build.sh
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmulatorPkg / build.sh
CommitLineData
417a8020 1#!/bin/bash
2#
461e8e8e 3# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
8f5b2655 4# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
417a8020 5#
e3ba31da 6# SPDX-License-Identifier: BSD-2-Clause-Patent
417a8020 7#
8
461e8e8e 9set -e
10shopt -s nocasematch
11
12
13#
14# Setup workspace if it is not set
15#
16if [ -z "$WORKSPACE" ]
17then
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
30else
31 echo Building from: $WORKSPACE
32fi
33
34#
35# Configure defaults for various options
36#
37
38PROCESSOR=
39BUILDTARGET=DEBUG
40BUILD_OPTIONS=
41PLATFORMFILE=
42LAST_ARG=
43RUN_EMULATOR=no
44CLEAN_TYPE=none
8ff12211 45TARGET_TOOLS=GCC48
461e8e8e 46NETWORK_SUPPORT=
47BUILD_NEW_SHELL=
48BUILD_FAT=
49HOST_PROCESSOR=X64
50
51case `uname` in
52 CYGWIN*) echo Cygwin not fully supported yet. ;;
53 Darwin*)
54 Major=$(uname -r | cut -f 1 -d '.')
55 if [[ $Major == 9 ]]
56 then
57 echo UnixPkg requires Snow Leopard or later OS
58 exit 1
59 else
8649abce
AF
60 CLANG_VER=$(clang -ccc-host-triple x86_64-pc-win32-macho 2>&1 >/dev/null) || true
61 if [[ "$CLANG_VER" == *-ccc-host-triple* ]]
62 then
55b9bbf4 63 # only older versions of Xcode support -ccc-host-triple, for newer versions
8649abce 64 # it is -target
55b9bbf4 65 HOST_TOOLS=XCODE5
8649abce
AF
66 TARGET_TOOLS=XCODE5
67 else
68 HOST_TOOLS=XCODE32
69 TARGET_TOOLS=XCLANG
70 fi
461e8e8e 71 fi
72 BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
73 BUILD_FAT="-D BUILD_FAT"
74 ;;
75 Linux*)
76 case `uname -m` in
77 i386)
78 HOST_PROCESSOR=IA32
79 ;;
80 i686)
81 HOST_PROCESSOR=IA32
82 ;;
83 x86_64)
84 HOST_PROCESSOR=X64
85 ;;
86 esac
ca3ba72c 87
88 gcc_version=$(gcc -v 2>&1 | tail -1 | awk '{print $3}')
89 case $gcc_version in
8ff12211
LE
90 [1-3].*|4.[0-7].*)
91 echo EmulatorPkg requires GCC4.8 or later
a04ec6d9
JJ
92 exit 1
93 ;;
dc4ad153
JJ
94 4.8.*)
95 TARGET_TOOLS=GCC48
96 ;;
a04ec6d9 97 4.9.*|6.[0-2].*)
dc4ad153
JJ
98 TARGET_TOOLS=GCC49
99 ;;
ca3ba72c 100 *)
a04ec6d9 101 TARGET_TOOLS=GCC5
ca3ba72c 102 ;;
103 esac
461e8e8e 104 ;;
105esac
106
107#
108# Scan command line to override defaults
109#
110
111for arg in "$@"
112do
113 if [ -z "$LAST_ARG" ]; then
114 case $arg in
115 -a|-b|-t|-p)
116 LAST_ARG=$arg
117 ;;
118 run)
119 RUN_EMULATOR=yes
120 shift
121 break
122 ;;
123 clean|cleanall)
124 CLEAN_TYPE=$arg
125 shift
126 break
127 ;;
128 *)
129 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
130 ;;
131 esac
132 else
133 case $LAST_ARG in
134 -a)
135 PROCESSOR=$arg
136 ;;
137 -b)
138 BUILDTARGET=$arg
139 ;;
140 -p)
141 PLATFORMFILE=$arg
142 ;;
143 -t)
c8a556e3 144 HOST_TOOLS=$arg
461e8e8e 145 ;;
146 *)
147 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
148 ;;
149 esac
150 LAST_ARG=
151 fi
152 shift
153done
c8a556e3 154if [ -z "$HOST_TOOLS" ]
461e8e8e 155then
c8a556e3 156 HOST_TOOLS=$TARGET_TOOLS
461e8e8e 157fi
158
159if [ -z "$PROCESSOR" ]
160then
161 PROCESSOR=$HOST_PROCESSOR
162fi
163
90fa59f6
LY
164BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator$PROCESSOR
165
461e8e8e 166case $PROCESSOR in
167 IA32)
168 ARCH_SIZE=32
1d602b12 169 LIB_NAMES="ld-linux.so.2 libdl.so.2 crt1.o crti.o crtn.o"
d142bb63 170 LIB_SEARCH_PATHS="/usr/lib/i386-linux-gnu /usr/lib32 /lib32 /usr/lib /lib"
461e8e8e 171 ;;
172 X64)
173 ARCH_SIZE=64
1d602b12 174 LIB_NAMES="ld-linux-x86-64.so.2 libdl.so.2 crt1.o crti.o crtn.o"
d142bb63 175 LIB_SEARCH_PATHS="/usr/lib/x86_64-linux-gnu /usr/lib64 /lib64 /usr/lib /lib"
461e8e8e 176 ;;
177esac
178
d142bb63 179for libname in $LIB_NAMES
180do
181 for dirname in $LIB_SEARCH_PATHS
182 do
183 if [ -e $dirname/$libname ]; then
184 export HOST_DLINK_PATHS="$HOST_DLINK_PATHS $dirname/$libname"
185 break
186 fi
187 done
188done
461e8e8e 189
190PLATFORMFILE=$WORKSPACE/EmulatorPkg/EmulatorPkg.dsc
8f5b2655 191BUILD_DIR="$BUILD_OUTPUT_DIR/${BUILDTARGET}_$TARGET_TOOLS"
8649abce 192BUILD_ROOT_ARCH=$BUILD_DIR/$PROCESSOR
461e8e8e 193
194if [[ ! -f `which build` || ! -f `which GenFv` ]];
195then
196 # build the tools if they don't yet exist. Bin scheme
197 echo Building tools as they are not in the path
198 make -C $WORKSPACE/BaseTools
199elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
200then
201 # build the tools if they don't yet exist. BinWrapper scheme
202 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
203 make -C $WORKSPACE/BaseTools
204else
205 echo using prebuilt tools
206fi
207
208
209if [[ "$RUN_EMULATOR" == "yes" ]]; then
210 case `uname` in
211 Darwin*)
32e55c9f
AF
212 cd $BUILD_ROOT_ARCH
213 /usr/bin/lldb \
214 -o "command script import $WORKSPACE/EmulatorPkg/Unix/lldbefi.py" \
215 -o 'script lldb.debugger.SetAsync(True)' \
216 -o "run" ./Host
217 exit $?
461e8e8e 218 ;;
219 esac
220
eb33b399 221 /usr/bin/gdb $BUILD_ROOT_ARCH/Host -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun.sh
461e8e8e 222 exit
223fi
224
225case $CLEAN_TYPE in
226 clean)
50509ec6 227 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -n 3 clean
c8a556e3 228 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
461e8e8e 229 exit $?
230 ;;
231 cleanall)
232 make -C $WORKSPACE/BaseTools clean
50509ec6 233 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -n 3 clean
c8a556e3 234 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
235 build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -b $BUILDTARGET -t $TARGET_TOOLS -n 3 clean
461e8e8e 236 exit $?
237 ;;
238esac
239
240
241#
242# Build the edk2 EmulatorPkg
243#
c8a556e3 244if [[ $HOST_TOOLS == $TARGET_TOOLS ]]; then
50509ec6 245 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3
461e8e8e 246else
50509ec6 247 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $HOST_TOOLS -D BUILD_$ARCH_SIZE -D SKIP_MAIN_BUILD -n 3 modules
c8a556e3 248 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc $BUILD_OPTIONS -a $PROCESSOR -b $BUILDTARGET -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3
8f5b2655 249 cp "$BUILD_OUTPUT_DIR/${BUILDTARGET}_$HOST_TOOLS/$PROCESSOR/Host" $BUILD_ROOT_ARCH
461e8e8e 250fi
251exit $?
417a8020 252