| 1 |
#!/bin/sh - |
| 2 |
# $Id$ |
| 3 |
# |
| 4 |
# Run SWIG to generate the C# APIs |
| 5 |
|
| 6 |
t=/tmp/__db_a |
| 7 |
trap 'rm -f $t ; exit 0' 0 |
| 8 |
trap 'rm -f $t ; exit 1' 1 2 3 13 15 |
| 9 |
|
| 10 |
SWIG=swig |
| 11 |
SWIG_DIR=../lang/csharp/libdb_csharp |
| 12 |
SWIG_FILE=$SWIG_DIR/db.i |
| 13 |
|
| 14 |
NAMESPACE="BerkeleyDB.Internal" |
| 15 |
CSHARP_SRCDIR=../lang/csharp/src/Internal |
| 16 |
|
| 17 |
die() { |
| 18 |
echo "$@" >&2 |
| 19 |
exit 1 |
| 20 |
} |
| 21 |
|
| 22 |
[ -f $SWIG_FILE ] || die "Must be run from the dist directory" |
| 23 |
DIST_DIR=`pwd` |
| 24 |
|
| 25 |
for api in csharp ; do |
| 26 |
echo "Building $api API" |
| 27 |
swig_args="-outdir $CSHARP_SRCDIR -namespace $NAMESPACE -dllimport libname -DSWIG_CSHARP_NO_EXCEPTION_HELPER $args" |
| 28 |
|
| 29 |
$SWIG -Wall -$api $swig_args -I$SWIG_DIR \ |
| 30 |
-o ../lang/csharp/libdb_$api/db_${api}_wrap.c $SWIG_FILE || exit $? |
| 31 |
done |
| 32 |
|
| 33 |
cd $CSHARP_SRCDIR |
| 34 |
[ -f DB.cs ] || exit 1 |
| 35 |
|
| 36 |
for f in *.cs ; do |
| 37 |
# SWIG v1.3 always puts quotes around the imported DLL name. We're using a |
| 38 |
# constant, not a string, because the DLL name changes based on Visual |
| 39 |
# Studio's configuration. Use sed to remove the quotes. |
| 40 |
chmod 664 $f |
| 41 |
sed 's/DllImport(\"libname\"/DllImport(libname/' < $f > $t |
| 42 |
cp $t $f |
| 43 |
done |
| 44 |
|
| 45 |
cd $DIST_DIR |
| 46 |
|
| 47 |
cd $SWIG_DIR |
| 48 |
# db_config.h must be the first #include, move it to the top of the file. |
| 49 |
( |
| 50 |
echo '#include "db_config.h"' |
| 51 |
sed '/#include "db_config.h"/d' < db_csharp_wrap.c |
| 52 |
) > $t && cp $t db_csharp_wrap.c |
| 53 |
|
| 54 |
# The following might become redundant with newer swig versions. |
| 55 |
# builds usually already define _CRT_SECURE_NO_DEPRECATE |
| 56 |
( |
| 57 |
sed -e '/# define _CRT_SECURE_NO_DEPRECATE/i\ |
| 58 |
# undef _CRT_SECURE_NO_DEPRECATE' < db_csharp_wrap.c |
| 59 |
) > $t && cp $t db_csharp_wrap.c |