فهرست منبع

Recursive scan implemented.

avkonst 13 سال پیش
والد
کامیت
734c63d81d
2فایلهای تغییر یافته به همراه41 افزوده شده و 18 حذف شده
  1. 36 18
      lib/SWI/Processor.pm
  2. 5 0
      swi_config_sample.xml

+ 36 - 18
lib/SWI/Processor.pm

@@ -233,32 +233,50 @@ sub swiProcess
         #print $dupindexIn "\n";
         #print $dupindexIn "init_nonregular\n";
         #print $dupindexIn "\n";
+        
+        my @directories;
+        push(@directories, $swiGlobalDirectory);
 
-        opendir( DIR, $swiGlobalDirectory )
-          or die("Can not open source directory '$swiGlobalDirectory'!");
-        while ( my $file = readdir(DIR) )
+        foreach my $curDirectory (@directories)
         {
-            if ( $file =~ m/$swiGlobalInclude/ )
+            opendir( DIR, $curDirectory )
+                or die("Can not open source directory '$curDirectory'!");
+            while ( my $file = readdir(DIR) )
             {
-                if (   $swiGlobalExclude ne ""
-                    && $file =~ m/$swiGlobalExclude/ )
+                my $fullPathFile = $curDirectory . "/" . $file;
+                if ($file eq '.' || $file eq '..')
                 {
                     next;
                 }
-
-                $filesData->{$file} = swiParse(
-                    $swiGlobalDirectory,
-                    $file,
-                    $swiGlobalPreprocessorRules,
-                    $swiGlobalScanerRules,
-                    $config->{"swi:modules"}->{"swi:module"}[$moduleId]
-                      ->{"swi:indexer:dup"},
-                    $config->{"swi:modules"}->{"swi:module"}[$moduleId]
-                      ->{"swi:indexer:gcov"}
-                );
+                if (-d ($fullPathFile))
+                {
+                    push(@directories, $fullPathFile);
+                    next;
+                }
+                
+                $fullPathFile =~ s/$swiGlobalDirectory\///;
+                if ( $fullPathFile =~ m/$swiGlobalInclude/ )
+                {
+                    if (   $swiGlobalExclude ne ""
+                        && $fullPathFile =~ m/$swiGlobalExclude/ )
+                    {
+                        next;
+                    }
+                    
+                    $filesData->{$fullPathFile} = swiParse(
+                        $swiGlobalDirectory,
+                        $fullPathFile,
+                        $swiGlobalPreprocessorRules,
+                        $swiGlobalScanerRules,
+                        $config->{"swi:modules"}->{"swi:module"}[$moduleId]
+                            ->{"swi:indexer:dup"},
+                        $config->{"swi:modules"}->{"swi:module"}[$moduleId]
+                            ->{"swi:indexer:gcov"}
+                    );
+                }
             }
+            closedir(DIR);
         }
-        closedir(DIR);
 
         # Add duplication statistics
         if ( defined($swiGlobalDupfinderEnabled)

+ 5 - 0
swi_config_sample.xml

@@ -116,6 +116,10 @@
           This is a full path to the directory where module's source files are stored
           It can be relative or full path (recommended).
           If it is relative path, you need to run Software Index tool from the relatively correct folder.
+		  
+		  Directory is processed recursively. I.e. files in sub-directories are scanned as well.
+		  In the report and in 'swi:files' section below,
+		  files are referenced relatively to directory configured in 'swi:location'.
       -->
       <swi:location>/path/to/my/module</swi:location>
       <!--
@@ -133,6 +137,7 @@
             .c, .h, .cpp, .hpp
             
             By default, all files are included.
+			If it is a file in sub-directory, it's name
         -->
         <swi:include>^.*[.][chCH]([pP][pP])?$</swi:include>
         <!--