]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/build.sh
EmulatorPkg: Merge build*.sh into build.sh
[mirror_edk2.git] / EmulatorPkg / build.sh
CommitLineData
417a8020 1#!/bin/bash
2#
461e8e8e 3# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
4# Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
417a8020 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
461e8e8e 15set -e
16shopt -s nocasematch
17
18
19#
20# Setup workspace if it is not set
21#
22if [ -z "$WORKSPACE" ]
23then
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
36else
37 echo Building from: $WORKSPACE
38fi
39
40#
41# Configure defaults for various options
42#
43
44PROCESSOR=
45BUILDTARGET=DEBUG
46BUILD_OPTIONS=
47PLATFORMFILE=
48LAST_ARG=
49RUN_EMULATOR=no
50CLEAN_TYPE=none
51UNIXPKG_TOOLS=GCC44
52NETWORK_SUPPORT=
53BUILD_NEW_SHELL=
54BUILD_FAT=
55HOST_PROCESSOR=X64
56
57case `uname` in
58 CYGWIN*) echo Cygwin not fully supported yet. ;;
59 Darwin*)
60 Major=$(uname -r | cut -f 1 -d '.')
61 if [[ $Major == 9 ]]
62 then
63 echo UnixPkg requires Snow Leopard or later OS
64 exit 1
65 else
66 TARGET_TOOLS=XCODE32
67 UNIXPKG_TOOLS=XCLANG
68 fi
69 BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
70 BUILD_FAT="-D BUILD_FAT"
71 ;;
72 Linux*)
73 case `uname -m` in
74 i386)
75 HOST_PROCESSOR=IA32
76 ;;
77 i686)
78 HOST_PROCESSOR=IA32
79 ;;
80 x86_64)
81 HOST_PROCESSOR=X64
82 ;;
83 esac
84 ;;
85esac
86
87#
88# Scan command line to override defaults
89#
90
91for arg in "$@"
92do
93 if [ -z "$LAST_ARG" ]; then
94 case $arg in
95 -a|-b|-t|-p)
96 LAST_ARG=$arg
97 ;;
98 run)
99 RUN_EMULATOR=yes
100 shift
101 break
102 ;;
103 clean|cleanall)
104 CLEAN_TYPE=$arg
105 shift
106 break
107 ;;
108 *)
109 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
110 ;;
111 esac
112 else
113 case $LAST_ARG in
114 -a)
115 PROCESSOR=$arg
116 ;;
117 -b)
118 BUILDTARGET=$arg
119 ;;
120 -p)
121 PLATFORMFILE=$arg
122 ;;
123 -t)
124 TARGET_TOOLS=$arg
125 ;;
126 *)
127 BUILD_OPTIONS="$BUILD_OPTIONS $arg"
128 ;;
129 esac
130 LAST_ARG=
131 fi
132 shift
133done
134if [ -z "$TARGET_TOOLS" ]
135then
136 TARGET_TOOLS=$UNIXPKG_TOOLS
137fi
138
139if [ -z "$PROCESSOR" ]
140then
141 PROCESSOR=$HOST_PROCESSOR
142fi
143
144case $PROCESSOR in
145 IA32)
146 ARCH_SIZE=32
147 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator32
148 if [ -d /lib32 ]; then
149 export LIB_ARCH_SFX=32
150 fi
151 ;;
152 X64)
153 ARCH_SIZE=64
154 BUILD_OUTPUT_DIR=$WORKSPACE/Build/Emulator
155 if [ -d /lib64 ]; then
156 export LIB_ARCH_SFX=64
157 fi
158 ;;
159esac
160
161
162PLATFORMFILE=$WORKSPACE/EmulatorPkg/EmulatorPkg.dsc
163BUILD_ROOT_ARCH=$BUILD_OUTPUT_DIR/DEBUG_"$UNIXPKG_TOOLS"/$PROCESSOR
164
165if [[ ! -f `which build` || ! -f `which GenFv` ]];
166then
167 # build the tools if they don't yet exist. Bin scheme
168 echo Building tools as they are not in the path
169 make -C $WORKSPACE/BaseTools
170elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
171then
172 # build the tools if they don't yet exist. BinWrapper scheme
173 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
174 make -C $WORKSPACE/BaseTools
175else
176 echo using prebuilt tools
177fi
178
179
180if [[ "$RUN_EMULATOR" == "yes" ]]; then
181 case `uname` in
182 Darwin*)
183 #
184 # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
185 # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
186 # images that get loaded in Host
187 #
188 cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $BUILD_OUTPUT_DIR/DEBUG_"$UNIXPKG_TOOLS"/$PROCESSOR
189 ;;
190 esac
191
192 /usr/bin/gdb $BUILD_ROOT_ARCH/Host -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun
193 exit
194fi
195
196case $CLEAN_TYPE in
197 clean)
198 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $TARGET_TOOLS -D UNIX_SEC_BUILD -n 3 clean
199 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $UNIXPKG_TOOLS -n 3 clean
200 exit $?
201 ;;
202 cleanall)
203 make -C $WORKSPACE/BaseTools clean
204 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $TARGET_TOOLS -D UNIX_SEC_BUILD -n 3 clean
205 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $UNIXPKG_TOOLS -n 3 clean
206 build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
207 exit $?
208 ;;
209esac
210
211
212#
213# Build the edk2 EmulatorPkg
214#
215if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
216 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $UNIXPKG_TOOLS -D BUILD_$ARCH_SIZE -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
217else
218 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $TARGET_TOOLS -D BUILD_$ARCH_SIZE -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8 modules
219 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a $PROCESSOR -t $UNIXPKG_TOOLS -D BUILD_$ARCH_SIZE $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
220 cp $BUILD_OUTPUT_DIR/DEBUG_"$TARGET_TOOLS"/$PROCESSOR/Host $BUILD_ROOT_ARCH
221fi
222exit $?
417a8020 223