Chris@1: #!/usr/bin/perl Chris@1: Chris@1: # quick, very dirty little script so that we can put all the Chris@1: # information for building a floor book set in one spec file. Chris@1: Chris@1: #eg: Chris@1: Chris@1: # >floor_44 Chris@1: # =44c0_s 44c1_s 44c2_s Chris@1: # build line_128x4_class0 0-256 Chris@1: # build line_128x4_0sub0 0-4 Chris@1: Chris@1: die "Could not open $ARGV[0]: $!" unless open (F,$ARGV[0]); Chris@1: Chris@1: $goflag=0; Chris@1: while($line=){ Chris@1: Chris@1: print "#### $line"; Chris@1: if($line=~m/^GO/){ Chris@1: $goflag=1; Chris@1: next; Chris@1: } Chris@1: Chris@1: if($goflag==0){ Chris@1: if($line=~m/\S+/ && !($line=~m/^\#/) ){ Chris@1: my $command=$line; Chris@1: print ">>> $command"; Chris@1: die "Couldn't shell command.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: } Chris@1: next; Chris@1: } Chris@1: Chris@1: # >floor_44 Chris@1: # this sets the output bookset file name Chris@1: if($line=~m/^>(\S+)\s+(\S*)/){ Chris@1: # set the output name Chris@1: $globalname=$1; Chris@1: Chris@1: $command="rm -f $globalname.vqh"; Chris@1: die "Couldn't remove file.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: next; Chris@1: } Chris@1: Chris@1: #=path1 path2 path3 Chris@1: #set the search path for input files; each build line will look Chris@1: #for input files in all of the directories in the search path and Chris@1: #append them for huffbuild input Chris@1: if($line=~m/^=(.*)/){ Chris@1: # set the output name Chris@1: @paths=split(' ',$1); Chris@1: next; Chris@1: } Chris@1: Chris@1: # build book.vqd 0-3 [noguard] Chris@1: if($line=~m/^build (.*)/){ Chris@1: # build a huffman book (no mapping) Chris@1: my($datafile,$range,$guard)=split(' ',$1); Chris@1: Chris@1: $command="rm -f $datafile.tmp"; Chris@1: print "\n\n>>> $command\n"; Chris@1: die "Couldn't remove temp file.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: # first find all the inputs we want; they'll need to be collected into a single input file Chris@1: foreach $dir (@paths){ Chris@1: if (-e "$dir/$datafile.vqd"){ Chris@1: $command="cat $dir/$datafile.vqd >> $datafile.tmp"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't append training data.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: } Chris@1: } Chris@1: Chris@1: my $command="huffbuild $datafile.tmp $range $guard"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't build huffbook.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: $command="cat $datafile.vqh >> $globalname.vqh"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't append to output book.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: $command="rm $datafile.vqh"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't remove temporary output file.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: $command="rm -f $datafile.tmp"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't remove temporary output file.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: next; Chris@1: } Chris@1: Chris@1: } Chris@1: Chris@1: $command="rm -f temp$$.vqd"; Chris@1: print ">>> $command\n"; Chris@1: die "Couldn't remove temp files.\n\tcommand:$command\n" Chris@1: if syst($command); Chris@1: Chris@1: sub syst{ Chris@1: system(@_)/256; Chris@1: }