summaryrefslogtreecommitdiffstats
path: root/build-aux/xdrgen
diff options
context:
space:
mode:
authorHarshavardhana <harsha@harshavardhana.net>2014-04-22 13:27:35 -0700
committerAnand Avati <avati@redhat.com>2014-04-25 13:29:25 -0700
commit9819fcedf10f1430d4969c86e6df4dfe975b7dcf (patch)
treea4ce5b4d8e5666fe6dd66147b5a360670bf51363 /build-aux/xdrgen
parent40675af8b4a1a90331e353295c75c0ea63457cf6 (diff)
rpcgen: Remove autogenerated files instead build on demand
Avoid modifying autogenerated files and keeping them in repository - autogenerate them on demand from ".x" files Change-Id: I2cdb1fe9b99768ceb80a8cb100fa00bd1d8fe2c6 BUG: 1090807 Signed-off-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-on: http://review.gluster.org/7526 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'build-aux/xdrgen')
-rwxr-xr-xbuild-aux/xdrgen93
1 files changed, 93 insertions, 0 deletions
diff --git a/build-aux/xdrgen b/build-aux/xdrgen
new file mode 100755
index 00000000000..dd5571baad6
--- /dev/null
+++ b/build-aux/xdrgen
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+_init ()
+{
+ xfile="$1";
+
+ cfile="${1%.x}.c";
+ hfile="${1%.x}.h";
+
+ tmp_cfile="$1.c";
+
+ tmp1_hfile="$1.h.tmp";
+ tmp1_cfile="$1.c.tmp";
+
+}
+
+append_licence_header ()
+{
+ src_file=$1;
+ dst_file=$2;
+
+ cat >$dst_file <<EOF
+/*
+ Copyright (c) 2007-2014 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+#include "compat.h"
+#include "xdr-common.h"
+#include "xdr-nfs3.h"
+
+#if defined(__GNUC__)
+#if __GNUC__ >= 4
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#endif
+#endif
+
+EOF
+
+ cat $src_file >> $dst_file;
+
+}
+
+main ()
+{
+ if [ $# -ne 1 ]; then
+ echo "wrong number of arguments given"
+ echo " $0 <XDR-definition-file>.x"
+ exit 1;
+ fi
+
+
+ echo -n "writing the XDR routine file ($tmp_cfile) ... ";
+ rm -f $tmp_cfile;
+ rpcgen -c -o $tmp_cfile $xfile;
+
+ echo "OK";
+
+ # no need for a temporary file here as there are no changes from glusterfs
+ echo -n "writing the XDR header file ($hfile) ... ";
+ rm -f $hfile;
+ rpcgen -h -o $hfile $xfile;
+
+ # the '#ifdef' part of file should be fixed
+ sed -i -e 's/-/_/g' $hfile;
+
+ echo "OK";
+
+ echo -n "writing licence header to the generated files ... ";
+ # Write header to temp file and append generated file
+ append_licence_header $hfile $tmp1_hfile;
+ append_licence_header $tmp_cfile $tmp1_cfile;
+ echo "OK"
+
+ # now move the destination file to actual original file
+ echo -n "updating existing files ... ";
+ mv $tmp1_hfile $hfile;
+ mv $tmp1_cfile $cfile;
+
+ # remove unwanted temporary files (if any)
+ rm -f $tmp_cfile $tmp1_cfile $tmp1_hfile
+
+ echo "OK"
+
+}
+
+_init "$@" && main "$@";