diff options
Diffstat (limited to 'db-4.8.30/dist/s_csharp_swig')
-rw-r--r-- | db-4.8.30/dist/s_csharp_swig | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/db-4.8.30/dist/s_csharp_swig b/db-4.8.30/dist/s_csharp_swig new file mode 100644 index 0000000..de52c87 --- /dev/null +++ b/db-4.8.30/dist/s_csharp_swig @@ -0,0 +1,59 @@ +#!/bin/sh - +# $Id$ +# +# Run SWIG to generate the C# APIs + +t=/tmp/__db_a +trap 'rm -f $t ; exit 0' 0 +trap 'rm -f $t ; exit 1' 1 2 3 13 15 + +SWIG=swig +SWIG_DIR=../libdb_csharp +SWIG_FILE=$SWIG_DIR/db.i + +NAMESPACE="BerkeleyDB.Internal" +CSHARP_SRCDIR=../csharp/Internal + +die() { + echo "$@" >&2 + exit 1 +} + +[ -f $SWIG_FILE ] || die "Must be run from the dist directory" +DIST_DIR=`pwd` + +for api in csharp ; do + echo "Building $api API" + swig_args="-outdir $CSHARP_SRCDIR -namespace $NAMESPACE -dllimport libname -DSWIG_CSHARP_NO_EXCEPTION_HELPER $args" + + $SWIG -Wall -$api $swig_args -I$SWIG_DIR \ + -o ../libdb_$api/db_${api}_wrap.c $SWIG_FILE || exit $? +done + +cd $CSHARP_SRCDIR +[ -f DB.cs ] || exit 1 + +for f in *.cs ; do + # SWIG v1.3 always puts quotes around the imported DLL name. We're using a + # constant, not a string, because the DLL name changes based on Visual + # Studio's configuration. Use sed to remove the quotes. + chmod 666 $f + sed 's/DllImport(\"libname\"/DllImport(libname/' < $f > $t + cp $t $f +done + +cd $DIST_DIR + +cd $SWIG_DIR +# db_config.h must be the first #include, move it to the top of the file. +( + echo '#include "db_config.h"' + sed '/#include "db_config.h"/d' < db_csharp_wrap.c +) > $t && cp $t db_csharp_wrap.c + +# The following might become redundant with newer swig versions. +# builds usually already define _CRT_SECURE_NO_DEPRECATE +( + sed -e '/# define _CRT_SECURE_NO_DEPRECATE/i\ +# undef _CRT_SECURE_NO_DEPRECATE' < db_csharp_wrap.c +) > $t && cp $t db_csharp_wrap.c |