author | truelight |
Sat, 14 Jul 2007 21:15:49 +0000 | |
branch | noai |
changeset 9657 | f2c6e332d8bc |
parent 9597 | db3908cf597a |
child 9693 | 31fcaa5375a1 |
permissions | -rwxr-xr-x |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
1 |
#!/bin/bash |
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
2 |
|
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
3 |
# This must be called from within the src/ai/api directory. |
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
4 |
|
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
5 |
if [ -z "$1" ]; then |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
6 |
for f in `ls *.hpp `; do |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
7 |
case "$f" in |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
8 |
# these files should not be changed by this script |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
9 |
"ai_controller.hpp" | "ai_object.hpp") continue; |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
10 |
esac |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
11 |
awk -f squirrel_export.awk ${f} > ${f}.tmp |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
12 |
if [ -n "`diff ${f}.tmp ${f}.sq 2> /dev/null || echo boo`" ]; then |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
13 |
mv ${f}.tmp ${f}.sq |
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
14 |
echo "Updated: ${f}" |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
15 |
svn add ${f}.sq > /dev/null 2>&1 |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
16 |
svn propset svn:eol-style native ${f}.sq > /dev/null 2>&1 |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
17 |
svn propset svn:keywords Id ${f}.sq > /dev/null 2>&1 |
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
18 |
else |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
19 |
rm -f ${f}.tmp |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
20 |
fi |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
21 |
done |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
22 |
else |
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
23 |
awk -f squirrel_export.awk $1 > $1.tmp |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
24 |
if [ -n "`diff $1.sq $1.tmp`" ]; then |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
25 |
mv $1.tmp $1.sq |
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
26 |
echo "Updated: $1" |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
27 |
svn add $1.sq > /dev/null 2>&1 |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
28 |
svn propset svn:eol-style native $1.sq > /dev/null 2>&1 |
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
29 |
svn propset svn:keywords Id $1.sq > /dev/null 2>&1 |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
30 |
else |
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
31 |
rm -f $1.tmp |
9526
a4ad60ba03be
(svn r9446) [NoAI] -Add: simple script to make changing/adding classes to export a little simpler.
rubidium
parents:
diff
changeset
|
32 |
fi |
9586
656646f23da7
(svn r9611) [NoAI] -Add: allow a single param for squirrel_export which indicates the only file it should run on, instead of all *.hpp files
truelight
parents:
9572
diff
changeset
|
33 |
fi |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
34 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
35 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
36 |
# Add stuff to ../ai_squirrel.cpp |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
37 |
f='../ai_squirrel.cpp' |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
38 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
39 |
functions=`` |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
40 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
41 |
echo " |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
42 |
{ } |
9597
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
43 |
/.hpp.sq/ { next } |
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
44 |
/squirrel_register_std/ { next } |
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
45 |
/SQAI.*Register/ { next } |
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
46 |
|
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
47 |
/Note: this line a marker in squirrel_export.sh. Do not change!/ { |
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
48 |
print \$0 |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
49 |
split(\"`grep '^void SQAI.*Register(Squirrel \*engine) {$' *.hpp.sq | sed 's/:.*$//' | sort | uniq | tr -d '\r' | tr '\n' ' '`\", files, \" \") |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
50 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
51 |
for (i = 1; files[i] != \"\"; i++) { |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
52 |
print \"#include \\\"api/\" files[i] \"\\\"\" |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
53 |
} |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
54 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
55 |
next; |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
56 |
} |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
57 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
58 |
/\/\* Register all classes \*\// { |
9597
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
59 |
print \$0 |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
60 |
print \" squirrel_register_std(this->engine);\" |
9596
8af5a1399842
(svn r9629) [NoAI] -Codechange: move the squirrel export functions out of the API header files.
rubidium
parents:
9586
diff
changeset
|
61 |
split(\"`grep '^void SQAI.*Register(Squirrel \*engine) {$' *.hpp.sq | sed 's/^.*void //;s/Squirrel \*/this->/;s/ {/;/' | sort | tr -d '\r' | tr '\n' ' '`\", regs, \" \") |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
62 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
63 |
for (i = 1; regs[i] != \"\"; i++) { |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
64 |
print \" \" regs[i] |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
65 |
} |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
66 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
67 |
next |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
68 |
} |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
69 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
70 |
{ print \$0; } |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
71 |
" > ${f}.awk |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
72 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
73 |
awk -f ${f}.awk ${f} > ${f}.tmp |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
74 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
75 |
if [ -n "`diff ${f} ${f}.tmp`" ]; then |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
76 |
mv ${f}.tmp ${f} |
9572
6a78470c53f3
(svn r9535) [NoAI] -Codechange: don't export virtual classes, only their class signature for parameters.
rubidium
parents:
9528
diff
changeset
|
77 |
echo "Updated: ${f}" |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
78 |
else |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
79 |
rm -f ${f}.tmp |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
80 |
fi |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
81 |
rm -f ${f}.awk |