1#!/bin/sh - 2# $Id: s_java_swig,v 12.6 2006/09/08 20:28:44 bostic Exp $ 3# 4# Run SWIG to generate the Java APIs 5 6t=/tmp/__db_a 7trap 'rm -f $t ; exit 0' 0 8trap 'rm -f $t ; exit 1' 1 2 3 13 15 9 10SWIG=swig 11SWIG_DIR=../libdb_java 12SWIG_FILE=$SWIG_DIR/db.i 13PACKAGE="com.sleepycat.db.internal" 14 15die() { 16 echo "$@" >&2 17 exit 1 18} 19 20[ -f $SWIG_FILE ] || die "Must be run from the dist directory" 21 22for api in java ; do 23 echo "Building $api API" 24 25 swig_args="" 26 case $api in 27 java) 28 swig_args="-nodefaultctor -nodefaultdtor -package $PACKAGE $args" 29 ;; 30 esac 31 32 $SWIG -Wall -$api $swig_args -I$SWIG_DIR \ 33 -o ../libdb_$api/db_${api}_wrap.c $SWIG_FILE || exit $? 34done 35 36# Skip Java sources if run with "-n" 37if [ "x$1" = "x-n" ] ; then 38 rm -f $SWIG_DIR/*.java 39 exit 0 40fi 41 42# Fixups for Java 43JAVA_SRCTOP=../java/src 44JAVA_PKGDIR=com/sleepycat/db/internal 45JAVA_SRCDIR=$JAVA_SRCTOP/$JAVA_PKGDIR 46 47# SWIG 1.3.18 puts the Java files in the same directory as the native code. 48cd $SWIG_DIR 49[ -f Db.java ] || exit 1 50 51for f in *.java ; do 52 case $f in 53 SWIGTYPE*) 54 die "Interface contains unresolved types: $f" 55 esac 56 rm -f $JAVA_SRCDIR/$f 57 perl -p $SWIG_DIR/java-post.pl < $f > $JAVA_SRCDIR/$f || exit $? 58 rm -f $f 59done 60 61# db_config.h must be the first #include, move it to the top of the file. 62( 63 echo '#include "db_config.h"' 64 sed '/#include "db_config.h"/d' < db_java_wrap.c 65) > $t && cp $t db_java_wrap.c 66 67# The following might become redundant with newer swig versions. 68# builds usually already define _CRT_SECURE_NO_DEPRECATE 69( 70 sed -e '/# define _CRT_SECURE_NO_DEPRECATE/i\ 71# undef _CRT_SECURE_NO_DEPRECATE' < db_java_wrap.c 72) > $t && cp $t db_java_wrap.c 73 74