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