Friday, December 12, 2008

A sample to employ "epocrc" for automatic resource file creation

Example of using "epocrc" from SDK 3rd Edition FP1

> epocrc -I\symbian\epoc32\include\ -u ex.rss -oex.rsc -hex.rsg

What we want to do here is to generate any "oemid" any time when requested without recompiling the whole resources.

In the example, I have default setting of oemid 1000 and I will replace 1000 with any new id for the resource file which passed to the makeResource function, whereas the output has the same name appended with its new id.

sub makeResource {

my $baseRssFile = "oempid_0x2000AAAA";

chdir($rssPath);

my $pid = $_[0];
my $rssFile = $baseRssFile . ".rss";
my $newRssFile = $baseRssFile . "_" . $pid . ".rss";
open(RSSFILE, $rssFile) or die "Error: Cannot open $1 : $!\n";

my @file = ;
close(RSSFILE);

open(NEWRSSFILE, ">$newRssFile") or die "Error: Cannot open $1 : $!\n";
foreach $_ (@file) {
if ( $_ =~ m/1000/ && $_ =~ /buf/) {
$_ =~ s/1000/$pid/g;

}
print NEWRSSFILE $_;
}
close(NEWRSSFILE);

my $rscFile = $baseRssFile . "_" . $pid . ".rsc";
system("epocrc -I$symbPath -u $newRssFile -o$rscFile");
system("del $newRssFile");
print "$rscFile is done\n";
}

The following part is to read the arguments which may be passed as range of integer or non range integer seperated each entries by comma.

my @num = split(/,/, $args{i});

foreach $_ (@num) { // Input may look like 1,4,7-10,200
my $pid = "";
if ( $_ =~ /(.+)-(.+)/ ) { //search if the input is in range
foreach( $1 .. $2 ) {
&makeResource( $_ );
}
}

else { // non-range argument
&makeResource( $_ );
}

---------------------------