1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/bin/sh
me=$(dirname $0)
CPP="$(which cpp)"
TIME=
outfile=""
cxx_flags="-include $me/r++.macros"
rxx_flags=""
while :; do
case "$1" in
-tm|-time)
shift
TIME="$(which time)";;
-x|-include)
shift
shift;;
-f*)
shift;;
-o)
shift
outfile="$1"
shift;;
-dump)
rxx_flags="$rxx_flags -dump"
shift;;
-bind)
rxx_flags="$rxx_flags -bind"
shift;;
-I*|-D*|-U*)
cxx_flags="$cxx_flags $1"
shift;;
-*)
shift;;
*.o|*.a|*.s)
shift;;
*.h|*.hh)
filename=$1
break;;
*.cpp|*.c)
filename=$1
break;;
*)
break;
esac
done
#echo "the file is $filename"
#echo "the flags are $cxx_flags"
#echo "the out file is $outfile"
if [ -z $filename ]; then
echo "usage: r++ [-dump | -bind] file.cpp"
exit 255
fi
tmp=$(mktemp)
#echo "the out file is $outfile"
#echo "the temp file is $tmp"
$TIME $CPP -xc++ -I$me/include -I$($CPP -print-file-name=include) \
-U__GNUC__ $cxx_flags "$filename" > "$tmp"
# echo -n "preprocessed. "
$TIME $me/r++0 $rxx_flags "$tmp"
rtn=$?
echo "parsed $(wc -l $tmp | awk '{print $1;}' ) loc"
rm "$tmp"
exit $rtn
|