cannam@86
|
1 #!/usr/bin/perl
|
cannam@86
|
2
|
cannam@86
|
3 # quick, very dirty little script so that we can put all the
|
cannam@86
|
4 # information for building a floor book set in one spec file.
|
cannam@86
|
5
|
cannam@86
|
6 #eg:
|
cannam@86
|
7
|
cannam@86
|
8 # >floor_44
|
cannam@86
|
9 # =44c0_s 44c1_s 44c2_s
|
cannam@86
|
10 # build line_128x4_class0 0-256
|
cannam@86
|
11 # build line_128x4_0sub0 0-4
|
cannam@86
|
12
|
cannam@86
|
13 die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]);
|
cannam@86
|
14
|
cannam@86
|
15 $goflag=0;
|
cannam@86
|
16 while($line=<F>){
|
cannam@86
|
17
|
cannam@86
|
18 print "#### $line";
|
cannam@86
|
19 if($line=~m/^GO/){
|
cannam@86
|
20 $goflag=1;
|
cannam@86
|
21 next;
|
cannam@86
|
22 }
|
cannam@86
|
23
|
cannam@86
|
24 if($goflag==0){
|
cannam@86
|
25 if($line=~m/\S+/ && !($line=~m/^\#/) ){
|
cannam@86
|
26 my $command=$line;
|
cannam@86
|
27 print ">>> $command";
|
cannam@86
|
28 die "Couldn't shell command.\n\tcommand:$command\n"
|
cannam@86
|
29 if syst($command);
|
cannam@86
|
30 }
|
cannam@86
|
31 next;
|
cannam@86
|
32 }
|
cannam@86
|
33
|
cannam@86
|
34 # >floor_44
|
cannam@86
|
35 # this sets the output bookset file name
|
cannam@86
|
36 if($line=~m/^>(\S+)\s+(\S*)/){
|
cannam@86
|
37 # set the output name
|
cannam@86
|
38 $globalname=$1;
|
cannam@86
|
39
|
cannam@86
|
40 $command="rm -f $globalname.vqh";
|
cannam@86
|
41 die "Couldn't remove file.\n\tcommand:$command\n"
|
cannam@86
|
42 if syst($command);
|
cannam@86
|
43
|
cannam@86
|
44 next;
|
cannam@86
|
45 }
|
cannam@86
|
46
|
cannam@86
|
47 #=path1 path2 path3
|
cannam@86
|
48 #set the search path for input files; each build line will look
|
cannam@86
|
49 #for input files in all of the directories in the search path and
|
cannam@86
|
50 #append them for huffbuild input
|
cannam@86
|
51 if($line=~m/^=(.*)/){
|
cannam@86
|
52 # set the output name
|
cannam@86
|
53 @paths=split(' ',$1);
|
cannam@86
|
54 next;
|
cannam@86
|
55 }
|
cannam@86
|
56
|
cannam@86
|
57 # build book.vqd 0-3 [noguard]
|
cannam@86
|
58 if($line=~m/^build (.*)/){
|
cannam@86
|
59 # build a huffman book (no mapping)
|
cannam@86
|
60 my($datafile,$range,$guard)=split(' ',$1);
|
cannam@86
|
61
|
cannam@86
|
62 $command="rm -f $datafile.tmp";
|
cannam@86
|
63 print "\n\n>>> $command\n";
|
cannam@86
|
64 die "Couldn't remove temp file.\n\tcommand:$command\n"
|
cannam@86
|
65 if syst($command);
|
cannam@86
|
66
|
cannam@86
|
67 # first find all the inputs we want; they'll need to be collected into a single input file
|
cannam@86
|
68 foreach $dir (@paths){
|
cannam@86
|
69 if (-e "$dir/$datafile.vqd"){
|
cannam@86
|
70 $command="cat $dir/$datafile.vqd >> $datafile.tmp";
|
cannam@86
|
71 print ">>> $command\n";
|
cannam@86
|
72 die "Couldn't append training data.\n\tcommand:$command\n"
|
cannam@86
|
73 if syst($command);
|
cannam@86
|
74 }
|
cannam@86
|
75 }
|
cannam@86
|
76
|
cannam@86
|
77 my $command="huffbuild $datafile.tmp $range $guard";
|
cannam@86
|
78 print ">>> $command\n";
|
cannam@86
|
79 die "Couldn't build huffbook.\n\tcommand:$command\n"
|
cannam@86
|
80 if syst($command);
|
cannam@86
|
81
|
cannam@86
|
82 $command="cat $datafile.vqh >> $globalname.vqh";
|
cannam@86
|
83 print ">>> $command\n";
|
cannam@86
|
84 die "Couldn't append to output book.\n\tcommand:$command\n"
|
cannam@86
|
85 if syst($command);
|
cannam@86
|
86
|
cannam@86
|
87 $command="rm $datafile.vqh";
|
cannam@86
|
88 print ">>> $command\n";
|
cannam@86
|
89 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
|
cannam@86
|
90 if syst($command);
|
cannam@86
|
91
|
cannam@86
|
92 $command="rm -f $datafile.tmp";
|
cannam@86
|
93 print ">>> $command\n";
|
cannam@86
|
94 die "Couldn't remove temporary output file.\n\tcommand:$command\n"
|
cannam@86
|
95 if syst($command);
|
cannam@86
|
96 next;
|
cannam@86
|
97 }
|
cannam@86
|
98
|
cannam@86
|
99 }
|
cannam@86
|
100
|
cannam@86
|
101 $command="rm -f temp$$.vqd";
|
cannam@86
|
102 print ">>> $command\n";
|
cannam@86
|
103 die "Couldn't remove temp files.\n\tcommand:$command\n"
|
cannam@86
|
104 if syst($command);
|
cannam@86
|
105
|
cannam@86
|
106 sub syst{
|
cannam@86
|
107 system(@_)/256;
|
cannam@86
|
108 }
|