tools/static_dependencies.pl
author William Roberts <williamr@symbian.org>
Thu, 18 Nov 2010 15:45:28 +0000
changeset 138 6028e81d48fd
parent 105 96c15d318508
permissions -rw-r--r--
Update stem_rom.oby and rom_content.csv to remove multimedia Also removed spurious Phonebook2_reg.rsc file which causes PhoneBook to appear in the matrix menu
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     1
# Copyright (c) 2010 Symbian Foundation Ltd.
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     2
# All rights reserved.
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     7
#
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation - initial contribution.
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    10
#
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    11
# Contributors:
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    12
#
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    13
# Description: 
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    14
# This script generates a list of static dependencies for files in a ROM
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    15
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    16
use strict;
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    17
use Getopt::Long;
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    18
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    19
my $inverted_table = 0;
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    20
my $existing_file;
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    21
GetOptions(
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    22
  "i|invert" => \$inverted_table,   # add the inverted table
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    23
  "u|update=s" => \$existing_file,  # update existing file
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    24
  );
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    25
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    26
my @existinglines;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    27
if ($existing_file)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    28
	{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    29
	open EXISTING, "<$existing_file" or die("Cannot open $existing_file: $!\n");
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    30
	print STDERR "Reading existing dependencies from $existing_file\n";
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    31
	@existinglines = <EXISTING>;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    32
	close EXISTING;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    33
	}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    34
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    35
my %romfiles;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    36
my @contents;
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    37
my %need_details;
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    39
my $line;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    40
while ($line = <>)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    41
	{
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    42
  my ($romfile,$hostfile,$ibyfile,$package,$cmd,@columns) = split /,/, $line;		# first 5 fields are guaranteed to be simple
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    43
	next if ($romfile eq "ROM file");		# skip header line
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    44
	if (!defined $hostfile)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    45
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    46
		# is it perhaps a static_dependencies.txt line?
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    47
		my $dependencies;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    48
		my $nothing;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    49
		($romfile,$hostfile,$dependencies,$nothing) = split /\t/, $line;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    50
		next if (defined $nothing || !defined $hostfile);
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    51
		$cmd = "";
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    52
		}
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    53
	
105
96c15d318508 Regenerate static_dependencies.txt from first principles, to original files as well as stem_* versions
William Roberts <williamr@symbian.org>
parents: 80
diff changeset
    54
	if ($cmd =~ /slim$/i)
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    55
		{
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    56
		$need_details{lc $romfile} = 1;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    57
		$cmd = "stem";		# slim implies stem
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    58
		}
