Skip to content

Commit

Permalink
Add DSC comments to non-packaged resource.
Browse files Browse the repository at this point in the history
  • Loading branch information
terryburton committed Jan 19, 2014
1 parent 757b765 commit 74f84d6
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ $(MONOLITHIC_MKDIRSTAMP):
mkdir -p $(MONOLITHIC_MKDIRS)
touch $@

$(MONOLITHIC_FILE): $(SOURCES) $(SRCDIR)/ps.head $(VERSION_FILE) $(UPR_FILE) $(MONOLITHIC_MKDIRSTAMP)
$(DSTDIR)/make_monolithic >$@
$(MONOLITHIC_FILE): $(TARGETS_RES) $(SRCDIR)/ps.head $(VERSION_FILE) $(UPR_FILE) $(MONOLITHIC_MKDIRSTAMP)
$(DSTDIR)/make_monolithic $(RESDIR)/Resource >$@
$(MONOLITHIC_FILE_WITH_SAMPLE): $(MONOLITHIC_FILE) $(SRCDIR)/sample $(MONOLITHIC_MKDIRSTAMP)
cat $(MONOLITHIC_FILE) $(SRCDIR)/sample > $@
$(MONOLITHIC_DIR)/README: $(SRCDIR)/README.monolithic $(MONOLITHIC_MKDIRSTAMP)
Expand Down
28 changes: 13 additions & 15 deletions build/make_monolithic
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,24 @@ while ($upr=~/^(.*)=(.*)$/mg) {
my $src=join('',<SRC>);
close(SRC);

(my $begin, $_, $_, my $meta, my $body, my $end)=$src=~/
(my $begin, $_, $_, my $meta, my $end)=$src=~/
(^%\ --BEGIN\ (ENCODER|RENDERER|RESOURCE)\ ([\w-]+?)--$)
(.*?)
(^[^%].*?)
^[^%].*?
(^%\ --END\ \2\ \3--$)
/msgx;

if ($resourcedir ne '') {
open(RES,$resfile) || die "Unable to open resource file: $resfile";
my $res=join('',<RES>);
close(RES);
$res=~/
(^%%BeginResource:\ [\w\.]+\ [\w\.-]+?\ .*?$)
.*
(^%%BeginData:.*?$
.*
^%%EndResource$)
/msgx;
$body="$1\n$2\n";
}
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;
Expand Down
5 changes: 4 additions & 1 deletion build/make_packaged_resource
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

use strict;
use File::Temp;
use File::Basename;

my $abspath=`pwd`;
chomp $abspath;

my $scriptname=basename($0);

my $infile=$ARGV[0];
my $outfile=$ARGV[1];

Expand Down Expand Up @@ -61,7 +64,7 @@ my $vmusagefile=mktemp('/tmp/vmusage.XXXXXX');
(my $yyyy, my $mm, my $dd, $_, my $rr)=$version=~/^(\d{4})-(\d{2})-(\d{2})(-(\d{1,2}))?$/ or die 'Malformed version';
my $qualifier="0.0 $yyyy$mm$dd".sprintf("%02d",$rr||0);

print `cd build/packaged_resource/Resource && gs -P -dQUIET -dNOPAUSE -dBATCH -sDEVICE=nullpage -sInputFilename='$abspath/$outfile.tmp' -sOutputFilename='$abspath/$outfile' -sVMusageFilename='$vmusagefile' -sCategory='$category' -sKey='$key' -sVMusage='$vmusage' -sQualifier='$qualifier' -sVersion='$version' -sNeededResources='$neededresources' -sPostWatermark='$category/$key $qualifier' -- ../../make_packaged_resource.ps`;
print `cd build/resource/Resource && gs -P -dQUIET -dNOPAUSE -dBATCH -sDEVICE=nullpage -sInputFilename='$abspath/$outfile.tmp' -sOutputFilename='$abspath/$outfile' -sVMusageFilename='$vmusagefile' -sCategory='$category' -sKey='$key' -sVMusage='$vmusage' -sQualifier='$qualifier' -sVersion='$version' -sNeededResources='$neededresources' -sPostWatermark='$category/$key $qualifier' -- ../../$scriptname.ps`;
die 'GS create resource error' if $?;
unlink("$outfile.tmp");

Expand Down
69 changes: 59 additions & 10 deletions build/make_resource
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
# $Id$

use strict;
use File::Temp;
use File::Basename;

my $abspath=`pwd`;
chomp $abspath;

my $scriptname=basename($0);

my $infile=$ARGV[0];
my $outfile=$ARGV[1];

open(PS,$infile) || die "File not found: $infile";
my $template=join('',<PS>);
close(PS);

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/;
open(PS,$infile) || die "File not found: $infile";
my $template=join('',<PS>);
close(PS);

$template=~/
^%\ --BEGIN\ (ENCODER|RENDERER|RESOURCE)\ ([\w-]+?)--$
Expand All @@ -28,10 +30,57 @@ $template=~/
^%\ --END\ \1\ \2--$
/msgx;

my $resource=$2;
my $meta=$3;
my $body=$4;

open(PS,">$outfile") || die "Failed to write $outfile";
print PS $head;
(my $reqs)=$meta=~/^% --REQUIRES (.*)--$/mg;
$reqs='' unless defined $reqs;

my $neededresources='';
foreach (split /\s+/, $reqs) {
if ($_ eq 'preamble') {
$neededresources.="Category/uk.co.terryburton.bwipp ";
} else {
$neededresources.="uk.co.terryburton.bwipp/$_ ";
}
}
$neededresources=~s/\s+$//;

open(PS,">$outfile.tmp") || die "Failed to write $outfile";
print PS $body;
close(PS);

my $category='uk.co.terryburton.bwipp';
my $key=$resource;
if ($resource eq 'preamble') {
$category='Category';
$key='uk.co.terryburton.bwipp';
}

my $vmusage='0 0';
my $vmusagefile=mktemp('/tmp/vmusage.XXXXXX');

(my $yyyy, my $mm, my $dd, $_, my $rr)=$version=~/^(\d{4})-(\d{2})-(\d{2})(-(\d{1,2}))?$/ or die 'Malformed version';
my $qualifier="0.0 $yyyy$mm$dd".sprintf("%02d",$rr||0);

print `cd build/resource/Resource && gs -P -dQUIET -dNOPAUSE -dBATCH -sDEVICE=nullpage -sInputFilename='$abspath/$outfile.tmp' -sOutputFilename='$abspath/$outfile' -sVMusageFilename='$vmusagefile' -sCategory='$category' -sKey='$key' -sVMusage='$vmusage' -sQualifier='$qualifier' -sVersion='$version' -sNeededResources='$neededresources' -sPostWatermark='$category/$key $qualifier' -- ../../$scriptname.ps`;
die 'GS create resource error' if $?;
unlink("$outfile.tmp");

my $vmout=`gs -dQUIET -dNOPAUSE -dBATCH -sDEVICE=nullpage -- $vmusagefile`;
die 'GS measure VMusage error' if $?;
($vmusage)=$vmout=~/VMusage \((\d+ \d+)\) def/ or die 'Failed to determine VMusage';
unlink($vmusagefile);

# Stamp VMusage into the resource
{
$^I='';
@ARGV=($outfile);
while (<>) {
s/%%VMusage: \d+ \d+/%%VMusage: $vmusage/g;
s/%%BeginResource: (.*) \d+ \d+/%%BeginResource: $1 $vmusage/g;
print;
}
}

Binary file added build/make_resource.ps
Binary file not shown.

0 comments on commit 74f84d6

Please sign in to comment.