* Print from a template for the C struct definition code generator as well

* Add a template for the struct definition header; adds some #include directives required to be able to compile the generated header


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5435 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-07-09 13:57:26 +00:00
parent 2d1b9d8694
commit 707d5cf718
3 changed files with 28 additions and 2 deletions

View File

@ -9,8 +9,8 @@ all: $(C_SOURCES) $(C_HEADERS) $(SQL_TABLES)
%.c: %.tpl.sql.c %.tpl
./db-lang.pl c_sqliteload $^ > $@
%.h: %.tpl
./db-lang.pl c_structdef $< > $@
%.h: %.tpl.struct.h %.tpl
./db-lang.pl c_structdef $^ > $@
%.sql: %.tpl
./db-lang.pl sql_tabledef $< > $@

View File

@ -193,8 +193,13 @@ sub printHdrGuard
$$output .= "__INCLUDED_DB_TEMPLATE_SCHEMA_STRUCTDEF_${name}_H__";
}
my $startTpl = "";
sub processCmdLine()
{
my ($argv) = @_;
$startTpl = shift(@$argv) if @$argv > 1;
}
sub startFile()
@ -210,6 +215,26 @@ sub startFile()
$$output .= "#define ";
printHdrGuard($output, $name);
$$output .= "\n\n";
# Replace the extension with ".h" so that we can use it to #include the header
my $header = $name;
$header =~ s/\.[^.]*$/.h/;
$$output .= "#line 1 \"$startTpl\"\n";
open (TEMPL, $startTpl);
while (<TEMPL>)
{
s/\$name\b/$name/g;
s/\$header\b/$header/g;
$$output .= $_;
}
close (TEMPL);
my $count = $$output =~ s/\n/\n/sg;
$count += 2;
$$output .= "#line $count \"$header\"\n";
$$output .= "\n";
}
sub endFile()

View File

@ -0,0 +1 @@
#include "lib/ivis_common/ivisdef.h"