summaryrefslogtreecommitdiff
path: root/ArmRealViewEbPkg/build.sh
blob: 449ed22fd8e3292e0d46c88bec9311d058056218 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution.  The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#

set -e
shopt -s nocasematch

function process_debug_scripts {
  if [[ -d $1 ]]; then
    for filename in `ls $1`
    do
      sed -e "s@ZZZZZZ@$BUILD_ROOT@g" -e "s@WWWWWW@$WORKSPACE@g" \
            "$1/$filename" \
            > "$BUILD_ROOT/$filename"

      #For ARMCYGWIN, we have to change /cygdrive/c to c:
      if [[ $TARGET_TOOLS == RVCT31CYGWIN ]]
      then
        mv "$BUILD_ROOT/$filename" "$BUILD_ROOT/$filename"_temp
        sed -e "s@/cygdrive/\(.\)@\1:@g" \
              "$BUILD_ROOT/$filename"_temp \
              > "$BUILD_ROOT/$filename"
        rm -f "$BUILD_ROOT/$filename"_temp
      fi
    done
  fi
}


#
# Setup workspace if it is not set
#
if [ -z "$WORKSPACE" ]
then
  echo Initializing workspace
  cd ..
  export EDK_TOOLS_PATH=`pwd`/BaseTools
  source edksetup.sh BaseTools
else
  echo Building from: $WORKSPACE
fi

#
# Pick a default tool type for a given OS
#
case `uname` in
  CYGWIN*) 
      TARGET_TOOLS=RVCT31CYGWIN 
      ;;
  Linux*)  
      # Not tested
      TARGET_TOOLS=ARMGCC 
      ;;
  Darwin*) 
      Major=$(uname -r | cut -f 1 -d '.')
      if [[ $Major == 9 ]]
      then
        # Not supported by this open source project
        TARGET_TOOLS=XCODE31
      else 
        TARGET_TOOLS=XCODE32
      fi  
      ;;
esac

TARGET=DEBUG
for arg in "$@"
do
  if [[ $arg == RELEASE ]]; 
  then
    TARGET=RELEASE
  fi
done

BUILD_ROOT=$WORKSPACE/Build/ArmRealViewEb/"$TARGET"_"$TARGET_TOOLS"

if  [[ ! -e $EDK_TOOLS_PATH/Source/C/bin ]];
then
  # build the tools if they don't yet exist
  echo Building tools: $EDK_TOOLS_PATH
  make -C $EDK_TOOLS_PATH
else
  echo using prebuilt tools
fi

#
# Build the edk2 ArmEb code
#
if [[ $TARGET == RELEASE ]]; then
  build -p $WORKSPACE/ArmRealViewEbPkg/ArmRealViewEbPkg.dsc -a ARM -t $TARGET_TOOLS -b $TARGET -D DEBUG_TARGET=RELEASE $2 $3 $4 $5 $6 $7 $8
else
  build -p $WORKSPACE/ArmRealViewEbPkg/ArmRealViewEbPkg.dsc -a ARM -t $TARGET_TOOLS -b $TARGET $1 $2 $3 $4 $5 $6 $7 $8
fi


for arg in "$@"
do
  if [[ $arg == clean ]]; then
    # no need to post process if we are doing a clean
    exit
  elif [[ $arg == cleanall ]]; then
    make -C $EDK_TOOLS_PATH clean
    exit
    
  fi
done


echo Creating debugger scripts
process_debug_scripts $WORKSPACE/ArmRealViewEbPkg/Debugger_scripts