ITK/Release 4/Wrapping/Tasks/WrapITKModular: Difference between revisions

From KitwarePublic
< ITK‎ | Release 4‎ | Wrapping‎ | Tasks
Jump to navigationJump to search
No edit summary
Line 4: Line 4:


== Script used to obtain the mapping ==
== Script used to obtain the mapping ==
  #!/usr/bin/perl -w
  #!/usr/bin/perl  
  require 5.004;
  require 5.004;
 
  $fname = "Ashish_AllWrapFiles.txt";
  $fname = "Ashish_AllWrapFiles";
  $outname = "Ashish_ModFiles.txt";
  $outname = "Ashish_ModFiles";
$merged = "Ashish_Mapping.txt";
  # First, prepare the input file
  open(FILE2, ">$fname") || die "Could not open $fname\n";
system("find . -name \*\.wrap -print >> $fname")  == 0 || die "system error $?";
close(FILE2);
   
   
# First, prepare the input file
open(FILE2, ">$fname") || die "Could not open $fname\n";
system("find . -name \*\.wrap >> $fname")  == 0 || die "system error $?";
close(FILE2);
  # Next, process and write it in the output file
  # Next, process and write it in the output file
  open(FILE, "$fname") || die "Could not open $fname\n";
  open(FILE, "$fname") || die "Could not open $fname\n";
  open (OUTPUT, ">$outname") || die "Could not open $outname\n";
  open (OUTPUT, ">$outname") || die "Could not open $outname\n";
  #$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap';
  #$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap';
  $pattern = '^\.\/(((\w*)\/)+)(\w*)\.wrap';
  $pattern = '^\.\/(((\w*)\/)+)(\w*)\.wrap';
   
   
  while ($line = <FILE>) {  
  while ($line = <FILE>) {  
     chomp($line);
     chomp($line);
     if($line=~/$pattern/)  {
     if($line=~/$pattern/)  {
         system("find . -name \'$4.h\' >> $outname") == 0 || die "system error $?";  
         #(@output) = `find . -iname \'$4.h\' -print`;
        #$out = pop(@output);
        $out = `find . -iname \'$4.h\' -print`;
        #chomp($out);
        $out =~ s/\n/,/g;
        $out =~ s/,$//; # get rid of last comma
        if($out) {
            print OUTPUT "$out\n";
        } else {
            print OUTPUT "<No Mapping available>\n";
        }
     }
     }
  }  
  }  
close(OUTPUT);
  close(FILE);
  close(FILE);
# Merge two files line by line
open (OUTPUT, "$outname") || die "Could not open $outname\n";
open (MERGED, ">$merged") || die "Could not open $outname\n";
open (FILE, "$fname") || die "Could not open $fname\n";
while ($line = <FILE>) {
    $line2 = <OUTPUT>;
    chomp($line);
    print MERGED $line, " => ", $line2;
  close(OUTPUT);
  close(OUTPUT);
close(FILE);
close(MERGED);

Revision as of 02:50, 1 June 2011

Modular WrapITK

Mapping of files

Script used to obtain the mapping

#!/usr/bin/perl 
require 5.004;
$fname = "Ashish_AllWrapFiles.txt";
$outname = "Ashish_ModFiles.txt";
$merged = "Ashish_Mapping.txt";
 # First, prepare the input file
 open(FILE2, ">$fname") || die "Could not open $fname\n";
system("find . -name \*\.wrap -print >> $fname")  == 0 || die "system error $?"; 
close(FILE2);

# Next, process and write it in the output file
open(FILE, "$fname") || die "Could not open $fname\n";
open (OUTPUT, ">$outname") || die "Could not open $outname\n";

#$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap';
$pattern = '^\.\/(((\w*)\/)+)(\w*)\.wrap';


while ($line = <FILE>) { 
    chomp($line);
    if($line=~/$pattern/)  {
        #(@output) = `find . -iname \'$4.h\' -print`;
        #$out = pop(@output);
        $out = `find . -iname \'$4.h\' -print`;
        #chomp($out);
        $out =~ s/\n/,/g;
        $out =~ s/,$//; # get rid of last comma
        if($out) {
            print OUTPUT "$out\n";

        } else {
            print OUTPUT "<No Mapping available>\n";
        }
    }
} 
close(OUTPUT);
close(FILE);

# Merge two files line by line
open (OUTPUT, "$outname") || die "Could not open $outname\n";
open (MERGED, ">$merged") || die "Could not open $outname\n";
open (FILE, "$fname") || die "Could not open $fname\n";

while ($line = <FILE>) { 
    $line2 = <OUTPUT>;
    chomp($line);
    print MERGED $line, " => ", $line2;
}  

close(OUTPUT);
close(FILE);
close(MERGED);