105
96c15d318508 Regenerate static_dependencies.txt from first principles, to original files as well as stem_* versions
William Roberts <williamr@symbian.org>
parents: 80
diff changeset
    59
	if ($cmd =~ /stem$/i && $hostfile !~ /stem_/)
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    60
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    61
		push @contents, "$romfile\t$hostfile";	# calculate dependencies for the original file
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    62
		$hostfile =~ s/(\/|\\)([^\\\/]+)$/$1stem_$2/;			# then use stem version as well
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    63
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    64
	push @contents, "$romfile\t$hostfile";
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    65
	$romfiles{lc $romfile} = $romfile;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    66
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    67
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    68
sub canonical_romfile($)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    69
	{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    70
	my ($romfile) = @_;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    71
	my $canonical = $romfiles{lc $romfile};
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    72
	return $canonical if (defined $canonical);
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    73
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    74
	# New romfile not seen before - add to table
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    75
	$romfiles{lc $romfile} = $romfile;	# set the standard for others!
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    76
	return $romfile;	
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    77
	}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    78
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    79
my %outputlines;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    80
foreach my $existingline (@existinglines)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    81
	{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    82
	chomp $existingline;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    83
	my ($romfile, $hostfile, $deps) = split /\t/, $existingline;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    84
	if (defined $deps)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    85
		{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    86
		$romfile = canonical_romfile($romfile);
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    87
		$outputlines{"$romfile\t$hostfile"} = "$romfile\t$hostfile\t$deps";
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    88
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    89
	}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
    90
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
my %dependents;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    92
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    93
sub print_dependency($$@)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    95
	my ($romfile,$hostfile,@dependencies) = @_;
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
    96
	$outputlines{"$romfile\t$hostfile"} = "$romfile\t$hostfile\t". join(":",@dependencies);
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    97
	
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    98
	next unless $inverted_table;
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
    99
	
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
	# Create inverted table 
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   101
	foreach my $dependent (@dependencies)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   102
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   103
		next if ($dependent =~ /^sid=/);
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
		$dependent = lc $dependent;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   106
		$dependent =~ s/^sys\\bin\\//;	# no directory => sys\bin anyway
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
		$dependent =~ s/\[\S+\]//;	# ignore the UIDs for now
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   108
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   109
		if (!defined $dependents{$dependent})
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   110
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   111
			$dependents{$dependent} = $romfile;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   113
		else
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   115
			$dependents{$dependent} .= "\t$romfile";
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   117
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   118
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   119
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   120
sub summarise_list($)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   121
	{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   122
	my ($hashref) = @_;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   123
	my @summary;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   124
	my @list = sort {$a <=> $b} keys %$hashref;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   125
	my $first = shift @list;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   126
	my $latest = $first;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   127
	foreach my $number (@list)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   128
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   129
		if ($number == $latest + 1)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   130
			{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   131
			# extends existing range by one
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   132
			$latest = $latest + 1;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   133
			next;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   134
			}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   135
		# new range
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   136
		if ($first > -1)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   137
			{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   138
			if ($latest == $first)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   139
				{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   140
				# Range with one element
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   141
				push @summary, $first;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   142
				}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   143
			else
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   144
				{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   145
				push @summary, "$first-$latest";
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   146
				}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   147
			}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   148
		$first = $number;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   149
		$latest = $number;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   150
		}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   151
	if ($latest == $first)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   152
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   153
		push @summary, "$first";
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   154
		}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   155
	else
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   156
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   157
		push @summary, "$first-$latest";
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   158
		}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   159
	return join(".", @summary);
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   160
	}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   161
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   162
sub generate_elftran_dependencies($$)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   163
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   164
	my ($romfile,$hostfile) = @_;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   165
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   166
	return if ($hostfile =~ /\/z\//); 	# data files in armv5\urel\z
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   167
	return if ($hostfile =~ /\.sis$/);	# not an e32 image file
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   169
	my @elftran = `elftran $hostfile`;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   170
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   171
	my $sid;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   172
	my @imports;
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   173
	my $dll;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   174
	my $importing = 0;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   175
	my %ordinals;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   176
	my %exports;
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   177
	foreach my $line (@elftran)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
		{
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   179
		#        Ordinal   318:  00010f9f
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   180
		if ($line =~ /Ordinal\s+(\d+):\s+(ABSENT)?/)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   181
			{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   182
			$exports{$1} = 1 unless ($2 eq "ABSENT");
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   183
			next;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   184
			}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   185
16
58fdbe891c31 Update static_dependencies.pl to handle dlls with interesting version numbers (e.g. backend.dll)
William Roberts <williamr@symbian.org>
parents: 12
diff changeset
   186
		# 2 imports from backend{00010001}[102828d5].dll
58fdbe891c31 Update static_dependencies.pl to handle dlls with interesting version numbers (e.g. backend.dll)
William Roberts <williamr@symbian.org>
parents: 12
diff changeset
   187
		# 17 imports from dfpaeabi{000a0000}.dll
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   188
		if ($line =~ /(\d+) imports from (\S+)\{.{8}\}(\S+)$/)
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   189
			{
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   190
			$dll = $2.$3;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   191
			my $import_count = $1;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   192
			my $exename = "sys\\bin\\". lc $dll;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   193
			$exename =~ s/\[\S+\]//;	# ignore the UID
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   194
			if (defined $need_details{$exename})
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   195
				{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   196
				# enable the tracking of the imported ordinals
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   197
				$importing = $import_count;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   198
				%ordinals = ();
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   199
				}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   200
			else
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   201
				{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   202
				# Just report the simple reference to the imported dll
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   203
				$importing = 0;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   204
				push @imports, $dll;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   205
				}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   206
			next;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   207
			}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   208
		if ($importing && $line =~ /^\s+(\d+)( offset by \d+)?$/)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   209
			{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   210
			$ordinals{$1} = 1;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   211
			$importing -= 1;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   212
			if ($importing == 0)
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   213
				{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   214
				$dll = $dll. "@". summarise_list(\%ordinals);
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   215
				push @imports, $dll;
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   216
				}
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   217
			next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   218
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   219
		if ($line =~ /^Secure ID: (\S+)$/)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   220
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   221
			$sid = $1; 	# presumably owns private/$sid  and various $sid.etxn files
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   222
			next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   223
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   224
		}
80
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   225
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   226
	my @export_info = ();
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   227
	if (scalar keys %exports && $need_details{lc $romfile})
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   228
		{
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   229
		push @export_info, "exports=".summarise_list(\%exports);
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   230
		}
3ab0df073c86 Add support for "slim", which is "stem" + removal of some exports and checking of import details
William Roberts <williamr@symbian.org>
parents: 25
diff changeset
   231
	print_dependency($romfile,$hostfile, @export_info, "sid=$sid",@imports);
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   232
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   233
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   234
sub find_exe_names_dependencies($$)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   235
	{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   236
	my ($romfile,$hostfile) = @_;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   237
	
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   238
	my @strings = `$ENV{"SBS_HOME"}\\win32\\mingw\\bin\\strings $hostfile`;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   239
	
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   240
	my %executables;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   241
	foreach my $string (@strings)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   242
		{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   243
		if ($string =~ /^(.*\\)?([^-\\]+\.(exe|dll))$/i)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   244
			{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   245
			my $exename = $2;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   246
			$exename =~ s/^\s+//;		# strip off leading whitespace (e.g.length byte before "clock.exe")
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   247
			$exename = canonical_romfile("sys\\bin\\$exename");	# get the exact capitalisation
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   248
			# print STDERR "Found $exename in $string";
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   249
			$executables{$exename} = 1;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   250
			}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   251
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   252
	if (%executables)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   253
		{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   254
		print_dependency($romfile,$hostfile,sort keys %executables);
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   255
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   256
	else
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   257
		{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   258
		print STDERR "No executable names found in system statup resource $hostfile\n";
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   259
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   260
	}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   261
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   262
sub find_dependency_in_sys_bin($$$)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   263
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   264
	my ($romfile,$hostfile,$basename) = @_;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   265
	$basename = lc $basename;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   266
	foreach my $extension (".exe",".dll")
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   267
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   268
		my $dependency = "sys\\bin\\$basename$extension";
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   269
		if (defined $romfiles{$dependency})
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   270
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   271
			print_dependency($romfile,$hostfile,$romfiles{$dependency});
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   272
			return;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   273
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   274
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   275
	# grep in the contents list?
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   276
	# print_dependency($romfile,$hostfile,"unmatched sys\\bin\\$basename");
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   277
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   278
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   279
foreach $line (@contents)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   280
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   281
	my ($romfile,$hostfile) = split /\t/, $line;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   282
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   283
	if ($hostfile =~ /epoc32.release.arm/i)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   284
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   285
		generate_elftran_dependencies($romfile,$hostfile);
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   286
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   287
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   288
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   289
	# App registration files
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   290
	if ($romfile =~ /private.10003a3f.*apps\\(.*)_reg\.rsc$/i)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   291
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   292
		my $dependency = "sys\\bin\\$1.exe";
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   293
		print_dependency($romfile,$hostfile,$dependency);
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   294
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   295
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   296
	# app resources
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   297
	if ($romfile =~ /resource.apps\\(.*)(\.mif|\.mbm|\.rsc)$/)
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   298
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   299
		my $executable = $1;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   300
		$executable =~ s/_aif$//; 	# xxx_aif.mif
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   301
		$executable =~ s/_loc$//; 	# xxx_loc.rsc
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   302
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   303
		find_dependency_in_sys_bin($romfile,$hostfile,$executable);
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   304
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   305
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   306
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   307
	# System state manager resource files
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   308
	if ($romfile =~ /private.2000d75b\\.*\.rsc$/i)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   309
		{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   310
		find_exe_names_dependencies($romfile,$hostfile);
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   311
		next;
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   312
		}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   313
	
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   314
	# Assume that the rest don't depend on anything, and leave them out.
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   315
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   316
25
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   317
foreach my $romfile ( sort keys %outputlines)
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   318
	{
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   319
	print $outputlines{$romfile}, "\n";
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   320
	}
f213623e3c86 Add -u option to static_dependencies.pl, to support merging information from an existing file with new dependencies
William Roberts <williamr@symbian.org>
parents: 22
diff changeset
   321
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   322
if ($inverted_table)
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   323
	{
22
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   324
	print "\n";
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   325
	foreach my $inverted (sort keys %dependents)
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   326
		{
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   327
		print "x\t$inverted\t$dependents{$inverted}\n";
76c5e260003e Calculate the inverted dependency table in filter_obyfile.pl, and make it optional (-i) in static_dependencies.pl
William Roberts <williamr@symbian.org>
parents: 16
diff changeset
   328
		}
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   329
	}