]> git.proxmox.com Git - mirror_edk2.git/blame - EmulatorPkg/Unix/build.sh
EmulatorPkg: Move Unix/UnixX64.* to EmulatorPkg.*
[mirror_edk2.git] / EmulatorPkg / Unix / build.sh
CommitLineData
112a857f 1#!/bin/bash
2#
3# Copyright (c) 2008 - 2011, Apple Inc. All rights reserved.<BR>
4# Copyright (c) 2010, 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
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# Pick a default tool type for a given OS
42#
112a857f 43UNIXPKG_TOOLS=GCC44
44NETWORK_SUPPORT=
45BUILD_NEW_SHELL=
46BUILD_FAT=
47case `uname` in
48 CYGWIN*) echo Cygwin not fully supported yet. ;;
49 Darwin*)
50 Major=$(uname -r | cut -f 1 -d '.')
51 if [[ $Major == 9 ]]
52 then
53 echo UnixPkg requires Snow Leopard or later OS
54 exit 1
55 else
56 TARGET_TOOLS=XCODE32
57 UNIXPKG_TOOLS=XCLANG
58 fi
112a857f 59 BUILD_NEW_SHELL="-D BUILD_NEW_SHELL"
60 BUILD_FAT="-D BUILD_FAT"
61 ;;
112a857f 62esac
63
27f6b4f8 64if [ -d /lib32 ]
65then
66 export LIB_ARCH_SFX=32
67fi
68
feceaad5 69if [ -z "$TARGET_TOOLS" ]
70then
71 TARGET_TOOLS=$UNIXPKG_TOOLS
72fi
73
e23e488e 74BUILD_ROOT_ARCH=$WORKSPACE/Build/Emulator32/DEBUG_"$UNIXPKG_TOOLS"/IA32
112a857f 75
76if [[ ! -f `which build` || ! -f `which GenFv` ]];
77then
78 # build the tools if they don't yet exist. Bin scheme
79 echo Building tools as they are not in the path
80 make -C $WORKSPACE/BaseTools
81elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
82then
83 # build the tools if they don't yet exist. BinWrapper scheme
84 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
85 make -C $WORKSPACE/BaseTools
86else
87 echo using prebuilt tools
88fi
89
90
91for arg in "$@"
92do
93 if [[ $arg == run ]]; then
94 case `uname` in
95 Darwin*)
96 #
97 # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
98 # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
59ad461d 99 # images that get loaded in Host
112a857f 100 #
bb89ec1a 101 cp $WORKSPACE/EmulatorPkg/Unix/.gdbinit $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
112a857f 102 ;;
103 esac
104
59ad461d 105 /usr/bin/gdb $BUILD_ROOT_ARCH/Host -q -cd=$BUILD_ROOT_ARCH -x $WORKSPACE/EmulatorPkg/Unix/GdbRun
112a857f 106 exit
107 fi
108
109 if [[ $arg == cleanall ]]; then
110 make -C $WORKSPACE/BaseTools clean
e23e488e 111 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
112 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
112a857f 113 build -p $WORKSPACE/ShellPkg/ShellPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
114 exit $?
115 fi
116
117 if [[ $arg == clean ]]; then
e23e488e 118 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $TARGET_TOOLS -D SEC_ONLY -n 3 clean
119 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -n 3 clean
112a857f 120 exit $?
121 fi
122
123done
124
125
126#
127# Build the edk2 UnixPkg
128#
feceaad5 129if [[ $TARGET_TOOLS == $UNIXPKG_TOOLS ]]; then
e23e488e 130 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 -D UNIX_SEC_BUILD $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
feceaad5 131else
e23e488e 132 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $TARGET_TOOLS -D BUILD_32 -D UNIX_SEC_BUILD -D SKIP_MAIN_BUILD -n 3 $1 $2 $3 $4 $5 $6 $7 $8 modules
133 build -p $WORKSPACE/EmulatorPkg/EmulatorPkg.dsc -a IA32 -t $UNIXPKG_TOOLS -D BUILD_32 $NETWORK_SUPPORT $BUILD_NEW_SHELL $BUILD_FAT -n 3 $1 $2 $3 $4 $5 $6 $7 $8
59ad461d 134 cp $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$TARGET_TOOLS"/IA32/Host $WORKSPACE/Build/EmuUnixIa32/DEBUG_"$UNIXPKG_TOOLS"/IA32
feceaad5 135fi
112a857f 136exit $?
137