Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
correcting mode of a perl script to be executable
[simgrid.git] / buildtools / Cmake / update_tesh.pl
1 #!/usr/bin/perl -w
2 use strict;
3
4 if($#ARGV!=1) {
5     die "Usage: perl make_tesh.pl <directory> <old.tesh>\n";
6 }
7
8 my($directory)=$ARGV[0];
9 my($old)=$ARGV[1];
10
11 chdir("$directory");
12
13 open SH_LIGNE, $old or die "Unable to open $old. $!\n";
14
15 my($line);
16 my($line_exec);
17 my($l);
18 my($tmp);
19
20 print "#! ./tesh\n";
21
22 while(defined($line=<SH_LIGNE>))
23 {
24         if($line =~ /^p(.*)$/)
25         {
26                 print "$line\n";
27         }
28         else
29         {
30                 if($line =~ /^\$(.*)$/) 
31                 {
32                         $line_exec = $line;
33                         $line =~ s/\$\{srcdir\:\=\.\}/./g;
34                         $line =~ s/\$SG_TEST_EXENV//g;
35                         $line =~ s/\$EXEEXT//g;
36                         $line =~ s/^\$\ */.\//g;
37                         $line =~ s/^.\/lua/lua/g;
38                         $line =~ s/^.\/ruby/ruby/g;
39                         $line =~ s/--log=([^ ]*)/--log="$1"/g;
40                         print "\n$line_exec";
41                         chomp $line;
42                         open (FILE, "$line 2>&1|");
43                         while(defined($l=<FILE>))
44                         {
45                         chomp $l;
46                         print "\> $l\n";
47                         }
48
49                 }
50                 close(FILE);
51         }
52 }
53
54 close(SH_LIGNE);