summaryrefslogtreecommitdiff
path: root/src/script/api/squirrel_export.sh
diff options
context:
space:
mode:
authortruebrain <truebrain@openttd.org>2011-11-29 23:29:20 +0000
committertruebrain <truebrain@openttd.org>2011-11-29 23:29:20 +0000
commit7158aaea3100fbae72c75645800592117375f897 (patch)
tree30b4f0058553c0246ea3c5d773972bbafedac5b7 /src/script/api/squirrel_export.sh
parente60747a6043d42b872d02ba667f99187b5d3f1d7 (diff)
downloadopenttd-7158aaea3100fbae72c75645800592117375f897.tar.xz
(svn r23373) -Add: move the AI API to script/api/ai, and move the Squirrel C++ glue templates to script/api/template
Diffstat (limited to 'src/script/api/squirrel_export.sh')
-rwxr-xr-xsrc/script/api/squirrel_export.sh35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/script/api/squirrel_export.sh b/src/script/api/squirrel_export.sh
index b29727a7d..bf54526e8 100755
--- a/src/script/api/squirrel_export.sh
+++ b/src/script/api/squirrel_export.sh
@@ -23,14 +23,32 @@ fi
# This must be called from within a src/???/api directory.
scriptdir=`dirname $0`
apilc=`pwd | sed "s@/api@@;s@.*/@@"`
-apiuc=`echo ${apilc} | tr [a-z] [A-Z]`
+
+# Check if we are in the root directory of the API, as then we generate all APIs
+if [ "$apilc" = "script" ]; then
+ for api in `find -type d | cut -b3-`; do
+ if [ -z "$api" ]; then continue; fi
+ echo "Generating for API '$api' ..."
+ cd $api
+ sh $scriptdir/../`basename $0`
+ cd ..
+ done
+ exit 0
+fi
+
+case $apilc in
+ template) apiuc="Template" ;;
+ ai) apiuc="AI" ;;
+ *) echo "Unknown API type."; exit 1 ;;
+esac
if [ -z "$1" ]; then
- for f in `ls ../../script/api/*.hpp`; do
- bf=`basename ${f} | sed s/script/${apilc}/`
+ for f in `ls ../*.hpp`; do
+ bf=`basename ${f} | sed s@script_@${apilc}_@`
# ScriptController has custom code, and should not be generated
if [ "`basename ${f}`" = "script_controller.hpp" ]; then continue; fi
+ if [ "`basename ${f}`" = "script_object.hpp" ]; then continue; fi
${AWK} -v api=${apiuc} -f ${scriptdir}/squirrel_export.awk ${f} > ${bf}.tmp
@@ -71,22 +89,23 @@ fi
# Remove .hpp.sq if .hpp doesn't exist anymore
for f in `ls *.hpp.sq`; do
- f=`echo ${f} | sed "s/.hpp.sq$/.hpp/;s/${apilc}/script/"`
- if [ ! -f ../../script/api/${f} ];then
+ f=`echo ${f} | sed "s/.hpp.sq$/.hpp/;s@${apilc}_@script_@"`
+ if [ ! -f ../${f} ];then
echo "Deleted: ${f}.sq"
svn del --force ${f}.sq > /dev/null 2>&1
fi
done
+if [ "$apilc" = "template" ]; then exit 0; fi
+
# Add stuff to ${apilc}_instance.cpp
-f="../${apilc}_instance.cpp"
+f="../../../${apilc}/${apilc}_instance.cpp"
functions=``
echo "
{ }
/.hpp.sq/ { next }
-/squirrel_register_std/ { next }
/SQ${apiuc}Controller_Register/ { print \$0; next }
/SQ${apiuc}.*_Register/ { next }
@@ -96,7 +115,7 @@ echo "
split(\"`grep '^void SQ'${apiuc}'.*_Register(Squirrel \*engine)$' *.hpp.sq | sed 's/:.*$//' | sort | uniq | tr -d '\r' | tr '\n' ' '`\", files, \" \")
for (i = 1; files[i] != \"\"; i++) {
- print \"#include \\\"api/\" files[i] \"\\\"\" \$0
+ print \"#include \\\"../script/api/${apilc}/\" files[i] \"\\\"\" \$0
}
next;