3 # Copyright (C) 2007 The Android Open Source Project
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
9 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 # This script uses the file bytecodes.txt (in this directory) to
20 # generate code inside the given <file>, based on the directives found
21 # in that file. Refer to those files to understand what's being
22 # generated. (Look for comments that say "BEGIN(name)" where "name" is
23 # one of the "emission" directives defined in opcode-gen.awk in this
29 echo "processing `basename $1`" 1>&2
31 if [ "x$1" = "x" ]; then
32 echo "must specify a file" 1>&2
36 # Set up prog to be the path of this script, including following symlinks,
37 # and set up progdir to be the fully-qualified pathname of its directory.
39 while [ -h "${prog}" ]; do
40 newProg=`/bin/ls -ld "${prog}"`
41 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
42 if expr "x${newProg}" : 'x/' >/dev/null; then
45 progdir=`dirname "${prog}"`
46 prog="${progdir}/${newProg}"
50 progdir=`dirname "${prog}"`
53 prog="${progdir}"/`basename "${prog}"`
56 bytecodeFile="$progdir/bytecode.txt"
58 awk -v "bytecodeFile=$bytecodeFile" -f "$progdir/opcode-gen.awk" \
61 if [ "$?" = "0" ]; then
65 echo "error running awk" 1>&2