make_floor_books.pl 2.5 KB

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