summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-12-07 14:22:56 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2012-12-07 14:22:56 +0100
commite8f12bfd6d9fa3e813c3f8d4f6102a6b1c7037ab (patch)
treeacaf650957f7c3d453602df8273689854d57c190
parentd64294639375cd5758cd7abe090348d62e5d9ca7 (diff)
Work with c files.
-rwxr-xr-xadd_file34
1 files changed, 34 insertions, 0 deletions
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