[go: nahoru, domu]

1094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea#!/bin/bash -e
2094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
3094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Copyright 2012, The Android Open Source Project
4094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea#
5094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Licensed under the Apache License, Version 2.0 (the "License");
6094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# you may not use this file except in compliance with the License.
7094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# You may obtain a copy of the License at
8094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea#
9094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea#     http://www.apache.org/licenses/LICENSE-2.0
10094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea#
11094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Unless required by applicable law or agreed to in writing, software
12094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# distributed under the License is distributed on an "AS IS" BASIS,
13094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# See the License for the specific language governing permissions and
15094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# limitations under the License.
16094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
17094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Creates and builds projects from a RenderScript testcase and a set of Java templates
18094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
19094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaHELP=no
20094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaVERBOSE=no
21094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaMINSDK=1
22094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaTARGET=1
23094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaNAME=""
24094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaOUT_DIR=
25094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaACTIVITY=""
26094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaPACKAGE=""
27094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaSDK=""
28094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaTESTCASE_PATH=""
29094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaDRIVER=""
30094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
31094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_param ()
32094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea{
33094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    if [ -z "$2" ]; then
34094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        echo "ERROR: Missing parameter after option '$1'"
35094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        exit 1
36094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    fi
37094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea}
38094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
39094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_required_param()
40094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea{
41094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    if [ -z "$1" ]; then
42094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        echo "ERROR: Missing required parameter $2"
43094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        exit 1
44094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    fi
45094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea}
46094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
47094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malearun ()
48094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea{
49094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    if [ "$VERBOSE" = "yes" ] ; then
50094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        echo "## COMMAND: $@"
51094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    fi
52094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    $@ 2>&1
53094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea}
54094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
55094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaprocess_template()
56094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea{
57094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  src=$1
58094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  dest=$2
59094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  sed -e "s/%ACTIVITY%/$3/g" -e "s/%PACKAGE%/$4/g" -e "s/%TESTCASE%/$5/g" -e "s/%MINSDK%/$6/g" < $src > $dest;
60094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  echo "processed $src ==> $dest"
61094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea}
62094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
63094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleawhile [ -n "$1" ]; do
64094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    opt="$1"
65094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    case "$opt" in
66094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --help|-h|-\?)
67094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            HELP=yes
68094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
69094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --verbose|-v)
70094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            VERBOSE=yes
71094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
72094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --sdk)
73094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
74094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            SDK="$2"
75094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
76094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --name)
77094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
78094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            NAME="$2"
79094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
80094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --out)
81094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
82094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            OUT_DIR="$2"
83094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
84094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --activity)
85094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
86094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ACTIVITY="$2"
87094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
88094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --package)
89094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
90094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            PACKAGE="$2"
91094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
92094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --minsdk)
93094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
94094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            MINSDK="$2"
95094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
96094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --target)
97094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
98094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            TARGET="$2"
99094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
100094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --testcase)
101094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
102094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            TESTCASE_PATH="$2"
103094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
104094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        --driver)
105094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            check_param $1 $2
106094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            DRIVER="${2%/}"
107094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
108094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        -*) # unknown options
109094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            echo "ERROR: Unknown option '$opt', use --help for list of valid ones."
110094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            exit 1
111094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        ;;
112094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea        *)  # Simply record parameter
113094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            if [ -z "$PARAMETERS" ] ; then
114094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea                PARAMETERS="$opt"
115094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            else
116094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea                PARAMETERS="$PARAMETERS $opt"
117094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            fi
118094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea            ;;
119094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    esac
120094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    shift
121094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleadone
122094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
123094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ "$HELP" = "yes" ] ; then
124094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "Usage: $PROGNAME [options]"
125094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo ""
126094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "Build a test project from a RS testcase and a java driver template."
127094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo ""
128094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "Required Parameters:"
129094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --sdk                Location of Android SDK installation"
130094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --out <path>         Location of your project directory"
131094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --testcase <name>    The .rs testcase file with which to build the project"
132094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --driver <name>      The java template directory with which to build the project"
133094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo ""
134094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "Optional Parameters (reasonable defaults are used if not specified)"
135094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --activity <name>    Name for your default Activity class"
136094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --package <name>     Package namespace for your project"
137094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --target <name>      Android build target. Execute 'android list targets' to list available targets and their ID's."
138094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --minsdk <name>      minSdkVersion attribute to embed in AndroidManifest.xml of test project."
139094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --help|-h|-?         Print this help"
140094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "    --verbose|-v         Enable verbose mode"
141094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo ""
142094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    exit 0
143094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
144094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
145094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Verify required parameters are non-empty
146094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_required_param "$SDK" "--sdk"
147094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_required_param "$OUT_DIR" "--out"
148094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_required_param "$TESTCASE_PATH" "--testcase"
149094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacheck_required_param "$DRIVER" "--driver"
150094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
151094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Compute name of testcase
152094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaTESTCASE=`basename $TESTCASE_PATH .rs`
153094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
154094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Compute activity, appname, and java package, if not specified via parameters
155094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ -z "$ACTIVITY" ]; then
156094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  ACTIVITY="$TESTCASE";
157094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
158094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
159094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ -z "$NAME" ]; then
160094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  NAME="$ACTIVITY"
161094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
162094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
163094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ -z "$PACKAGE" ]; then
164094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  PACKAGE=com.android.test.rsdebug.$TESTCASE
165094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
166094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
167094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Create the project
168094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malearun $SDK/tools/android create project --target $TARGET --name $NAME --path $OUT_DIR --activity $ACTIVITY --package $PACKAGE
169094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
170094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ $? != 0 ] ; then
171094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "ERROR: Could not create Android project."
172094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "       Check parameters and try again."
173094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    exit 1
174094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
175094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
176094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Compute name of destination source directory
177094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaDEST_SRC_DIR=$OUT_DIR/src/`echo $PACKAGE | sed 's/\./\//g'`
178094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
179094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ ! -d "$DRIVER" ]; then
180094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  # If driver directory does not exist, try to fix it up by searching the
181094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  # testcase directory as well
182094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  DRIVER=`dirname $TESTCASE_PATH`/"$DRIVER"
183094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  if [ ! -d $DRIVER ]; then
184094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "unable to find driver in $DRIVER, please check --driver"
185094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    exit 1;
186094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  fi
187094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
188094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
189094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "Copying driver template from $DRIVER -> $DEST_SRC_DIR"
190094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ ! -d "$DEST_SRC_DIR" ]; then
191094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  echo "Error, destination directory does not exist: $DEST_SRC_DIR";
192094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  exit 1;
193094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
194094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "Performing template substitutions:"
195094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "    %ACTIVITY% ==> $ACTIVITY"
196094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "    %PACKAGE% ==> $PACKAGE"
197094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "    %TESTCASE% ==> $TESTCASE"
198094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaecho "    %MINSDK% ==> $MINSDK"
199094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaSUBST_PARAMS="$ACTIVITY $PACKAGE $TESTCASE $MINSDK"
200094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
201094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# If it exists, use contents of driver-common directory to seed
202094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# the testcase project
203094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaDRIVER_COMMON="`dirname $TESTCASE_PATH`/driver-common"
204094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ -d $DRIVER_COMMON ]; then
205094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  echo "Found common driver directory: $DRIVER_COMMON"
206094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  ls $DRIVER_COMMON/SRC/*.java.template | while read src; do
207094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    SRC_BASENAME=`basename $src .java.template`;
208094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    dest=$DEST_SRC_DIR/`echo $SRC_BASENAME | sed "s/ACTIVITY/$ACTIVITY/g"`.java
209094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    process_template $src $dest $SUBST_PARAMS
210094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  done;
211094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
212094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  # Copy AndroidManifest.xml
213094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  COMMON_MANIFEST="$DRIVER_COMMON/AndroidManifest.xml"
214094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  if [ -e $COMMON_MANIFEST ]; then
215094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    process_template $COMMON_MANIFEST $OUT_DIR/AndroidManifest.xml $SUBST_PARAMS
216094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  fi
217094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
218094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
219094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Copy Java source to project directory.
220094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleals $DRIVER/*.java.template | while read src; do
221094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  SRC_BASENAME=`basename $src .java.template`
222094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  dest=$DEST_SRC_DIR/`echo $SRC_BASENAME | sed "s/ACTIVITY/$ACTIVITY/g"`.java
223094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  process_template $src $dest $SUBST_PARAMS
224094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleadone;
225094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
226094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Copy AndroidManifest.xml override, if it exists
227094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaOVERRIDE_MANIFEST="$DRIVER/AndroidManifest.xml"
228094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ -e $OVERRIDE_MANIFEST ]; then
229094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea  process_template $OVERRIDE_MANIFEST $OUT_DIR/AndroidManifest.xml $SUBST_PARAMS
230094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
231094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
232094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Copy RS testcase to project directory.
233094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel MaleaTESTCASE_DEST=$DEST_SRC_DIR/`basename $TESTCASE_PATH`
234094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaprocess_template $TESTCASE_PATH $TESTCASE_DEST $SUBST_PARAMS
235094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
236094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea# Buid signed and aligned apk
237094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleacd $OUT_DIR
238094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malearun ant clean debug install
239094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
240094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaif [ $? != 0 ] ; then
241094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    echo "ERROR: Apk build and install failed"
242094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea    exit 1
243094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleafi
244094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Malea
245094881f513ab366f7ffd0b2c7778ab50281ca59eDaniel Maleaexit 0
246