From e8f12bfd6d9fa3e813c3f8d4f6102a6b1c7037ab Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 7 Dec 2012 14:22:56 +0100 Subject: Work with c files. --- add_file | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/add_file b/add_file index c5d5b29..83ba8a0 100755 --- a/add_file +++ b/add_file @@ -83,6 +83,36 @@ function ccfile() { echo "#endif/*TEST_${hn}*/" >> $1; } +function cfile() { + local hf=`echo -n $1 | cut -d'.' -f1`.h; + hfile $hf; + + allfile $1; + echo -n '#include "' >> $1; + echo -n $hf >> $1; + echo '"' >> $1; + echo '' >> $1; + + local hn=`echo $1 | cut -d'.' -f1 | tr 'a-z.' 'A-Z_'` + echo "#ifdef TEST_${hn}" >> $1; + echo "//Additional dependency files" >> $1; + echo "//deps:" >> $1; + echo "//Required cflags (autoconf vars may be used)" >> $1; + echo "//cflags:" >> $1; + echo "//Required link options (autoconf vars may be used)" >> $1; + echo "//libs:" >> $1; + echo "#include \"test.h\"" >> $1; + echo "" >> $1; + echo "TEST_BEGIN;" >> $1; + echo "" >> $1; + echo "// TODO: Put some testcode here (see test.h for usable macros)." >> $1; + echo "TEST_TRUE(false, \"No tests yet!\");" >> $1; + echo "" >> $1; + echo "TEST_END;" >> $1; + echo "" >> $1; + echo "#endif/*TEST_${hn}*/" >> $1; +} + function hfile() { allfile $1; local hn=`echo $1 | tr 'a-z.' 'A-Z_'` @@ -93,6 +123,9 @@ function hfile() { } if [ "$#" = "1" ]; then +if [ "C" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then + cfile $1; +fi; if [ "CC" = `echo $1 | cut -d'.' -f2 | tr 'a-z' 'A-Z'` ]; then ccfile $1; fi; @@ -103,6 +136,7 @@ else echo "Usage: $0 filename"; echo echo "Examples:"; + echo "$0 myclass.c Which will produce both myclass.c and myclass.h"; echo "$0 myclass.cc Which will produce both myclass.cc and myclass.h"; echo "$0 myinterface.h Which will only produce myinterface.h"; echo -- cgit v1.2.3