#!/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=../lang/csharp/libdb_csharp SWIG_FILE=$SWIG_DIR/db.i NAMESPACE="BerkeleyDB.Internal" CSHARP_SRCDIR=../lang/csharp/src/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 ../lang/csharp/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 664 $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