source: branches/profile/SOURCE_TOOLS/check_same_compiler_version.pl

Last change on this file was 11000, checked in by westram, 10 years ago
  • auto-rename flagfile old→new (to avoid cleaning all checkouts)
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.9 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my $old_extension = 'last_gcc';
7my $extension     = 'last_compiler';
8
9my $args = scalar(@ARGV);
10if ($args!=2) { die "Usage: check_same_compiler_version.pl name version\n"; }
11
12my $name    = $ARGV[0];
13my $version = $ARGV[1];
14
15my $arbhome = $ENV{'ARBHOME'};
16(-d $arbhome) || die "\$arbhome has to contain the name of a directory.\n";
17
18opendir(ARBHOME,$arbhome) || die "can't read directory '$arbhome' (Reason: $!)";
19my @found_version_files = ();
20foreach (readdir(ARBHOME)) {
21  if (/\.$extension$/ig) { push @found_version_files, $_; }
22  if (/\.$old_extension$/ig) { push @found_version_files, $_; }
23}
24closedir(ARBHOME);
25
26my $result = 0;
27my $found  = scalar(@found_version_files);
28
29my $currVersion     = $version.'.'.$name.'.'.$extension;
30my $obsoleteVersion = $version.'.'.$old_extension;
31
32if ($found == 0) { # first compilation -> create file
33  my $flagfile = $arbhome.'/'.$currVersion;
34  open(FLAG,">$flagfile") || die "can't create '$flagfile' (Reason: $!)";
35  print FLAG "- The last compilation was done using '$name $version'.\n";
36  close(FLAG);
37}
38elsif ($found != 1) {
39  die "Multiple compiler version files were found -- 'make rebuild' is your friend";
40}
41else {
42  my $lastVersion = $found_version_files[0];
43  if ($lastVersion eq $obsoleteVersion) {
44    print "[ renaming $obsoleteVersion -> $currVersion ]\n";
45    my $command = "mv $obsoleteVersion $currVersion";
46    system("$command") ==0 || die "can't execute '$command' (Reason: $?)";
47  }
48  elsif ($lastVersion ne $currVersion) {
49    my $command = "cat $lastVersion";
50    system("$command") ==0 || die "can't execute '$command' (Reason: $?)";
51    print "- Your current compiler version is '$name $version'.\n";
52    print "Use 'make rebuild' to recompile with a different compiler version or\n";
53    print "use 'make clean' to cleanup build and then compile again.\n";
54    $result = 1;
55  }
56}
57
58exit($result);
Note: See TracBrowser for help on using the repository browser.