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