ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.5
Committed: Thu Aug 19 09:12:32 1999 UTC (25 years, 9 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_9_21, V0_9_20
Changes since 1.21.2.4: +2 -2 lines
Log Message:
Fix bin target to use _o target - to work as advertised

File Contents

# User Rev Content
1 williamc 1.1 package BuildFile;
2 williamc 1.2 require 5.001;
3 williamc 1.1 require Exporter;
4     @ISA = qw(Exporter);
5     @EXPORT = qw(CheckBuildFile ParseBuildFile @BlockClassA $DefaultBuildFile);
6    
7     BEGIN {
8     use ToolBox;
9     $buildfile="BuildFile";
10 williamc 1.4 $toolbox=ToolBox->new();
11 williamc 1.21 $Arch=1;
12     push @ARCHBLOCK, $Arch;
13 williamc 1.1 }
14    
15     #Parse the BuildFile
16     sub ParseBuildFile {
17     my $base=shift;
18     my $path=shift;
19     my $filename=shift @_;
20     my $fullfilename="$base/$path/$filename";
21     #print "Processing $fullfilename\n";
22     # This hash defines which Document Elements we can use
23     my $SupportedTags={
24     'Use' => \&OutToMakefile,
25     'Use_StartTag' => \&Use_start,
26     'Group' => \&OutToMakefile,
27     'Group_StartTag' => \&Group_start,
28     'External' => \&OutToMakefile,
29     'External_StartTag' => \&External_StartTag,
30     'ConfigurationClass_StartTag' => \&Class_StartTag,
31     'ConfigurationClass' => \&OutToMakefile,
32     'AssociateGroup' => \&AssociateGroup,
33     'none' => \&OutToMakefile,
34 williamc 1.8 'Bin' => 'none',
35 williamc 1.1 'Bin_StartTag' => \&Bin_start,
36     'ClassPath' => \&OutToMakefile,
37 williamc 1.21 'ClassPath_StartTag' => \&setBlockClassPath,
38     'lib' => 'none',
39     'lib_StartTag' => \&lib_start,
40 williamc 1.21.2.1 'lib_EndTag' => 'none',
41     'ignore' => 'none',
42     'ignore_EndTag' => \&ignoretag_end,
43     'ignore_StartTag' => \&ignoretag,
44     'Architecture_StartTag' => \&Arch_Start,
45     'Architecture_EndTag' => \&Arch_End,
46     'Architecture' => \&OutToMakefile
47 williamc 1.1 };
48 williamc 1.2 use Utilities::Switcher;
49 williamc 1.1 $switch=Switcher->new($SupportedTags, $fullfilename);
50     $switch->{Strict_no_cr}='no';
51     #open a temporary gnumakefile to store output.
52 williamc 1.2 use Utilities::AddDir;
53 williamc 1.3 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
54 williamc 1.1 open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
55     if ( -e $ENV{LatestBuildFile} ) {
56     print GNUmakefile "include $ENV{LatestBuildFile}\n";
57     }
58     # print "writing to :\n".
59     # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
60     $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
61     $switch->parse(); # sort out supported tags
62     close GNUmakefile;
63     }
64    
65 williamc 1.21 sub ParseBuildFile_Export {
66     my $filename=shift;
67     use Tool;
68     # This hash defines which Document Elements we can use
69     my $SupportedTags={
70     'none' => 'none',
71     'export' => \&OutToMakefile,
72     'export_StartTag' => \&export_start,
73     'export_EndTag' => \&export_end,
74     'lib_StartTag' => \&lib_start_export,
75     'lib' => 'none'
76     };
77     use Utilities::Switcher;
78     $switchex=Switcher->new($SupportedTags, $filename);
79     $switchex->{Strict_no_cr}='no';
80     $switchex->parse(); # sort out supported tags
81     }
82    
83 williamc 1.1 sub initialterms() {
84     my $name=shift;
85     my @string=@_;
86    
87     $_=join "", @string;
88     chomp;
89     SWITCH: {
90     last SWITCH if /^#/;
91     if ( /^.*BlockClassPath.*/i ) {
92     s/^.*BlockClassPath *= *//;
93     _CutBlock($_);
94     last SWITCH;
95     }
96     } # end SWITCH
97     }
98    
99     # Tag routines - called by the Switcher when tag found
100    
101    
102    
103     #-- Override a class type with the <ConfigurationClass type=xxx> tag
104     # the type tag will pick up a pre-defined class type from project space.
105    
106     sub Class_StartTag {
107     my $name=shift;
108     my $hashref;
109     my @vars=@_;
110    
111     $hashref=$switch->SetupValueHash(\@vars);
112 williamc 1.21.2.1 if ( $Arch ) {
113 williamc 1.1 if ( defined $$hashref{'type'} ) {
114     $ClassName=$$hashref{'type'};
115     }
116 williamc 1.21.2.1 }
117 williamc 1.1 }
118    
119     sub ClassPath_StartTag {
120     my $name=shift;
121     my @vars=@_;
122     my $hashref;
123    
124     $hashref=$switch->SetupValueHash(\@vars);
125 williamc 1.21.2.1 if ( $Arch ) {
126 williamc 1.1 if ( defined $$hashref{'defaultpath'} ) {
127     }
128 williamc 1.21.2.1 }
129 williamc 1.1 }
130    
131     sub Bin_start {
132     my $name=shift;
133     my @vars=@_;
134     my $hashref;
135     my $fileclass;
136     my @tools;
137     my $tool;
138 williamc 1.12 my $filename;
139     my $objectname;
140 williamc 1.1
141     $hashref=$switch->SetupValueHash(\@vars);
142     $switch->checkparam($hashref, $name, 'file');
143 williamc 1.21.2.1 if ( $Arch ) {
144 williamc 1.1 if ( ! defined $$hashref{name} ) {
145     ($$hashref{name}=$$hashref{file})=~s/\..*//;
146     }
147 williamc 1.4 # This stuff for later
148     #$fileclass=$toolbox->getclass($file);
149     #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
150 williamc 1.12 ($filename=$$hashref{file})=~s/\..*//;
151     ($objectname=$$hashref{file})=~s/\..*/\.o/;
152     ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
153 williamc 1.14 ($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
154 williamc 1.21.2.5 print GNUmakefile "bin:$$hashref{name}_o\n";
155 williamc 1.10 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
156 williamc 1.13 print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
157 williamc 1.12 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
158 williamc 1.13 print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
159 williamc 1.12 print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
160 williamc 1.14 print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
161 williamc 1.12 print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
162 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdDebug)\n";
163 williamc 1.13 print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
164 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdInsure)\n";
165 williamc 1.12 print GNUmakefile "$$hashref{name}.exe:$objectname\n";
166 williamc 1.16 print GNUmakefile "\t\$(CClinkCmd)\n";
167 williamc 1.15 print GNUmakefile "$objectname:$$hashref{name}.dep\n";
168     print GNUmakefile "$objectname_d:$$hashref{name}.dep\n";
169     print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n";
170 williamc 1.21.2.3 print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
171     print GNUmakefile "-include $$hashref{name}.dep\n";
172 williamc 1.10 # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
173 williamc 1.17 print GNUmakefile <<ENDTEXT;
174 williamc 1.19 $$hashref{name}_d.exe:\$(libslocal_d)
175     $$hashref{name}.exe:\$(libslocal)
176 williamc 1.21.2.4 ifdef MCCABE_DATA_DIR
177     $$hashref{name}_mccabe.exe: \$(libslocal_d) $(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
178     endif
179 williamc 1.19 $$hashref{name}_Insure.exe:\$(libslocal_I)
180 williamc 1.17 $$hashref{name}_d:$$hashref{name}_d.exe
181 williamc 1.18 \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
182 williamc 1.17 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
183 williamc 1.18 \@mv $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
184 williamc 1.20 $$hashref{name}:$$hashref{name}_d.exe
185     \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
186 williamc 1.21.2.5 $$hashref{name}_o:$$hashref{name}.exe
187 williamc 1.18 \@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
188 williamc 1.21.2.4 binfiles+=$$hashref{file}
189 williamc 1.17 bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
190     ENDTEXT
191 williamc 1.21.2.1 }
192 williamc 1.1 }
193    
194     sub External_StartTag {
195     my $name=shift;
196     my @vars=@_;
197     my $hashref;
198    
199     $hashref=$switch->SetupValueHash(\@vars);
200 williamc 1.21 if ( $Arch ) {
201 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
202 williamc 1.1 print GNUmakefile $$hashref{'ref'};
203     if ( defined $$hashref{'version'} ) {
204     print GNUmakefile "_V_".$$hashref{'version'};
205     }
206     print GNUmakefile "=true\n";
207 williamc 1.21 }
208 williamc 1.1
209     }
210    
211     sub Group_start {
212     my $name=shift;
213     my @vars=@_;
214     my $hashref;
215    
216     $hashref=$switch->SetupValueHash(\@vars);
217     $switch->checkparam($hashref, $name, 'name');
218 williamc 1.21.2.1 if ( $Arch ) {
219 williamc 1.1 print GNUmakefile "GROUP_".$$hashref{'name'};
220     if ( defined $$hashref{'version'} ) {
221     print GNUmakefile "_V_".$$hashref{'version'};
222     }
223     print GNUmakefile "=true\n";
224 williamc 1.21.2.1 }
225 williamc 1.1 }
226    
227     sub External {
228     my $name=shift;
229     my @vars=@_;
230     # Will simply collect string into a seperate buffer for processind
231     # at the tag closure - used for specifying product defaults
232     # --- Oh oh all of string already in external buffer @!
233     }
234    
235     sub External_EndTag {
236     my $name=shift;
237     my @vars=@_;
238    
239     # process buffer and check consistency with product dtd
240     }
241    
242     sub Use_start {
243     my $name=shift;
244     my @vars=@_;
245     my $hashref;
246     my $filename;
247 williamc 1.2 use Utilities::SCRAMUtils;
248 williamc 1.1
249     $hashref=$switch->SetupValueHash(\@vars);
250     $switch->checkparam($hashref, $name, "name");
251 williamc 1.21.2.1 if ( $Arch ) {
252 williamc 1.21 $filename=SCRAMUtils::checkfile(
253     "$ENV{INTsrc}/$$hashref{name}/BuildFile");
254     if ( $filename ne "" ) {
255     ParseBuildFile_Export( $filename );
256 williamc 1.1 }
257 williamc 1.21.2.1 }
258 williamc 1.1 }
259    
260 williamc 1.5 sub CheckBuildFile {
261 williamc 1.1 my $classdir=shift;
262     $ClassName="";
263     $thisfile="$classdir/$buildfile";
264    
265     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
266     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
267     ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
268     }
269     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
270     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
271     ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
272     }
273     return $ClassName;
274     }
275    
276     # List association groups between <AssociateGroup> tags
277     # seperated by newlines or spaces
278     sub AssociateGroup {
279     my $name=shift;
280     my @vars=@_;
281     my $word;
282    
283     foreach $word ( @vars ){
284     chomp $word;
285     next if /^#/;
286     push @groups, $word;
287     }
288 williamc 1.21.2.1 }
289    
290     sub ignoretag {
291     my $name=shift;
292     my @vars=@_;
293    
294     $Arch=0;
295     push @ARCHBLOCK, $Arch;
296     }
297    
298     sub ignoretag_end {
299     my $name=shift;
300     my @vars=@_;
301    
302     pop @ARCHBLOCK;
303     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
304     }
305    
306     sub Arch_Start {
307     my $name=shift;
308     my @vars=@_;
309     my $hashref;
310    
311     $hashref=$toolswitch->SetupValueHash( \@vars );
312     $toolswitch->checkparam($hashref, $name, 'name');
313     #( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
314     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
315     push @ARCHBLOCK, $Arch;
316     }
317     sub Arch_End {
318     my $name=shift;
319     my @vars=@_;
320    
321     pop @ARCHBLOCK;
322     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
323 williamc 1.1 }
324    
325     # Split up the Class Block String into a useable array
326 williamc 1.5 sub _CutBlock {
327 williamc 1.1 my $string= shift @_;
328     @BlockClassA = split /\//, $string;
329     }
330    
331     sub OutToMakefile {
332     my $name=shift;
333     my @vars=@_;
334    
335     print GNUmakefile @vars;
336     }
337     sub setBlockClassPath {
338     my $name=shift;
339     my @vars=@_;
340     my $hashref;
341    
342     $hashref=$switch->SetupValueHash(\@vars);
343     $switch->checkparam($hashref, $name, 'path');
344     $BlockClassPath=$BlockClassPath.":".$$hashref{path};
345     _CutBlock($$hashref{path});
346 williamc 1.21 }
347    
348     sub export_start {
349     #Set up a toolfile object
350     $exporttool=Tool->new();
351     }
352    
353     sub export_end {
354     #Write toolfile object to disk
355     $exporttool->envtomake(\*GNUmakefile);
356     }
357    
358     #
359     # Export Mode Lib Tag
360     #
361     sub lib_start_export {
362     my $name=shift;
363     my @vars=@_;
364     my $hashref;
365    
366     $hashref=$switchex->SetupValueHash( \@vars );
367     $switchex->checkparam($hashref, $name, 'name');
368     if ( $Arch ) {
369     if ( $switchex->context('export') ) {
370     #If export mode then add this env to the export tool
371     $exporttool->addenv('lib',$$hashref{name});
372     }
373     }
374     }
375    
376     #
377     # Standard lib tag
378     #
379     sub lib_start {
380     my $name=shift;
381     my @vars=@_;
382     my $hashref;
383    
384     $hashref=$switch->SetupValueHash( \@vars );
385     $switch->checkparam($hashref, $name, 'name');
386     if ( $Arch ) {
387     print GNUmakefile "lib+=$$hashref{name}\n";
388     }
389 williamc 1.1 }