Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clean tabs for publis.html
[simgrid.git] / tools / simgrid_update_xml.pl
index d0d7277..16d4bc7 100755 (executable)
@@ -1,9 +1,9 @@
 #! /usr/bin/perl
 
 # This script updates the simgrid XML file passed as argument (modification in place)
-# It is built to do the conversion incrementally (even if for now, only 2 versions are defined)
+# It is built to do the conversion incrementally.
 
-# Copyright (C) 2006-2007. The SimGrid team. All rights reserved.
+# Copyright (C) 2006-2010. The SimGrid team. All rights reserved.
 #
 # This file is part of the SimGrid project. This is free software:
 # You can redistribute and/or modify it under the terms of the
 use strict;
 
 my $fromversion=-1;
-my $toversion=2;
+my $toversion=3;
 
 my($output_string);
 
 $ARGV[0] or die "simgrid_update_xml.pl <platform.xml>\n";
 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 .=  "<platform version=\"$toversion\">";
+$output_string = "<?xml version='1.0'?>\n".
+    "<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n".
+    "<platform version=\"$toversion\">\n";
+
+
+my($AS_opened)=0;
 
 my $line;
 while (defined($line = <INPUT>)) {
@@ -29,19 +32,21 @@ while (defined($line = <INPUT>)) {
     # 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.]*)["']?>//) {
+       print "version 0\n";
+       next if !$line =~ /\S/;
+    } elsif ($line =~ s/<platform.*version=["]*([0-9.])["]*>//) {
        $fromversion = $1;
+       print "version $fromversion\n";
        if ($fromversion == $toversion) {
-           warn "Input platform file version is already $fromversion. This should be a no-op.\n";
+           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) {
@@ -59,15 +64,37 @@ while (defined($line = <INPUT>)) {
        }
     }
 
-    if ($fromversion < 2) {
-        # The renamings (\b=zero-width word boundary check)
+    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 ($fromversion < 3)  {
+       $line =~ s/\blink:ctn\b/link_ctn/g;
+       $line =~ s/\btrace:connect\b/trace_connect/g;
+
+       if($AS_opened && (($line=~ /<\/platform>/) || ($line=~ /<process/))) {
+           $output_string .= "</AS>\n";
+           $AS_opened = 0;
+       }
+
+       if( (!$AS_opened) && (
+               ($line =~ /<host/)    ||
+               ($line =~ /<link/)    ||
+               ($line =~ /<cluster/) ||
+               ($line =~ /<router/)
+           )) {
+           $output_string .=  " <AS  id=\"AS0\"  routing=\"Full\">\n";
+           $AS_opened=1;
+       }
+    }
+       
+       if($line=~/<route /){$line =~ s/\<route/\<route symmetrical=\"NO\"/g;}
+    $output_string .= "$line\n";
 }
 
 close INPUT;