author | truebrain |
Sat, 07 Jun 2008 23:05:36 +0000 | |
branch | noai |
changeset 10853 | 87f2238f47d4 |
parent 10643 | 970417eef395 |
child 10878 | 6e4f60c7d18c |
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 |
9693
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
6 |
for f in `ls *.hpp`; do |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
7 |
case "${f}" in |
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
|
8 |
# these files should not be changed by this script |
10339
ce6cd68d9eb8
(svn r12880) [NoAI] -Add: introduces ai_types.hpp, which has all NNNId like VehicleID. This simplifies the include-mess, and avoids including tons of _type.h for just a single typedef.
truebrain
parents:
10338
diff
changeset
|
9 |
"ai_controller.hpp" | "ai_object.hpp" | "ai_types.hpp" ) continue; |
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
|
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 |
10338
fb4e0030116d
(svn r12879) [NoAI] -Fix: two bugs in $Id$ handling of squirrel_export, and one fix for future problems
truebrain
parents:
10308
diff
changeset
|
12 |
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b ${f}.tmp ${f}.sq 2> /dev/null || echo boo`" ]; then |
9596
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 |
9693
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
14 |
echo "Updated: ${f}.sq" |
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 |
10338
fb4e0030116d
(svn r12879) [NoAI] -Fix: two bugs in $Id$ handling of squirrel_export, and one fix for future problems
truebrain
parents:
10308
diff
changeset
|
24 |
if ! [ -f "${f}.sq" ] || [ -n "`diff -I '$Id' -b $1.sq $1.tmp 2> /dev/null || echo boo`" ]; then |
9596
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 |
9693
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
26 |
echo "Updated: $1.sq" |
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 |
|
9693
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
35 |
# Remove .hpp.sq if .hpp doesn't exist anymore |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
36 |
for f in `ls *.hpp.sq`; do |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
37 |
f=`echo ${f} | sed "s/.hpp.sq$/.hpp/"` |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
38 |
if [ ! -f ${f} ];then |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
39 |
echo "Deleted: ${f}.sq" |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
40 |
svn del --force ${f}.sq > /dev/null 2>&1 |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
41 |
fi |
31fcaa5375a1
(svn r10769) [NoAI] -Fix: EOL only changes are now considered as "not changed"
glx
parents:
9597
diff
changeset
|
42 |
done |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
43 |
|
10643
970417eef395
(svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents:
10339
diff
changeset
|
44 |
# Add stuff to ai_controller.cpp |
970417eef395
(svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents:
10339
diff
changeset
|
45 |
f='ai_controller.cpp' |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
46 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
47 |
functions=`` |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
48 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
49 |
echo " |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
50 |
{ } |
9597
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
51 |
/.hpp.sq/ { next } |
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
52 |
/squirrel_register_std/ { next } |
9741
53c1c5850e01
(svn r12221) [NoAI] -Fix: Register functions are no _Register functions, and always on top of the sort list
truebrain
parents:
9693
diff
changeset
|
53 |
/SQAI.*_Register/ { next } |
9597
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
54 |
|
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
55 |
/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
|
56 |
print \$0 |
9741
53c1c5850e01
(svn r12221) [NoAI] -Fix: Register functions are no _Register functions, and always on top of the sort list
truebrain
parents:
9693
diff
changeset
|
57 |
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
|
58 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
59 |
for (i = 1; files[i] != \"\"; i++) { |
10643
970417eef395
(svn r13187) [NoAI] -Codechange: rewrote the AI register part; C++ AIs are completely impossible now, and registration happens directly via AISquirrel. This cleans up the registration flow, and makes everything readable again, as sure I made a mess out of it :)
truebrain
parents:
10339
diff
changeset
|
60 |
print \"#include \\\"\" files[i] \"\\\"\" |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
61 |
} |
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 |
next; |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
64 |
} |
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 |
/\/\* Register all classes \*\// { |
9597
db3908cf597a
(svn r9630) [NoAI] -Codechange: remove now useless define.
rubidium
parents:
9596
diff
changeset
|
67 |
print \$0 |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
68 |
print \" squirrel_register_std(this->engine);\" |
9741
53c1c5850e01
(svn r12221) [NoAI] -Fix: Register functions are no _Register functions, and always on top of the sort list
truebrain
parents:
9693
diff
changeset
|
69 |
split(\"`grep '^void SQAI.*_Register(Squirrel \*engine) {$' *.hpp.sq | sed 's/^.*void //;s/Squirrel \*/this->/;s/ {/;/;s/_Register/0000Register/g;' | sort | sed 's/0000Register/_Register/g' | 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
|
70 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
71 |
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
|
72 |
print \" \" regs[i] |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
73 |
} |
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 |
next |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
76 |
} |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
77 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
78 |
{ print \$0; } |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
79 |
" > ${f}.awk |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
80 |
|
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
81 |
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
|
82 |
|
10338
fb4e0030116d
(svn r12879) [NoAI] -Fix: two bugs in $Id$ handling of squirrel_export, and one fix for future problems
truebrain
parents:
10308
diff
changeset
|
83 |
if ! [ -f "${f}" ] || [ -n "`diff -I '$Id' -b ${f} ${f}.tmp 2> /dev/null || echo boo`" ]; then |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
84 |
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
|
85 |
echo "Updated: ${f}" |
9528
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
86 |
else |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
87 |
rm -f ${f}.tmp |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
88 |
fi |
b2cc6f31363c
(svn r9448) [NoAI] -Codechange: extend the squirrel_export script to update ai_squirrel too.
rubidium
parents:
9526
diff
changeset
|
89 |
rm -f ${f}.awk |