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 57project_src=$project_home/src 58project_lib=$project_home/lib 59project_data=$project_home/data 60javac_out=$tmpdir/classout 61javafiles=$tmpdir/_javafiles 62mainfilesdir=$tmpdir/mainfiles 63mainfileslist=$tmpdir/_mainfileslist 64 65#echo "home: $project_home" 66 67if [ "$tmpdir" = "" ]; then 68 echo "error: intermediates dir not set/found!!"; 69 exit 1; 70else 71 echo "tmp/intermediates dir (rel): $tmpdir" 72fi 73rm -rf --preserve-root $javac_out 74rm -rf --preserve-root $javafiles 75 76# compile all files from javafiles 77echo "compiling all java files (with package dxc.junit.**)" 78find $project_src/dxc/junit -name '*.java' > $javafiles 79echo "$project_src/util/CollectAllTests.java" >> $javafiles 80mkdir -p $javac_out 81jfiles=\@$javafiles 82javac -d $javac_out -classpath ${dxjarpath} -sourcepath $project_src $jfiles 83 84echo "compiling all jasmin (*.j)" 85 86find $project_src/dxc/junit -name '*.j' | sort > $tmpdir/alljasminfiles 87java -classpath $project_home/utilclasses:$project_lib/jasmin.jar util.CompileAllJasmin $tmpdir/alljasminfiles $javac_out &> /dev/null 88 89echo "compiling all .cfh files into .class files" 90for acfhfile in `find $project_src/dxc/junit -name '*.cfh'` 91do 92 #echo "cfh file:$acfhfile" 93 java -classpath ${dxjarpath} dxconvext.ClassFileAssembler $acfhfile $javac_out &> /dev/null 94done 95 96echo "generating Main_*.java files reading from $project_home writing to $mainfilesdir" 97mkdir -p $mainfilesdir 98# generate the Main_*.java files 99java -cp $project_lib/junit.jar:$javac_out util.CollectAllTests $project_home $mainfilesdir 100# compile the Main_*.java files 101find $mainfilesdir/dxc/junit -name '*.java' > $mainfileslist 102echo "compile the Main_*.java files" 103javac -d $javac_out -classpath $project_lib/junit.jar:$javac_out -sourcepath $mainfilesdir \@$mainfileslist 104 105# now copy relevant data from intermediates dir to its final destination 106fdest=$ANDROID_BUILD_TOP/out/target/common/cts/dxconverter 107mkdir -p $fdest/data 108acp -r $javac_out $fdest/ 109acp $mainfilesdir/data/scriptdata $fdest/data/scriptdata 110 111echo "dxconverter test suite sucessfully built!" 112echo "intermediate Main_*.java files (for stacktrace analysis) can be found under $mainfilesdir" 113 114