[svn:parrot] r43408 - branches/one_make/tools/dev

coke at svn.parrot.org coke at svn.parrot.org
Fri Jan 8 00:20:57 UTC 2010


Author: coke
Date: Fri Jan  8 00:20:57 2010
New Revision: 43408
URL: https://trac.parrot.org/parrot/changeset/43408

Log:
Search through .pir files for .include's and try to match them to real files.
Don't report errors on this yet.

Modified:
   branches/one_make/tools/dev/checkdepend.pl

Modified: branches/one_make/tools/dev/checkdepend.pl
==============================================================================
--- branches/one_make/tools/dev/checkdepend.pl	Thu Jan  7 23:48:33 2010	(r43407)
+++ branches/one_make/tools/dev/checkdepend.pl	Fri Jan  8 00:20:57 2010	(r43408)
@@ -18,7 +18,7 @@
 
 =head1 DESCRIPTION
 
-A braindead script to check that every F<.c> file has makefile deps
+A braindead script to check that every file has makefile deps
 on its includes.
 
  checkdepend.pl [--dump]
@@ -44,12 +44,11 @@
 die 'no Makefile found; This tool requires a full build for analysis.'
     unless -e 'Makefile';
 
-
-my $files = `ack -fa {src,compilers,include} | grep '\\.[ch]\$'`;
+my $files = `ack -fa {src,compilers,include} | ack '\\.(c|h|pir)\$'`;
 
 our %deps;
 
-foreach my $file (sort split /\n/, $files) {
+foreach my $file (sort grep /\.[hc]$/, split /\n/, $files) {
     # For now, skip any files that have generated dependencies
     next if $file =~ m{src/(ops|dynoplibs|dynpmc|pmc)/};
     next if $file =~ m{src/string/(charset|encoding)/};
@@ -61,7 +60,7 @@
         $guts = <$fh>;
     }
 
-    # Ingore anything inside a c-style comment.
+    # Ignore anything inside a c-style comment.
     $guts =~ s{\Q/*\E.*?\Q*/}{}gm;
 
     my @includes = $guts =~ m/#include "(.*)"/g;
@@ -89,6 +88,55 @@
     }
 }
 
+foreach my $file (sort grep /\.pir$/, split /\n/, $files) {
+    open my $fh, '<', $file;
+    my $guts;
+    {
+        local $/;
+        $guts = <$fh>;
+    }
+
+    # Ignore anything inside a # - comment.
+    $guts =~ s{^#.*$}{}gm;
+    # Ignore anything inside pod.
+    $guts =~ s{^=.*^=cut$}{}gsm;
+
+    my @includes;
+    while ($guts =~ m/.include (["'])(.*)\1/g) {
+        push @includes, $2;
+    } 
+
+    # Canonicalize each of these includes.
+
+    $deps{$file} = [ ];
+    foreach my $include (@includes) {
+        # same dir as file?
+        my $file_dir = (File::Spec->splitpath($file))[1];
+        my $make_dep = collapse_path(File::Spec->catfile($file_dir,$include));
+        if (defined($make_dep) && -f $make_dep) {
+            push @{$deps{$file}}, $make_dep;
+            next;
+        }
+
+        # global 'runtime' dir?
+        $make_dep = collapse_path(File::Spec->catfile('runtime/parrot/include',$include));
+        if (defined($make_dep) && -f $make_dep) {
+            push @{$deps{$file}}, $make_dep;
+            next;
+        }
+
+        # relative to top level?
+        $make_dep = collapse_path(File::Spec->catfile($include));
+        if (defined($make_dep) && -f $make_dep) {
+            push @{$deps{$file}}, $make_dep;
+            next;
+        }
+
+        diag "couldn't find $include, included from $file";
+    }
+}
+
+
 open my $mf, '<', "Makefile";
 my $rules;
 {


More information about the parrot-commits mailing list