File: xml2cppbase.sh

package info (click to toggle)
actiona 3.11.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 54,580 kB
  • sloc: cpp: 969,398; xml: 52,881; javascript: 32,914; python: 23,909; sh: 550; ansic: 90; makefile: 9
file content (69 lines) | stat: -rw-r--r-- 1,701 bytes parent folder | download
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."