Home | History | Annotate | Line # | Download | only in test
rpcgen_wrapper.sh revision 1.1.1.1
      1  1.1  christos #!/bin/sh
      2  1.1  christos # libevent rpcgen_wrapper.sh
      3  1.1  christos # Transforms event_rpcgen.py failure into success for make, only if
      4  1.1  christos # regress.gen.c and regress.gen.h already exist in $srcdir.  This
      5  1.1  christos # is needed for "make distcheck" to pass the read-only $srcdir build,
      6  1.1  christos # as with read-only sources fresh from tarball, regress.gen.[ch] will
      7  1.1  christos # be correct in $srcdir but unwritable.  This previously triggered
      8  1.1  christos # Makefile.am to create stub regress.gen.c and regress.gen.h in the
      9  1.1  christos # distcheck _build directory, which were then detected as leftover
     10  1.1  christos # files in the build tree after distclean, breaking distcheck.
     11  1.1  christos # Note that regress.gen.[ch] are not in fresh git clones, making
     12  1.1  christos # working Python a requirement for make distcheck of a git tree.
     13  1.1  christos 
     14  1.1  christos exit_updated() {
     15  1.1  christos     echo "Updated ${srcdir}\regress.gen.c and ${srcdir}\regress.gen.h"
     16  1.1  christos     exit 0
     17  1.1  christos }
     18  1.1  christos 
     19  1.1  christos exit_reuse() {
     20  1.1  christos     echo "event_rpcgen.py failed, ${srcdir}\regress.gen.\[ch\] will be reused." >&2
     21  1.1  christos     exit 0
     22  1.1  christos }
     23  1.1  christos 
     24  1.1  christos exit_failed() {
     25  1.1  christos     echo "Could not generate regress.gen.\[ch\] using event_rpcgen.sh" >&2
     26  1.1  christos     exit 1
     27  1.1  christos }
     28  1.1  christos 
     29  1.1  christos if [ -x /usr/bin/python2 ] ; then
     30  1.1  christos   PYTHON2=/usr/bin/python2
     31  1.1  christos elif [ "x`which python2`" != x ] ; then
     32  1.1  christos   PYTHON2=python2
     33  1.1  christos else
     34  1.1  christos   PYTHON2=python
     35  1.1  christos fi
     36  1.1  christos 
     37  1.1  christos srcdir=$1
     38  1.1  christos srcdir=${srcdir:-.}
     39  1.1  christos ${PYTHON2} ${srcdir}/../event_rpcgen.py ${srcdir}/regress.rpc
     40  1.1  christos case "$?" in
     41  1.1  christos  0)
     42  1.1  christos     exit_updated
     43  1.1  christos     ;;
     44  1.1  christos  *)
     45  1.1  christos     test -r ${srcdir}/regress.gen.c -a -r ${srcdir}/regress.gen.h && \
     46  1.1  christos 	exit_reuse
     47  1.1  christos     exit_failed
     48  1.1  christos     ;;
     49  1.1  christos esac
     50