Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
regenerate all makefiles.in with the lastest autotools
[simgrid.git] / examples / gras / mutual_exclusion / simple_token / make_deployment.pl
index 5e69deb..b25f614 100755 (executable)
@@ -3,23 +3,30 @@
 use strict;
 
 my $input    = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
-my $nb_hosts = shift @ARGV || die "Usage: $ARGV[0] platform_file.xml nb_host\n";
+my $nb_hosts = shift @ARGV || 0;
 
 my @host;
 
 open IN,$input || die "Cannot open $input: $!\n";
 
 while (<IN>) {
-  next unless /<cpu name="([^"]*)"/; # "
+  next unless /<host id="([^"]*)"/; # "
   
   push @host, $1;
 }
 
+die "No host found in $input. Is it really a SimGrid platform file?\nCheck that you didn't pass a deployment file, for example.\n"
+  unless (scalar @host);
+
+if (! $nb_hosts) {
+    $nb_hosts = scalar @host;
+}
+
 # map { print "$_\n" } @host;
 
 print "<?xml version='1.0'?>\n";
-print "<!DOCTYPE platform_description SYSTEM \"surfxml.dtd\">\n";
-print "<platform_description version=\"1\">\n\n";
+print "<!DOCTYPE platform SYSTEM \"surfxml.dtd\">\n";
+print "<platform version=\"2\">\n\n";
 
 
 my $it_port=4000;
@@ -47,4 +54,4 @@ print "    <argument value=\"4000\"/>     <!-- port on which peer is listening -
 print "    <argument value=\"--create-token\"/>   <!-- I'm first client, ie I have to create the token -->\n";
 print "  </process>\n\n";
 
-print "</platform_description>\n";
+print "</platform>\n";