ITK/Release 4/Wrapping/Tasks/WrapITKModular

From KitwarePublic
< ITK‎ | Release 4‎ | Wrapping‎ | Tasks
Revision as of 02:50, 1 June 2011 by Ashishs99 (talk | contribs)
Jump to navigationJump to search

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);