Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
authorShabe Razvi <shaber@symbian.org>
Mon, 20 Sep 2010 14:23:42 +0100
changeset 1259 5f8149838262
parent 1258 7c13417d5e31
child 1260 3f4513c7c945
Add dependency analysis tool, however dont switch on yet until v2.x of depends.exe tool is deployed.
common/build.postbuild.xml
common/tools/analysis/depends.pl
--- a/common/build.postbuild.xml	Mon Sep 20 11:38:07 2010 +0100
+++ b/common/build.postbuild.xml	Mon Sep 20 14:23:42 2010 +0100
@@ -741,7 +741,38 @@
         </then>
       </if>
     </target>
-    
+
+
+    <target name="sf-run-analysis-depends">
+
+        <for param="binary" parallel="true" threadCount="${env.NUMBER_OF_PROCESSORS}">
+
+        <fileset dir="${build.drive}/epoc32/release/winscw/udeb">
+            <filename name="*.dll"/>
+            <filename name="*.exe"/>
+        </fileset>
+
+        <sequential>
+
+        <propertyregex property="binary.filename"  override="true" input="@{binary}" regexp="\\([^\\]*)$" select="\1" casesensitive="false"/>
+        <echo message="INFO Processing ${binary.filename}"/>
+
+        <exec executable="cmd" dir="${sf.common.config.dir}/tools/analysis/" output="${temp.build.dir}/${binary.filename}.depends.out">
+            <arg value="/c"/>            
+            <arg value="perl"/>            
+            <arg value="depends.pl"/>            
+ 	    <arg value="@{binary}"/>
+        </exec>
+
+        </sequential>  
+      </for>
+
+      <concat destfile="${build.log.dir}\analysis\${build.id}_depends.log">
+        <fileset dir="${temp.build.dir}" includes="*depends.out"/>
+      </concat>
+
+    </target>
+
     <target name="sf-links-to-diamonds">
       <fmpp sourceFile="${sf.common.config.dir}/diamonds/linksForDiamonds.xml.ftl" outputFile="${build.log.dir}/linksForDiamonds.xml">
         <data expandProperties="yes">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/analysis/depends.pl	Mon Sep 20 14:23:42 2010 +0100
@@ -0,0 +1,72 @@
+#!perl -w
+# Copyright (c) 2010 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Wrapper for dependency analysis tool (http://www.dependencywalker.com), which identifies missing dependencies. This script will
+# process a set of given binaries and produce a tab separated output in the following format
+#
+#   Missing DLL/EXE		(binary with broken dependancy)
+#
+# Note: 
+# 1) Requires minimum of v2.0 of depends.exe to be available in the path.
+# 2) Binaries are dealt with sequentially. Any parallelisation should be dealt with by whoever calls this tool.
+#
+# Usage:
+# perl depends.pl <file pattern>
+#
+# Example:
+# perl depends.pl M:\epoc32\release\winscw\udeb\avkon.dll
+# perl depends.pl M:\epoc32\release\winscw\udeb\libOpenV* 
+# perl depends.pl M:\epoc32\release\winscw\udeb\*
+#
+use Text::CSV;
+my %missing_binaries;
+my $debug = 0;
+
+sub walk_binary($)
+{
+  my $filename = shift;
+  my $walk_cmd = "depends.exe /oc:$filename.csv /c $filename";
+  my $ret = system("$walk_cmd");
+  print "$walk_cmd --DONE\n" if $debug==1;
+
+  # Load CSV
+  
+  my $csv = Text::CSV->new();
+  my @rows;
+  
+  open my $csvText, "<", $filename.".csv" or die;
+  while ( my $row = $csv->getline( $csvText ) ) 
+  {
+     # column 0 is "?" if unknown dependency
+     if ($row->[0] =~ m/^\?$/)
+	 {
+         # column 1 contains missing dependency	
+	 print "MISSING: $filename is missing $row->[1]\n" if $debug==1;
+	 $missing_binaries{"$row->[1] \t\t($filename)"} = 1;
+	 } 
+  }
+  $csv->eof or $csv->error_diag();
+  # cleanup
+  close $csvText;
+  system("del $filename.csv");
+  
+}
+
+
+my @files = map(glob,@ARGV);
+foreach my $file (@files)
+{
+  print "Walking $file...\n" if $debug==1;
+  walk_binary($file);
+}
+print join("\n", sort keys %missing_binaries, "");