]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/build.sh
Prevent infinite recursion when ASSERT(), DEBUG(), or any other use of ReportStatusCo...
[mirror_edk2.git] / UnixPkg / build.sh
CommitLineData
7ee3b613
A
1#!/bin/bash
2#
f9b8ab56 3# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
75f18f34 4# Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
5#
f9b8ab56 6# This program and the accompanying materials
7ee3b613
A
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
7ee3b613
A
19#
20# Setup workspace if it is not set
21#
22if [ -z "$WORKSPACE" ]
23then
24 echo Initializing workspace
75f18f34 25 if [ ! -e `pwd`/edksetup.sh ]
26 then
27 cd ..
28 fi
b395a08d 29# This version is for the tools in the BaseTools project.
30# this assumes svn pulls have the same root dir
1096a48f 31# export EDK_TOOLS_PATH=`pwd`/../BaseTools
b395a08d 32# This version is for the tools source in edk2
1096a48f 33 export EDK_TOOLS_PATH=`pwd`/BaseTools
7ee3b613
A
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#
43TARGET_TOOLS=MYTOOLS
44case `uname` in
45 CYGWIN*) echo Cygwin not fully supported yet. ;;
75f18f34 46 Darwin*)
7ee3b613
A
47 Major=$(uname -r | cut -f 1 -d '.')
48 if [[ $Major == 9 ]]
49 then
50 echo UnixPkg requires Snow Leopard or later OS
51 exit 1
75f18f34 52 else
7ee3b613 53 TARGET_TOOLS=XCODE32
75f18f34 54 fi
7ee3b613
A
55 ;;
56 Linux*) TARGET_TOOLS=ELFGCC ;;
75f18f34 57
7ee3b613
A
58esac
59
60BUILD_ROOT_ARCH=$WORKSPACE/Build/Unix/DEBUG_"$TARGET_TOOLS"/IA32
61
62if [[ ! -f `which build` || ! -f `which GenFv` ]];
63then
2a8ecdd0 64 # build the tools if they don't yet exist. Bin scheme
65 echo Building tools as they are not in the path
66 make -C $WORKSPACE/BaseTools
67elif [[ ( -f `which build` || -f `which GenFv` ) && ! -d $EDK_TOOLS_PATH/Source/C/bin ]];
68then
69 # build the tools if they don't yet exist. BinWrapper scheme
70 echo Building tools no $EDK_TOOLS_PATH/Source/C/bin directory
7ee3b613
A
71 make -C $WORKSPACE/BaseTools
72else
73 echo using prebuilt tools
74fi
75
76
77for arg in "$@"
78do
79 if [[ $arg == run ]]; then
80 case `uname` in
75f18f34 81 Darwin*)
7ee3b613
A
82 #
83 # On Darwin we can't use dlopen, so we have to load the real PE/COFF images.
84 # This .gdbinit script sets a breakpoint that loads symbols for the PE/COFFEE
85 # images that get loaded in SecMain
86 #
87 cp $WORKSPACE/UnixPkg/.gdbinit $WORKSPACE/Build/Unix/DEBUG_"$TARGET_TOOLS"/IA32
88 ;;
75f18f34 89 esac
7ee3b613
A
90
91 /usr/bin/gdb $BUILD_ROOT_ARCH/SecMain -q -cd=$BUILD_ROOT_ARCH
92 exit
93 fi
94
95 if [[ $arg == cleanall ]]; then
75f18f34 96 make -C $WORKSPACE/BaseTools clean
97 build -p $WORKSPACE/GccShellPkg/GccShellPkg.dsc -a IA32 -t $TARGET_TOOLS -n 3 clean
98 exit $?
99 fi
100
101 if [[ $arg == clean ]]; then
102 build -p $WORKSPACE/GccShellPkg/GccShellPkg.dsc -a IA32 -t $TARGET_TOOLS -n 3 clean
103 exit $?
7ee3b613 104 fi
185969ed 105
106 if [[ $arg == shell ]]; then
107 build -p $WORKSPACE/GccShellPkg/GccShellPkg.dsc -a IA32 -t $TARGET_TOOLS -n 3 $2 $3 $4 $5 $6 $7 $8
108 exit $?
109 fi
7ee3b613
A
110done
111
112
113#
114# Build the edk2 UnixPkg
115#
116echo $PATH
117echo `which build`
b9c8e50e 118build -p $WORKSPACE/UnixPkg/UnixPkg.dsc -a IA32 -t $TARGET_TOOLS -n 3 $1 $2 $3 $4 $5 $6 $7 $8
7ee3b613
A
119exit $?
120