ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/Utilities/Architecture.pm
(Generate patch)

Comparing COMP/SCRAM/src/Utilities/Architecture.pm (file contents):
Revision 1.3 by sashby, Fri Jul 1 15:23:36 2005 UTC vs.
Revision 1.6 by sashby, Mon May 15 15:52:28 2006 UTC

# Line 10 | Line 10
10   #
11   #--------------------------------------------------------------------
12   package Architecture;
13 +
14 + =head1 NAME
15 +  
16 + Architecture - Utilities to determine the architecture name.
17 +
18 + =head1 SYNOPSIS
19 +
20 +   if (! defined $self->{SCRAM_ARCH})
21 +      {
22 +      my $arch = Architecture->new();
23 +      $self->architecture($a->arch());
24 +      $self->system_architecture($a->system_arch_stem());
25 +      $ENV{SCRAM_ARCH} = $self->architecture();
26 +      }
27 +
28 + =head1 DESCRIPTION
29 +
30 + A mechanism to extract the current system architecture. The full arch
31 + and system (short) arch strings can be returned in the application using
32 + the methods in this package.
33 +
34 + =head1 METHODS
35 +
36 + =over
37 +  
38 + =cut
39 +  
40   require 5.004;
41   use Exporter;
42  
43   @ISA=qw(Exporter);
44   @EXPORT_OK=qw( );
45  
46 + =item   C<new()>
47 +
48 + Constructor for Architecture objects.
49 +
50 + =cut
51 +
52   sub new()
53     {
54     ###############################################################
# Line 38 | Line 71 | sub new()
71     return $self;
72     }
73  
74 + =item   C<arch()>
75 +
76 + Method to set or return the architecture name.
77 +
78 + =cut
79 +
80   sub arch()
81     {
82     my $self=shift;
# Line 46 | Line 85 | sub arch()
85        : $self->{arch};
86     }
87  
88 + =item   C<system_arch_stem()>
89 +
90 + Method to set or return the system architecture name stem. The
91 + architecture stem is the full architecture without any compiler dependence.
92 + For example, the architecture B<slc3_ia32_gcc323> has a system architecture
93 + name stem of B<slc3_ia32>.
94 +
95 + =cut
96 +
97   sub system_arch_stem()
98     {
99     my $self=shift;
# Line 54 | Line 102 | sub system_arch_stem()
102        : $self->{archstem};
103     }
104  
105 < # A subroutine to determine the architecture. This
106 < # is done by parsing the architecture map contained as
107 < # data inside SCRAM_SITE.pm and looking for an appropriate
108 < # match for our platform:
105 > =item   C<_initarch()>
106 >  
107 > A subroutine to determine the architecture. This
108 > is done by parsing the architecture map contained as
109 > data inside B<SCRAM_SITE.pm> and looking for an appropriate
110 > match for our platform.
111 >
112 > =cut
113 >  
114   sub _initarch()
115     {
116     my $self=shift;
# Line 65 | Line 118 | sub _initarch()
118     return $self;
119     }
120  
121 < # Parse the map data:
121 > =item   C<parse_architecture_map()>
122 >
123 > Read the architecture map file defined in the site package B<SCRAM_SITE.pm>.
124 >  
125 > =cut
126 >  
127   sub parse_architecture_map()
128     {
129     my $self=shift;
# Line 82 | Line 140 | sub parse_architecture_map()
140           {
141           # Store the matched string:
142           $matches->{$archstring}=1;
143 <        
86 <         if ((my $nkeys = keys %{$matches}) > 1)
87 <            {
88 <            print "\n";
89 <            print "SCRAM: WARNING: more than one architecture definition in ","\n";
90 <            print "       SCRAM_SITE matches current platform!","\n";
91 <            print "Unable to set the architecture correctly!","\n";
92 <            print "\n";
93 <            exit(1);
94 <            }
95 <        
96 <         # Store the match (only the *first* match in the case
97 <         # of multiple matches):
143 >         # Store the match. We take the first match then return:
144           $self->arch($archstring);
99
145           # Also take the arch stem from the arch string. E.g. for a string
146           # "slc3_ia32_xxx", keep the "slc3_ia32" part:
147           if (my ($sysname,$cpuarch) = ($archstring =~ /(.*?)\_(.*?)\_.*?$/))
# Line 109 | Line 154 | sub parse_architecture_map()
154              # Just set the stem to be the same as the main arch string:
155              $self->system_arch_stem($archstring);
156              }
157 +         return;
158           }
159        else
160           {
# Line 118 | Line 164 | sub parse_architecture_map()
164     }
165  
166   1;
167 +
168 + __END__
169 +
170 + =back
171 +
172 + =head1 AUTHOR/MAINTAINER
173 +
174 + Shaun Ashby
175 +
176 + =cut

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines