Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update the script for transform platform into v3.
[simgrid.git] / tools / simgrid_update_xml.pl
index d0d7277..5b7b5a1 100755 (executable)
@@ -12,7 +12,7 @@
 use strict;
 
 my $fromversion=-1;
 use strict;
 
 my $fromversion=-1;
-my $toversion=2;
+my $toversion=3;
 
 my($output_string);
 
 
 my($output_string);
 
@@ -21,53 +21,76 @@ open INPUT, "$ARGV[0]" or die "Cannot open input file $ARGV[0]: $!\n";
 
 $output_string .=  "<?xml version='1.0'?>\n";
 $output_string .=  "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n";
 
 $output_string .=  "<?xml version='1.0'?>\n";
 $output_string .=  "<!DOCTYPE platform SYSTEM \"simgrid.dtd\">\n";
-$output_string .=  "<platform version=\"$toversion\">";
+$output_string .=  "<platform version=\"$toversion\">\n";
+$output_string .=  " <AS  id=\"AS0\"  routing=\"Full\">\n";
 
 my $line;
 
 my $line;
-while (defined($line = <INPUT>)) {
+while (defined($line = <INPUT>))
+{
     chomp $line;
     # eat the header, whatever form it has
     next if ($line =~ s/<\?xml[^>]*>//           && ! $line =~ /\S/); # just in case several tags are on the same line
     next if ($line =~ s/<!DOCTYPE[^>]*>//        && ! $line =~ /\S/);
     chomp $line;
     # eat the header, whatever form it has
     next if ($line =~ s/<\?xml[^>]*>//           && ! $line =~ /\S/); # just in case several tags are on the same line
     next if ($line =~ s/<!DOCTYPE[^>]*>//        && ! $line =~ /\S/);
-    next if ($line =~ s/<platform_description>// && ! $line =~ /\S/);
     
     
-    
-    if ($line =~ s/<platform(_description)? *>//) {
-       $fromversion = 0;
-    } else if ($line =~ s/<platform(_description)? *version=['"]?([0-9.]*)["']?>//) {
-       $fromversion = $1;
-       if ($fromversion == $toversion) {
-           warn "Input platform file version is already $fromversion. This should be a no-op.\n";
-       }
-       if ($fromversion > $toversion) {
-           die "Input platform file version is more recent than this script (file version: $fromversion; script version: $toversion)\n";
-       }
+    if ($line =~ s/<platform(_description)? *>//)
+    {
+               $fromversion = 0;
+               print "version 0\n";
+               next if !$line =~ /\S/;
+    }
+    elsif ($line =~ s/<platform.*version=["]*([0-9.])["]*>//)
+    {
+               $fromversion = $1;
+               print "version $fromversion\n";
+               if ($fromversion == $toversion) 
+               {
+               die "Input platform file version is already $fromversion. This should be a no-op.\n";
+               }
+               if ($fromversion > $toversion)
+               {
+               die "Input platform file version is more recent than this script (file version: $fromversion; script version: $toversion)\n";
+               }
+               next if !$line =~ /\S/;
     }
     
     }
     
-    if ($fromversion == 0) {
-       while ($line =~ m|^(.*?)<cpu(.*?)power="([^"]*)"(.*)$|) {
-           $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
-       }
-       while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*)$/) {
-           $line = "$1<cpu${2}power=\"$3\"$4";
-       }
-       while ($line =~ m|^(.*?)<network_link(.*?)bandwidth="([^"]*)"(.*?)$|) {
-           $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
-       }
-       while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)$/) {
-           $line = "$1<network_link${2}bandwidth=\"$3\"$4";
-       }
+    if ($fromversion == 0)
+    {
+               while ($line =~ m|^(.*?)<cpu(.*?)power="([^"]*)"(.*)$|)
+               {
+               $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
+               }
+               while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*)$/)
+               {
+               $line = "$1<cpu${2}power=\"$3\"$4";
+               }
+               while ($line =~ m|^(.*?)<network_link(.*?)bandwidth="([^"]*)"(.*?)$|)
+               {
+               $line = "$1TOTOTUTUTATA${2}TOTOTUTUTATA".($3*1000000)."TOTOTUTUTATA${4}";
+               }
+               while ($line =~ /^(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)TOTOTUTUTATA(.*?)$/)
+               {
+               $line = "$1<network_link${2}bandwidth=\"$3\"$4";
+               }
     }
 
     }
 
-    if ($fromversion < 2) {
-        # The renamings (\b=zero-width word boundary check)
-       $line =~ s/\bplatform_description\b/platform/g;
-       $line =~ s/\bname\b/id/g;
-       $line =~ s/\bcpu\b/host/g;
-       $line =~ s/\bnetwork_link\b/link/g;
-       $line =~ s/\broute_element\b/link:ctn/g;
+    if ($fromversion < 2) 
+    {
+               # The renamings (\b=zero-width word boundary check)
+               $line =~ s/\bplatform_description\b/platform/g;
+               $line =~ s/\bname\b/id/g;
+               $line =~ s/\bcpu\b/host/g;
+               $line =~ s/\bnetwork_link\b/link/g;
+               $line =~ s/\broute_element\b/link:ctn/g;
     }
     }
-    $output_string .=  "$line\n";
+    
+    if($line =~ /^(.*)<\/platform>(.*)$/)
+       {
+               $output_string .=  " <\/AS>\n<\/platform>";
+       }
+       else
+       {
+       $output_string .=  "$line\n";
+       }
 }
 
 close INPUT;
 }
 
 close INPUT;