comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:509db1a7b7b8
1 my $cfg_dir=$ARGV[0];
2 my $cfg_string= $cfg_file ;
3 my $guard_string;
4 my @files;
5
6 shift;
7
8 foreach $define (@ARGV)
9 {
10 $define =~ /^(CFG_)?(.*?)_/;
11 my $file = $2;
12 if (! grep /$file/, @files)
13 {
14 push @files, $file;
15 }
16 }
17
18 foreach $file (sort @files)
19 {
20 my $cfg_string = "\L$file";
21 my $cfg_file = "$cfg_dir/$cfg_string.cfg";
22
23 my $guard_string = "\U__${file}_CFG__";
24
25 # open the file
26 open (CFG,">$cfg_file")||die "can't open $cfg_file \n";
27
28 # print guard pattern
29 print CFG "#ifndef $guard_string\n";
30 print CFG "#define $guard_string\n";
31
32 foreach (sort @ARGV)
33 {
34 if (/^(CFG_)?($file)_(.*?)=(.*)/)
35 {
36 print CFG "#define $3 $4\n";
37 }
38 }
39
40 # end guard pattern
41 print CFG "#endif /* $guard_string */ \n";
42
43 # close the file
44 close CFG;
45 }
46
47