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