1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#!/usr/bin/perl -Tw
# $Id$
use strict;
my $resourcedir=$ARGV[0] || '';
open(UPR,'src/uk.co.terryburton.bwipp.upr') || die 'Unable to open UPR file';
my $upr=join('',<UPR>);
close(UPR);
open(VER,'src/VERSION') || die 'Unable to open VERSION';
my $version=join('',<VER>);
close VER;
chomp $version;
open(HEAD,'src/ps.head') || die 'Unable to open ps.head';
my $head=join('',<HEAD>);
close HEAD;
$head=~s/XXXX-XX-XX/$version/;
print $head;
print "% --BEGIN TEMPLATE--\n\n";
while ($upr=~/^(.*)=(.*)$/mg) {
my $srcfile="src/$1.ps";
$srcfile='src/preamble.ps' if $1 eq 'uk.co.terryburton.bwipp';
my $resfile="$resourcedir/$2";
open(SRC,$srcfile) || die "Unable to open source file: $srcfile";
my $src=join('',<SRC>);
close(SRC);
(my $begin, $_, $_, my $meta, my $end)=$src=~/
(^%\ --BEGIN\ (ENCODER|RENDERER|RESOURCE)\ ([\w-]+?)--$)
(.*?)
^[^%].*?
(^%\ --END\ \2\ \3--$)
/msgx;
open(RES,$resfile) || die "Unable to open resource file: $resfile";
my $res=join('',<RES>);
close(RES);
$res=~/
(^%%BeginResource:\ [\w\.]+\ [\w\.-]+?\ .*?$)
.*
(^%%BeginData:.*?$
.*
^%%EndResource$)
/msgx;
my $body="$1\n$2\n";
print $begin;
print $meta;
print $body;
print "$end\n\n";
}
print "% --END TEMPLATE--\n";
|