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 17 echo "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 24 prog="$0" 25 while [ -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 34 done 35 oldwd=`pwd` 36 progdir=`dirname "${prog}"` 37 cd "${progdir}" 38 progdir=`pwd` 39 prog="${progdir}"/`basename "${prog}"` 40 cd "${oldwd}" 41 42 libdir=`dirname $progdir`/framework 43 44 javaOpts="" 45 while expr "x$1" : 'x-J' >/dev/null; do 46 opt=`expr "$1" : '-J\(.*\)'` 47 javaOpts="${javaOpts} -${opt}" 48 shift 49 done 50 51 #echo "progdir: $progdir" 52 #echo "android build top: $ANDROID_BUILD_TOP" 53 project_home=$1 54 javac=$2 55 tmpdir=$3 # ANDROID_BUILD_TOP/$3 56 dxjarpath=$4 57 outdir=$5 58 project_src=$project_home/src 59 project_lib=$project_home/lib 60 project_data=$project_home/data 61 javac_out=$tmpdir/classout 62 javafiles=$tmpdir/_javafiles 63 mainfilesdir=$tmpdir/mainfiles 64 mainfileslist=$tmpdir/_mainfileslist 65 66 #echo "home: $project_home" 67 68 if [ "$tmpdir" = "" ]; then 69 echo "error: intermediates dir not set/found!!"; 70 exit 1; 71 else 72 echo "tmp/intermediates dir (rel): $tmpdir" 73 fi 74 rm -rf $javac_out 75 rm -rf $javafiles 76 77 # compile all files from javafiles 78 echo "compiling all java files (with package dxc.junit.**)" 79 find $project_src/dxc/junit -name '*.java' > $javafiles 80 echo "$project_src/util/CollectAllTests.java" >> $javafiles 81 mkdir -p $javac_out 82 jfiles=\@$javafiles 83 javac -d $javac_out -classpath ${dxjarpath} -sourcepath $project_src $jfiles 84 85 echo "compiling all jasmin (*.j)" 86 87 find $project_src/dxc/junit -name '*.j' | sort > $tmpdir/alljasminfiles 88 java -classpath $project_home/utilclasses:$project_lib/jasmin.jar util.CompileAllJasmin $tmpdir/alljasminfiles $javac_out &> /dev/null 89 90 echo "compiling all .cfh files into .class files" 91 for acfhfile in `find $project_src/dxc/junit -name '*.cfh'` 92 do 93 #echo "cfh file:$acfhfile" 94 java -classpath ${dxjarpath} dxconvext.ClassFileAssembler $acfhfile $javac_out &> /dev/null 95 done 96 97 echo "generating Main_*.java files reading from $project_home writing to $mainfilesdir" 98 mkdir -p $mainfilesdir 99 # generate the Main_*.java files 100 java -cp $project_lib/junit.jar:$javac_out util.CollectAllTests $project_home $mainfilesdir 101 # compile the Main_*.java files 102 find $mainfilesdir/dxc/junit -name '*.java' > $mainfileslist 103 echo "compile the Main_*.java files" 104 javac -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 107 fdest=$outdir/cts/dxconverter 108 mkdir -p $fdest/data 109 acp -r $javac_out $fdest/ 110 acp $mainfilesdir/data/scriptdata $fdest/data/scriptdata 111 112 echo "dxconverter test suite sucessfully built!" 113 echo "intermediate Main_*.java files (for stacktrace analysis) can be found under $mainfilesdir" 114 115