FreeCalypso > hg > tcs211-fcmodem
diff g23m/system/busyb/tools/cfg_gen.pl @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/g23m/system/busyb/tools/cfg_gen.pl Mon Jun 01 03:24:05 2015 +0000 @@ -0,0 +1,47 @@ +my $cfg_dir=$ARGV[0]; +my $cfg_string= $cfg_file ; +my $guard_string; +my @files; + +shift; + +foreach $define (@ARGV) +{ + $define =~ /^(CFG_)?(.*?)_/; + my $file = $2; + if (! grep /$file/, @files) + { + push @files, $file; + } +} + +foreach $file (sort @files) +{ + my $cfg_string = "\L$file"; + my $cfg_file = "$cfg_dir/$cfg_string.cfg"; + + my $guard_string = "\U__${file}_CFG__"; + + # open the file + open (CFG,">$cfg_file")||die "can't open $cfg_file \n"; + + # print guard pattern + print CFG "#ifndef $guard_string\n"; + print CFG "#define $guard_string\n"; + + foreach (sort @ARGV) + { + if (/^(CFG_)?($file)_(.*?)=(.*)/) + { + print CFG "#define $3 $4\n"; + } + } + + # end guard pattern + print CFG "#endif /* $guard_string */ \n"; + + # close the file + close CFG; +} + +