tools/packages_in_rom.pl
author William Roberts <williamr@symbian.org>
Mon, 25 Oct 2010 17:26:54 +0100
changeset 80 3ab0df073c86
parent 11 9fac6902f40b
permissions -rw-r--r--
Add support for "slim", which is "stem" + removal of some exports and checking of import details For this to work, the static_dependencies.txt file needs to contain the augmented dependency information. To help with this, it can now consume a mixture of both rom_content.csv lines and static_dependencies.txt lines: the best way to update the information would be something like (edit rom_content.csv to add "slim" to XXX.dll) findstr /i "xxx.dll" rom_content.csv > slim.txt findstr /i "xxx.dll" static_dependencies.txt >> slim.txt perl ..\tools\static_dependencies.pl -u static_dependencies.txt slim.txt > new_dependencies.txt This will notice the "slim" marking for xxx.dll, and record the detailed import and export lists for xxx.dll and everything which links to it. The new information will look something like sys\bin\xxx.dll /epoc32/release/armv5/urel/stem_xxx.dll exports=1-98.100-102:euser[100039e5].dll sys\bin\yyy.dll /epoc32/release/armv5/urel/yyy.dll euser[100039e5].dll:xxx[102750c7].dll@2.4-5.77.104-106:scppnwdl.dll sys\bin\zzz.dll /epoc32/release/armv5/urel/zzz.dll euser[100039e5].dll:xxx[102750c7].dll@23.25.74-77:scppnwdl.dll Only executables for which there is a "slim" marking will have this level of detail. The filtering script now does the detailed cross-checking of imports to exports for "slim" executables. In this case, it will observe the stem_xxx.dll does not export ordinal 104, and so the filtering will include deleting sys\bin\yyy.dll (xxx.dll Missing ordinal 104) sys\bin\zzz.dll will be acceptable, because it only uses ordinals which are still present in stem_xxx.dll

# Copyright (c) 2010 Symbian Foundation Ltd.
# All rights reserved.
# This component and the accompanying materials are made available
# under the terms of the License "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Symbian Foundation - initial contribution.
#
# Contributors:
#
# Description: 
# This package is to identify the packages which contributed to a ROM image
# dir /s/b build_info\logs\releaseables\*.tsv | perl packages_in_rom.pl romfile.dir -

use strict;

my %romfiles;
my %ibyfiles;

sub scan_rom_dir_file($)
	{
	my ($romdirfile) = @_;
	
  my $line;
  open FILE, "<$romdirfile" or print "Failed to read $romdirfile: $!\n" and return;
  while ($line = <FILE>)
  	{
  	next if ($line !~ /\t/);
  	
  	chomp $line;
  	my ($romdest,$srcfile,$ibyfile) = split /\t/,$line;
  	$romdest =~ s/\s*$//;		# strip off trailing spaces
  	$romdest =~ s/\//\\/g; 	# convert to EPOC directory separators
  	
    $srcfile =~ s/\\/\//g;	# Unix directory separators please
    $srcfile =~ s/^"(.*)"$/$1/; 	# Remove quotes
    $srcfile =~ s/\/\//\//g; 	# Convert // to /
    $srcfile =~ s/^\[0x[0-9a-fA-F]+\]//;	# remove HVID, if present
    $srcfile =~ s/mbm_rom$/mbm/i; 	# use original name of derived file
    $srcfile =~ s/(z\/)system\/..\//$1/i; 	# z/system/../private
    $srcfile = lc $srcfile; 	# sigh...
    
    $ibyfile =~ s/\\/\//g;	# Unix directory separators please
    $ibyfile =~ s/^.*\/rom\/include\///; 	# normalise path to rom\include
    
  	$romfiles{$srcfile} = $romdest;
  	$ibyfiles{$romdest} = $ibyfile;
		}
	close FILE;
	}

my %packages;
my %packagenames;
my %package_by_romfile;

sub scan_tsv($)
  {
  my ($tsvfile) = @_;
  return if ($tsvfile !~ /\/(([^\/]+)\/([^\/]+))\/info.tsv$/i);
  my $packagename = $1;
  $packagename =~ s/\\/\//g;
  $packagenames{$packagename} = 1;
  
  my $line;
  open FILE, "<$tsvfile" or print "Failed to read $tsvfile: $!\n" and return;
  while ($line = <FILE>)
    {
    chomp $line;
    my ($filename,$type,$config) = split /\t/,$line;
    
    $filename = lc $filename;		# sigh...
    if (defined $romfiles{$filename})
    	{
    	$package_by_romfile{$filename} = $packagename;
    	}
    }
  }

my $romlisting = shift @ARGV;
scan_rom_dir_file($romlisting);

my $tsvfile;
while ($tsvfile = <>)
  {
  chomp $tsvfile;
  if ($tsvfile =~ /info.tsv$/)
    {
    $tsvfile =~ s/\\/\//g;
    scan_tsv($tsvfile);
    }
  }

print "ROM file,Host file,Iby file,Package,In/Out,Who,Why\n";
my $unknowns = 0;
foreach my $file (sort keys %romfiles)
	{
	my $romfile = $romfiles{$file};
	my $ibyfile = $ibyfiles{$romfile};
	my $package = $package_by_romfile{$file};

	if (!defined $package)
		{
		$package = "(unknown)";
		$package_by_romfile{$file} = $package;
		$unknowns += 1;
		}
	print join(",", $romfile, $file, $ibyfile, $package, "","",""), "\n";
	}
printf STDERR "\n%d files in %s, %d unknowns\n", scalar keys %romfiles, $romlisting, $unknowns;