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
|
#!/bin/bash
#echo "xml to cpp base class..."
DIR=`dirname $0`
MODULE=$1
noAStyle=0
which astyle 1>/dev/null 2>&1
noAStyle=$?
maxThreads=64
threads=0
for f in `find tmp/040_addcount -name "*.xml" | sort`
do
for mode in h cpp
do
xmlfile=${f##*/}
file=${xmlfile%%.*}
fileLower=`echo $file | tr '[:upper:]' '[:lower:]'`
ecmafile=${fileLower}_base.$mode
(
#if [ "$f" -nt "cpp/${ecmafile}" ]
#then
#echo "processing $file ($mode)"
if [ ! -z $MODULE ]
then
xsltproc --stringparam mode $mode --stringparam module $MODULE $DIR/xml2cppbase.xsl "$f" >"cpp/new_${ecmafile}"
else
xsltproc --stringparam mode $mode $DIR/xml2cppbase.xsl "$f" >"cpp/new_${ecmafile}"
fi
if [ $noAStyle -eq 0 ]
then
astyle "cpp/new_${ecmafile}"
fi
if [ ! -f "cpp/${ecmafile}" ]
then
mv "cpp/new_${ecmafile}" "cpp/${ecmafile}"
else
diff "cpp/${ecmafile}" "cpp/new_${ecmafile}"
if [ $? -ne 0 ]
then
mv "cpp/new_${ecmafile}" "cpp/${ecmafile}"
else
rm "cpp/new_${ecmafile}"
fi
fi
#fi
) &
let threads=threads+1
if [ $threads -eq $maxThreads ]; then
echo "waiting for threads to finish..."
wait
threads=0
fi
done
done
wait
rm -f cpp/*.orig
echo "done."
|