# HG changeset patch # User Timo Sirainen # Date 1269540232 -7200 # Node ID b218d4ec69962b4bfff898964a8a90765a8112a9 # Parent 93be85bb9db8f3cf3acf330c2589192479cd1a62 config: Parser script now supports preserving #ifdefs around service_settings. diff -r 93be85bb9db8 -r b218d4ec6996 src/config/settings-get.pl --- a/src/config/settings-get.pl Thu Mar 25 19:28:56 2010 +0200 +++ b/src/config/settings-get.pl Thu Mar 25 20:03:52 2010 +0200 @@ -13,6 +13,7 @@ print 'extern buffer_t config_all_services_buf;'; my @services = (); +my @service_ifdefs = (); my %parsers = {}; foreach my $file (@ARGV) { @@ -25,6 +26,8 @@ my $code = ""; my %funcs; my $cur_name = ""; + my $ifdef = ""; + my $state_ifdef = 0; while (<$f>) { my $write = 0; @@ -35,7 +38,14 @@ $state++; } elsif (/^struct service_settings (.*) = {/) { $state++; + if ($ifdef eq "") { + $state_ifdef = 0; + } else { + $_ = $ifdef."\n".$_; + $state_ifdef = 1; + } push @services, $1; + push @service_ifdefs, $ifdef; } elsif (/^(static )?const struct setting_parser_info (.*) = {/) { $cur_name = $2; $state++ if ($cur_name !~ /^\*default_/); @@ -45,7 +55,13 @@ $state = 4; $code .= $_; } - + + if (/(^#ifdef .*)$/ || /^(#if .*)$/) { + $ifdef = $1; + } else { + $ifdef = ""; + } + if (/#define.*DEF/ || /^#undef.*DEF/ || /ARRAY_DEFINE_TYPE.*_settings/) { $write = 1; $state = 2 if (/\\$/); @@ -83,6 +99,10 @@ $write = 1; if (/};/) { $state = 0; + if ($state_ifdef) { + $_ .= "#endif\n"; + $state_ifdef = 0; + } } } @@ -99,8 +119,13 @@ print "static struct service_settings *config_all_services[] = {\n"; -foreach my $name (@services) { - print "\t&$name,\n"; +for (my $i = 0; $i < scalar(@services); $i++) { + my $ifdef = $service_ifdefs[$i]; + print "$ifdef\n" if ($ifdef ne ""); + print "\t"; + print "," if ($i > 0); + print "&".$services[$i]."\n"; + print "#endif\n" if ($ifdef ne ""); } print "};\n"; print "buffer_t config_all_services_buf = {\n";