common/tools/analysis/depends.pl
author Simon Howkins <simonh@symbian.org>
Wed, 27 Oct 2010 16:22:14 +0100
changeset 1316 0b4a09013baf
parent 1259 5f8149838262
permissions -rw-r--r--
Added copyright messages
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1259
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     1
#!perl -w
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     2
# Copyright (c) 2010 Symbian Foundation Ltd
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     3
# This component and the accompanying materials are made available
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     5
# which accompanies this distribution, and is available
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     7
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     8
# Initial Contributors:
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
     9
# Symbian Foundation Ltd - initial contribution.
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    10
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    11
# Contributors:
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    12
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    13
# Description:
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    14
# Wrapper for dependency analysis tool (http://www.dependencywalker.com), which identifies missing dependencies. This script will
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    15
# process a set of given binaries and produce a tab separated output in the following format
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    16
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    17
#   Missing DLL/EXE		(binary with broken dependancy)
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    18
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    19
# Note: 
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    20
# 1) Requires minimum of v2.0 of depends.exe to be available in the path.
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    21
# 2) Binaries are dealt with sequentially. Any parallelisation should be dealt with by whoever calls this tool.
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    22
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    23
# Usage:
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    24
# perl depends.pl <file pattern>
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    25
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    26
# Example:
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    27
# perl depends.pl M:\epoc32\release\winscw\udeb\avkon.dll
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    28
# perl depends.pl M:\epoc32\release\winscw\udeb\libOpenV* 
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    29
# perl depends.pl M:\epoc32\release\winscw\udeb\*
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    30
#
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    31
use Text::CSV;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    32
my %missing_binaries;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    33
my $debug = 0;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    34
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    35
sub walk_binary($)
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    36
{
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    37
  my $filename = shift;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    38
  my $walk_cmd = "depends.exe /oc:$filename.csv /c $filename";
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    39
  my $ret = system("$walk_cmd");
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    40
  print "$walk_cmd --DONE\n" if $debug==1;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    41
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    42
  # Load CSV
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    43
  
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    44
  my $csv = Text::CSV->new();
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    45
  my @rows;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    46
  
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    47
  open my $csvText, "<", $filename.".csv" or die;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    48
  while ( my $row = $csv->getline( $csvText ) ) 
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    49
  {
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    50
     # column 0 is "?" if unknown dependency
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    51
     if ($row->[0] =~ m/^\?$/)
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    52
	 {
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    53
         # column 1 contains missing dependency	
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    54
	 print "MISSING: $filename is missing $row->[1]\n" if $debug==1;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    55
	 $missing_binaries{"$row->[1] \t\t($filename)"} = 1;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    56
	 } 
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    57
  }
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    58
  $csv->eof or $csv->error_diag();
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    59
  # cleanup
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    60
  close $csvText;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    61
  system("del $filename.csv");
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    62
  
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    63
}
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    64
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    65
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    66
my @files = map(glob,@ARGV);
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    67
foreach my $file (@files)
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    68
{
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    69
  print "Walking $file...\n" if $debug==1;
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    70
  walk_binary($file);
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    71
}
5f8149838262 Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
Shabe Razvi <shaber@symbian.org>
parents:
diff changeset
    72
print join("\n", sort keys %missing_binaries, "");