ITK/Release 4/Wrapping/Tasks/WrapITKModular: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Line 6: | Line 6: | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
require 5.004; | require 5.004; | ||
$ | |||
$ | $input = "Ashish_wrapfiles.txt"; | ||
$ | $output = "Ashish_headerfiles.txt"; | ||
$mapping = "Ashish_mapping.txt"; | |||
system("find . -name \*\.wrap -print >> $ | # First, prepare the input INPUT | ||
open(FILE2, ">$input") || die "Could not open $input\n"; | |||
system("find . -name \*\.wrap -print >> $input") == 0 || die "system error $?"; | |||
close(FILE2); | close(FILE2); | ||
# Next, process and write it in the output | # Next, process and write it in the output INPUT | ||
open( | open(INPUT, "$input") || die "Could not open $input\n"; | ||
open (OUTPUT, ">$ | open (OUTPUT, ">$output") || die "Could not open $output\n"; | ||
#$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap'; | #$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap'; | ||
Line 22: | Line 24: | ||
while ($line = < | while ($line = <INPUT>) { | ||
chomp($line); | chomp($line); | ||
if($line=~/$pattern/) { | if($line=~/$pattern/) { | ||
Line 40: | Line 42: | ||
} | } | ||
close(OUTPUT); | close(OUTPUT); | ||
close( | close(INPUT); | ||
# Merge two files line by line | # Merge two files line by line | ||
open (OUTPUT, "$ | open (OUTPUT, "$output") || die "Could not open $output\n"; | ||
open ( | open (MAPPING, ">$mapping") || die "Could not open $output\n"; | ||
open ( | open (INPUT, "$input") || die "Could not open $input\n"; | ||
while ($line = < | while ($line = <INPUT>) { | ||
$line2 = <OUTPUT>; | $line2 = <OUTPUT>; | ||
chomp($line); | print MAPPING $line, " => ", $line2, "\n"; | ||
} | |||
} | close(OUTPUT); | ||
close(INPUT); | |||
close(MAPPING); | |||
# git move the wrap files to the corresponding folders | |||
$log = "Ashish_Log.txt"; | |||
open (LOG, ">$log") || die "Could not open $log\n"; | |||
open (OUTPUT, "$output") || die "Could not open $output\n"; | |||
open (INPUT, "$input") || die "Could not open $input\n"; | |||
while ($line = <INPUT>) { | |||
$line2 = <OUTPUT>; | |||
if($line2 =~ /^\<No Mapping available\>$/) { | |||
; # do nothing | |||
} | |||
else { # move files | |||
chomp($line); | |||
$line2 =~ s/\n/,/g; | |||
$line2 =~ s/\s/,/g; | |||
$line2 =~ s/,$//; # get rid of last comma | |||
$line2 =~ s/^\.\///g; | |||
@temp = split(/\//, $line2); | |||
pop(@temp); pop(@temp); | |||
$rootdir = `pwd`;chomp($rootdir); | |||
$libdir = "$rootdir/Wrapping/WrapITK/Libraries"; | |||
$t = $libdir; | |||
while($sdir = shift(@temp)) { | |||
if (-d "$t/$sdir") { | |||
$t = "$t/$sdir"; | |||
next; | |||
} | |||
else { | |||
system("mkdir $t/$sdir") ==0 || die "Could not create directory $sdir of $t\n"; | |||
$t = "$t/$sdir"; | |||
} | |||
} | |||
system("cp $line $t/") == 0 || die "Could not copy INPUT:$line to directory:$t\n"; | |||
} | |||
} | |||
close(LOG); | |||
close(OUTPUT); | close(OUTPUT); | ||
close( | close(INPUT); | ||
Revision as of 22:09, 5 June 2011
Modular WrapITK
Mapping of files
Script used to obtain the mapping
#!/usr/bin/perl require 5.004; $input = "Ashish_wrapfiles.txt"; $output = "Ashish_headerfiles.txt"; $mapping = "Ashish_mapping.txt"; # First, prepare the input INPUT open(FILE2, ">$input") || die "Could not open $input\n"; system("find . -name \*\.wrap -print >> $input") == 0 || die "system error $?"; close(FILE2); # Next, process and write it in the output INPUT open(INPUT, "$input") || die "Could not open $input\n"; open (OUTPUT, ">$output") || die "Could not open $output\n"; #$pattern = '^\.\/Wrapping\/WrapITK\/Libraries\/(\w*)\/(\w*)\.wrap'; $pattern = '^\.\/(((\w*)\/)+)(\w*)\.wrap'; while ($line = <INPUT>) { 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(INPUT); # Merge two files line by line open (OUTPUT, "$output") || die "Could not open $output\n"; open (MAPPING, ">$mapping") || die "Could not open $output\n"; open (INPUT, "$input") || die "Could not open $input\n"; while ($line = <INPUT>) { $line2 = <OUTPUT>; print MAPPING $line, " => ", $line2, "\n"; } close(OUTPUT); close(INPUT); close(MAPPING); # git move the wrap files to the corresponding folders $log = "Ashish_Log.txt"; open (LOG, ">$log") || die "Could not open $log\n"; open (OUTPUT, "$output") || die "Could not open $output\n"; open (INPUT, "$input") || die "Could not open $input\n"; while ($line = <INPUT>) { $line2 = <OUTPUT>; if($line2 =~ /^\<No Mapping available\>$/) { ; # do nothing } else { # move files chomp($line); $line2 =~ s/\n/,/g; $line2 =~ s/\s/,/g; $line2 =~ s/,$//; # get rid of last comma $line2 =~ s/^\.\///g; @temp = split(/\//, $line2); pop(@temp); pop(@temp); $rootdir = `pwd`;chomp($rootdir); $libdir = "$rootdir/Wrapping/WrapITK/Libraries"; $t = $libdir; while($sdir = shift(@temp)) { if (-d "$t/$sdir") { $t = "$t/$sdir"; next; } else { system("mkdir $t/$sdir") ==0 || die "Could not create directory $sdir of $t\n"; $t = "$t/$sdir"; } } system("cp $line $t/") == 0 || die "Could not copy INPUT:$line to directory:$t\n"; } } close(LOG); close(OUTPUT); close(INPUT);