tools/static_dependencies.pl
author William Roberts <williamr@symbian.org>
Mon, 18 Oct 2010 12:30:30 +0100
changeset 66 fc9981c83de7
parent 25 f213623e3c86
child 80 3ab0df073c86
permissions -rw-r--r--
Add weatherinfo demo to syborg_stem_rom.oby Removed "Out" from etel.dll because it's too severe and kills the startup scripts Didn't add "In" to weatherinfo.exe because we are currently losing QtGui.dll due to dependency on MediaClientAudio.dll
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;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    37
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    38
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
    39
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
    40
	{
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
    41
  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
    42
	next if (!defined $hostfile);
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
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    44
	
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
    45
	if (lc $cmd eq "stem")
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
    46
		{
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
    47
		$hostfile =~ s/(\/|\\)([^\\\/]+)$/$1stem_$2/;			# use stem version instead
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
    48
		}
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
    49
	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
    50
	$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
    51
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    52
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
    53
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
    54
	{
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
	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
    56
	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
    57
	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
    58
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
    59
	# 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
    60
	$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
    61
	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
    62
	}
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
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
    65
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
    66
	{
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
    67
	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
    68
	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
    69
	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
    70
		{
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
		$romfile = canonical_romfile($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
		$outputlines{$romfile} = "$romfile\t$hostfile\t$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
    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
	}
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
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    76
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
    77
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    78
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
    79
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    80
	my ($romfile,$hostfile,@dependencies) = @_;
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
    81
	$outputlines{$romfile} = "$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
    82
	
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
    83
	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
    84
	
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    85
	# 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
    86
	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
    87
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    88
		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
    89
		$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
    90
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    91
		$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
    92
		$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
    93
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    94
		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
    95
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    96
			$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
    97
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    98
		else
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
    99
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   100
			$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
   101
			}
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
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   104
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   105
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
   106
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   107
	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
   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
	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
   110
	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
   111
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   112
	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
   113
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   114
	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
   115
	my @imports;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   116
	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
   117
		{
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
   118
		# 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
   119
		# 17 imports from dfpaeabi{000a0000}.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
   120
		if ($line =~ /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
   121
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   122
			push @imports, $1.$2;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   123
			next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   124
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   125
		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
   126
			{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   127
			$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
   128
			next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   129
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   130
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   131
	print_dependency($romfile,$hostfile,"sid=$sid",@imports);
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   132
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   133
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
   134
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
   135
	{
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
   136
	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
   137
	
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
   138
	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
   139
	
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
   140
	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
   141
	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
   142
		{
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
   143
		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
   144
			{
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
   145
			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
   146
			$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
   147
			$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
   148
			# 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
   149
			$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
   150
			}
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
   151
		}
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
   152
	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
   153
		{
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
   154
		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
   155
		}
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
   156
	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
   157
		{
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
   158
		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
   159
		}
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
   160
	}
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
   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 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
   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,$basename) = @_;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   165
	$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
   166
	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
   167
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   168
		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
   169
		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
   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
			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
   172
			return;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   173
			}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   174
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   175
	# 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
   176
	# 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
   177
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   178
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   179
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
   180
	{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   181
	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
   182
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   183
	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
   184
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   185
		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
   186
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   187
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   188
	
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   189
	# 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
   190
	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
   191
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   192
		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
   193
		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
   194
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   195
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   196
	# 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
   197
	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
   198
		{
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   199
		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
   200
		$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
   201
		$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
   202
		
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   203
		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
   204
		next;
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   205
		}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   206
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
   207
	# 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
   208
	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
   209
		{
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
   210
		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
   211
		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
   212
		}
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
   213
	
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   214
	# 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
   215
	}
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   216
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
   217
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
   218
	{
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
   219
	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
   220
	}
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
   221
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
   222
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
   223
	{
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
   224
	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
   225
	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
   226
		{
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
   227
		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
   228
		}
12
ab7598bdae30 Add tools\static_dependencies.pl which processes rom_contents.csv calculates static dependency information
William Roberts <williamr@symbian.org>
parents:
diff changeset
   229
	}