• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2008 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9#      http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17echo "building dx-test-suite"
18#
19# generates .class files from the .j (jasmin) and .cfh (hex format) files for the dxconverter test project.
20# the dx executable must be on the PATH.
21# only for lunch 2 at the moment - TODO check which commands are available in busybox/toolbox on the device
22#
23
24prog="$0"
25while [ -h "${prog}" ]; do
26    newProg=`/bin/ls -ld "${prog}"`
27    newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
28    if expr "x${newProg}" : 'x/' >/dev/null; then
29        prog="${newProg}"
30    else
31        progdir=`dirname "${prog}"`
32        prog="${progdir}/${newProg}"
33    fi
34done
35oldwd=`pwd`
36progdir=`dirname "${prog}"`
37cd "${progdir}"
38progdir=`pwd`
39prog="${progdir}"/`basename "${prog}"`
40cd "${oldwd}"
41
42libdir=`dirname $progdir`/framework
43
44javaOpts=""
45while expr "x$1" : 'x-J' >/dev/null; do
46    opt=`expr "$1" : '-J\(.*\)'`
47    javaOpts="${javaOpts} -${opt}"
48    shift
49done
50
51#echo "progdir: $progdir"
52#echo "android build top: $ANDROID_BUILD_TOP"
53project_home=$1
54javac=$2
55tmpdir=$3 # ANDROID_BUILD_TOP/$3
56dxjarpath=$4
57outdir=$5
58project_src=$project_home/src
59project_lib=$project_home/lib
60project_data=$project_home/data
61javac_out=$tmpdir/classout
62javafiles=$tmpdir/_javafiles
63mainfilesdir=$tmpdir/mainfiles
64mainfileslist=$tmpdir/_mainfileslist
65
66#echo "home: $project_home"
67
68if [ "$tmpdir" = "" ]; then
69    echo "error: intermediates dir not set/found!!";
70    exit 1;
71else
72    echo "tmp/intermediates dir (rel): $tmpdir"
73fi
74rm -rf --preserve-root $javac_out
75rm -rf --preserve-root $javafiles
76
77# compile all files from javafiles
78echo "compiling all java files (with package dxc.junit.**)"
79find $project_src/dxc/junit -name '*.java' > $javafiles
80echo "$project_src/util/CollectAllTests.java" >> $javafiles
81mkdir -p $javac_out
82jfiles=\@$javafiles
83javac -d $javac_out -classpath ${dxjarpath} -sourcepath $project_src $jfiles
84
85echo "compiling all jasmin (*.j)"
86
87find $project_src/dxc/junit -name '*.j' | sort > $tmpdir/alljasminfiles
88java -classpath $project_home/utilclasses:$project_lib/jasmin.jar util.CompileAllJasmin $tmpdir/alljasminfiles $javac_out  &> /dev/null
89
90echo "compiling all .cfh files into .class files"
91for acfhfile in `find $project_src/dxc/junit -name '*.cfh'`
92do
93    #echo "cfh file:$acfhfile"
94    java -classpath ${dxjarpath} dxconvext.ClassFileAssembler $acfhfile $javac_out &> /dev/null
95done
96
97echo "generating Main_*.java files reading from $project_home writing to $mainfilesdir"
98mkdir -p $mainfilesdir
99# generate the Main_*.java files
100java -cp $project_lib/junit.jar:$javac_out util.CollectAllTests $project_home $mainfilesdir
101# compile the Main_*.java files
102find $mainfilesdir/dxc/junit -name '*.java' > $mainfileslist
103echo "compile the Main_*.java files"
104javac -d $javac_out -classpath $project_lib/junit.jar:$javac_out -sourcepath $mainfilesdir \@$mainfileslist
105
106# now copy relevant data from intermediates dir to its final destination
107fdest=$outdir/cts/dxconverter
108mkdir -p $fdest/data
109acp -r $javac_out $fdest/
110acp $mainfilesdir/data/scriptdata $fdest/data/scriptdata
111
112echo "dxconverter test suite sucessfully built!"
113echo "intermediate Main_*.java files (for stacktrace analysis) can be found under $mainfilesdir"
114
115