From 737a75607ad8ca8daaca9c440a7ff6d394aa973e Mon Sep 17 00:00:00 2001
From: Ryan Harkin <ryan.harkin@linaro.org>
Date: Mon, 11 Feb 2013 18:10:58 +0000
Subject: [PATCH] panda: build.sh: use -b for build target

Make Panda's build.sh use -b to specify the build target on the command line.

Previously, build.sh could be called:

	./build.sh
	./build.sh -b DEBUG
	./build.sh RELEASE

Now, you call:

	./build.sh
	./build.sh -b DEBUG
	./build.sh -b RELEASE

Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
---
 PandaBoardPkg/build.sh |   28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/PandaBoardPkg/build.sh b/PandaBoardPkg/build.sh
index 8002eac..dc4b906 100755
--- a/PandaBoardPkg/build.sh
+++ b/PandaBoardPkg/build.sh
@@ -85,12 +85,23 @@ then
 fi
 
 TARGET=DEBUG
-for arg in "$@"
+BUILD_TARGET=DEBUG
+args=($@)
+
+for (( i=0; i<$#; i++ ))
 do
-  if [[ $arg == RELEASE ]]; 
-  then
-    TARGET=RELEASE
-  fi
+	if [[ "${args[$i]}" == "-b" ]]
+	then
+		TARGET=${args[$i+1]}
+		BUILD_TARGET=$TARGET
+		if [[ "$TARGET" == "RELEASE" ]]
+		then
+			BUILD_TARGET="$BUILD_TARGET -D DEBUG_TARGET=RELEASE"
+		fi
+		i=$i+1
+	else
+		other_args="$other_args ${args[$i]}"
+	fi
 done
 
 BUILD_ROOT=$WORKSPACE/Build/PandaBoard/"$TARGET"_"$TARGET_TOOLS"
@@ -109,12 +120,7 @@ fi
 #
 # Build the edk2 PandaBoard code
 #
-if [[ $TARGET == RELEASE ]]; then
-  build -p $WORKSPACE/PandaBoardPkg/PandaBoardPkg.dsc -a ARM -t $TARGET_TOOLS -b $TARGET -D DEBUG_TARGET=RELEASE ${2:-} ${3:-} ${4:-} ${5:-} ${6:-} ${7:-} ${8:-}
-else
-  build -p ${WORKSPACE:-}/PandaBoardPkg/PandaBoardPkg.dsc -a ARM -t $TARGET_TOOLS -b $TARGET ${1:-} ${2:-} ${3:-} ${4:-} ${5:-} ${6:-} ${7:-} ${8:-}
-fi
-
+build -p $WORKSPACE/PandaBoardPkg/PandaBoardPkg.dsc -a ARM -t $TARGET_TOOLS -b $BUILD_TARGET $other_args
 
 for arg in "$@"
 do
-- 
1.7.9.5

