More updates to filter_obyfile.pl, now copes properly with aliases
Can remove bluetooth.dll (+ 2107 other files!) to give a ROM which still links but it clearly doomed.
Can remove FileList.dll (from gsprofilesrv, takes out 158 files).
--- a/syborg_stem/rom_content.csv Sun Oct 10 20:19:54 2010 +0100
+++ b/syborg_stem/rom_content.csv Sun Oct 10 22:36:56 2010 +0100
@@ -2903,7 +2903,7 @@
sys\bin\BlackWhite.pgn,/epoc32/release/armv5/urel/blackwhite.pgn,core/app/ImageEditorBlackWhitePlugin.iby,app/imgeditor,,,
sys\bin\Blid.exe,/epoc32/release/armv5/urel/blid.exe,core/app/blid.iby,app/location,,,
sys\bin\BlidEng.dll,/epoc32/release/armv5/urel/blideng.dll,core/app/blid.iby,app/location,,,
-sys\bin\bluetooth.dll,/epoc32/release/armv5/urel/bluetooth.dll,bluetooth.iby,os/bt,Out,WR,Stem should not contain bluetooth
+sys\bin\bluetooth.dll,/epoc32/release/armv5/urel/bluetooth.dll,bluetooth.iby,os/bt,,WR,Stem should not contain bluetooth - kills 2108 files!
sys\bin\bluetoothAV.dll,/epoc32/release/armv5/urel/bluetoothav.dll,bluetooth.iby,os/bt,,,
sys\bin\bmcustomization.dll,/epoc32/release/armv5/urel/bmcustomization.dll,core/app/bmcustomization.iby,app/phone,,,
sys\bin\BmpAnim.dll,/epoc32/release/armv5/urel/bmpanim.dll,bmpanim.iby,mw/classicui,,,
@@ -3608,7 +3608,7 @@
Sys\Bin\filecertstore.dll,/epoc32/release/armv5/urel/filecertstore.dll,filetokens.iby,os/security,,,
Sys\Bin\filedetailsplugin.dll,/epoc32/release/armv5/urel/filedetailsplugin.dll,core/app/filedetailsplugin.iby,app/videoplayer,,,
Sys\Bin\filekeystore.dll,/epoc32/release/armv5/urel/filekeystore.dll,filetokens.iby,os/security,,,
-sys\bin\FileList.dll,/epoc32/release/armv5/urel/filelist.dll,core/app/filelist.iby,mw/gsprofilesrv,,,
+sys\bin\FileList.dll,/epoc32/release/armv5/urel/filelist.dll,core/app/filelist.iby,mw/gsprofilesrv,Out,WR,Causes 158 files to be removed
sys\bin\FileManager.exe,/epoc32/release/armv5/urel/filemanager.exe,core/app/FileManager.iby,app/files,,,
Sys\Bin\filemanageraiwprovider.dll,/epoc32/release/armv5/urel/filemanageraiwprovider.dll,core/app/FileManager.iby,app/files,,,
sys\bin\filemanagerbkupengine.dll,/epoc32/release/armv5/urel/filemanagerbkupengine.dll,core/app/FileManager.iby,app/files,,,
--- a/tools/filter_obyfile.pl Sun Oct 10 20:19:54 2010 +0100
+++ b/tools/filter_obyfile.pl Sun Oct 10 22:36:56 2010 +0100
@@ -68,6 +68,8 @@
# read static dependencies file
my %exe_to_romfile;
+my %lc_romfiles;
+
my $line;
open STATIC_DEPENDENCIES, "<$static_dependencies_txt" or die ("Cannot read $static_dependencies_txt: $!\n");
while ($line = <STATIC_DEPENDENCIES>)
@@ -75,6 +77,9 @@
chomp $line;
last if ($line eq ""); # blank line between the two sections
my ($romfile, $hostfile, $stuff) = split /\t/, $line;
+
+ $lc_romfiles{lc $romfile} = $romfile;
+
if ($romfile =~ /^sys.bin.(.*)$/i)
{
my $exe = lc $1;
@@ -90,12 +95,45 @@
}
close STATIC_DEPENDENCIES;
+# Create static dependencies for aliases
+
+my @obylines = <>; # read the oby file
+
+foreach my $line (@obylines)
+ {
+ if ($line =~ /^\s*alias\s+(\S+)\s+(\S+)\s*$/)
+ {
+ my $romfile = $1;
+ my $newname = $2;
+
+ $romfile =~ s/^\\sys/sys/; # remove leading \, to match $romfile convention
+ next if (!defined $lc_romfiles{lc $romfile}); # aliases to non-executables
+ $romfile = $lc_romfiles{lc $romfile};
+
+ $newname =~ s/^\\sys/sys/; # remove leading \, to match $romfile convention
+ $lc_romfiles{lc $newname} = $newname;
+
+ if ($romfile =~ /^sys.bin.(\S+)$/i)
+ {
+ my $realexe = lc $1;
+ push @{$exe_dependencies{$realexe}}, $newname; # the alias is a dependent of the real file
+ # print STDERR "added $newname as a dependent of $realexe\n"
+ }
+ }
+ }
+
+# foreach my $exe ("libopenvg.dll", "libopenvg_sw.dll")
+# {
+# printf STDERR "Dependents of %s = %s\n", $exe, join(", ", @{$exe_dependencies{$exe}});
+# }
+
# process the "out" commands to recursively expand the deletions
sub delete_dependents($$$)
{
- my ($romfile,$original_reason,$listref) = @_;
- printf STDERR " %d - deleting %s\n", scalar @{$listref}, $romfile;
+ my ($romtrail,$original_reason,$listref) = @_;
+ my ($romfile,$trail) = split /\t/, $romtrail;
+
if (defined $deletions{$romfile})
{
# already marked for deletion
@@ -105,6 +143,10 @@
}
return;
}
+
+ # We should keep the following information, but it's rather verbose
+ # printf STDERR " %d - deleting %s (%s)\n", scalar @{$listref}, $romfile, $trail;
+
$deletions{$romfile} = $original_reason; # this ensures that it gets deleted
if ($romfile =~ /^sys.bin.(.*)$/i)
{
@@ -114,15 +156,21 @@
# print STDERR "No dependencies for $exe ($romfile)\n";
return;
}
- push @{$listref}, @{$exe_dependencies{$exe}};
+ foreach my $dependent (@{$exe_dependencies{$exe}})
+ {
+ if (!defined $deletions{$dependent})
+ {
+ push @{$listref}, "$dependent\t$romfile $trail";
+ }
+ }
}
}
my @delete_cmds = sort keys %deletions;
foreach my $romfile (@delete_cmds)
{
- delete $deletions{$romfile}; # so that delete_dependents with iterate properly
- my @delete_list = ($romfile);
+ delete $deletions{$romfile}; # so that delete_dependents will iterate properly
+ my @delete_list = ("$romfile\tout");
while (scalar @delete_list > 0)
{
my $next_victim = shift @delete_list;
@@ -134,9 +182,7 @@
my $stem_count = 0;
my $deletion_count = 0;
-my %lc_romfiles;
-my $line;
-while ($line = <>)
+foreach my $line (@obylines)
{
chomp $line;
if ($line =~ /^(.*=)(\S+\s+)(\S+)(\s.*)?$/)
@@ -153,8 +199,8 @@
$hostfile .= '"';
$rest = '"'. $rest;
}
-
- $lc_romfiles{lc $romfile} = $romfile; # for alias processing
+
+ $lc_romfiles{lc $romfile} = $romfile;
if ($deletions{$romfile})
{
@@ -178,8 +224,6 @@
my ($emudir, $romdir, $dataz, $resourcedir, $exename, $rscname) = split /\s*,\s*/, $1;
my $romfile = $romdir. "\\". $exename;
- $lc_romfiles{lc $romfile} = $romfile; # for alias processing
-
if ($deletions{$romfile})
{
# print STDERR "Deleted __ECOM_PLUGIN for $romfile\n";
@@ -196,10 +240,14 @@
$romfile = $lc_romfiles{lc $romfile};
if ($deletions{$romfile})
{
+ # delete the alias if the real file is marked for deletion
$deletion_count++;
- # Not sure what to do about aliases - what if the alias has dependents?
next;
}
+ else
+ {
+ # print STDERR "$romfile is not deleted - saving $line\n";
+ }
}
# patchdata sys\bin\eiksrv.dll addr 0x0000c944 4 5
@@ -209,7 +257,7 @@
$romfile =~ s/^\\//; # remove leading \, to match $romfile convention
$romfile = $lc_romfiles{lc $romfile};
- print STDERR "deleting patchdata line for $romfile\n";
+ # print STDERR "deleting patchdata line for $romfile\n";
if ($deletions{$romfile})
{
# don't count these lines as deletions - they are just extra lines relating to deleted files.