ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.19
Committed: Fri Sep 24 11:42:01 1999 UTC (25 years, 7 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_9_35, V0_9_34
Changes since 1.21.2.18: +4 -4 lines
Log Message:
debug_local BugFix

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 williamc 1.21.2.6 'Architecture' => \&OutToMakefile,
47     'LibType_StartTag' => \&LibType_Start,
48     'LibType_EndTag' => 'none',
49 williamc 1.21.2.15 #'LibType' => \&OutToScreen
50     'LibType' => \&LibType_text
51 williamc 1.1 };
52 williamc 1.2 use Utilities::Switcher;
53 williamc 1.1 $switch=Switcher->new($SupportedTags, $fullfilename);
54     $switch->{Strict_no_cr}='no';
55     #open a temporary gnumakefile to store output.
56 williamc 1.2 use Utilities::AddDir;
57 williamc 1.3 AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}");
58 williamc 1.1 open ( GNUmakefile, ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk") or die 'Unable to open /$ENV{INTwork}/${path}/BuildFile.mk $!\n';
59     if ( -e $ENV{LatestBuildFile} ) {
60     print GNUmakefile "include $ENV{LatestBuildFile}\n";
61     }
62     # print "writing to :\n".
63     # "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk\n";
64     $ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
65     $switch->parse(); # sort out supported tags
66     close GNUmakefile;
67     }
68    
69 williamc 1.21 sub ParseBuildFile_Export {
70     my $filename=shift;
71     use Tool;
72     # This hash defines which Document Elements we can use
73     my $SupportedTags={
74     'none' => 'none',
75     'export' => \&OutToMakefile,
76     'export_StartTag' => \&export_start,
77     'export_EndTag' => \&export_end,
78     'lib_StartTag' => \&lib_start_export,
79 williamc 1.21.2.12 'External_StartTag' => \&Ext_start_export,
80 williamc 1.21 'lib' => 'none'
81     };
82     use Utilities::Switcher;
83     $switchex=Switcher->new($SupportedTags, $filename);
84     $switchex->{Strict_no_cr}='no';
85     $switchex->parse(); # sort out supported tags
86     }
87    
88 williamc 1.1 sub initialterms() {
89     my $name=shift;
90     my @string=@_;
91    
92     $_=join "", @string;
93     chomp;
94     SWITCH: {
95     last SWITCH if /^#/;
96     if ( /^.*BlockClassPath.*/i ) {
97     s/^.*BlockClassPath *= *//;
98     _CutBlock($_);
99     last SWITCH;
100     }
101     } # end SWITCH
102     }
103    
104     # Tag routines - called by the Switcher when tag found
105    
106    
107    
108     #-- Override a class type with the <ConfigurationClass type=xxx> tag
109     # the type tag will pick up a pre-defined class type from project space.
110    
111     sub Class_StartTag {
112     my $name=shift;
113     my $hashref;
114     my @vars=@_;
115    
116     $hashref=$switch->SetupValueHash(\@vars);
117 williamc 1.21.2.1 if ( $Arch ) {
118 williamc 1.1 if ( defined $$hashref{'type'} ) {
119     $ClassName=$$hashref{'type'};
120     }
121 williamc 1.21.2.1 }
122 williamc 1.1 }
123    
124     sub ClassPath_StartTag {
125     my $name=shift;
126     my @vars=@_;
127     my $hashref;
128    
129     $hashref=$switch->SetupValueHash(\@vars);
130 williamc 1.21.2.1 if ( $Arch ) {
131 williamc 1.1 if ( defined $$hashref{'defaultpath'} ) {
132     }
133 williamc 1.21.2.1 }
134 williamc 1.1 }
135    
136     sub Bin_start {
137     my $name=shift;
138     my @vars=@_;
139     my $hashref;
140     my $fileclass;
141     my @tools;
142     my $tool;
143 williamc 1.12 my $filename;
144     my $objectname;
145 williamc 1.1
146     $hashref=$switch->SetupValueHash(\@vars);
147     $switch->checkparam($hashref, $name, 'file');
148 williamc 1.21.2.1 if ( $Arch ) {
149 williamc 1.1 if ( ! defined $$hashref{name} ) {
150     ($$hashref{name}=$$hashref{file})=~s/\..*//;
151     }
152 williamc 1.4 # This stuff for later
153     #$fileclass=$toolbox->getclass($file);
154     #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
155 williamc 1.12 ($filename=$$hashref{file})=~s/\..*//;
156     ($objectname=$$hashref{file})=~s/\..*/\.o/;
157     ($objectname_d=$$hashref{file})=~s/\..*/_d\.o/;
158 williamc 1.14 ($objectname_Insure=$$hashref{file})=~s/\..*/_Insure\.o/;
159 williamc 1.21.2.5 print GNUmakefile "bin:$$hashref{name}_o\n";
160 williamc 1.10 print GNUmakefile "bin_debug:$$hashref{name}_d\n";
161 williamc 1.21.2.19 print GNUmakefile "bin_debug_local:$$hashref{name}_l_d\n";
162 williamc 1.13 print GNUmakefile "bin_insure:$$hashref{name}_Insure\n";
163 williamc 1.21.2.18 print GNUmakefile "bin_Insure:$$hashref{name}_Insure\n";
164 williamc 1.21.2.7 # print GNUmakefile ".INTERMEDIATE::$$hashref{name}_d.exe\n";
165     # print GNUmakefile ".INTERMEDIATE::$$hashref{name}_Insure.exe\n";
166 williamc 1.12 print GNUmakefile ".INTERMEDIATE::$$hashref{name}.exe\n";
167 williamc 1.14 print GNUmakefile "$$hashref{name}_Insure:.psrc\n";
168 williamc 1.12 print GNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
169 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdDebug)\n";
170 williamc 1.21.2.19 print GNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
171 williamc 1.21.2.17 print GNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
172 williamc 1.13 print GNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
173 williamc 1.16 print GNUmakefile "\t\$(CClinkCmdInsure)\n";
174 williamc 1.12 print GNUmakefile "$$hashref{name}.exe:$objectname\n";
175 williamc 1.16 print GNUmakefile "\t\$(CClinkCmd)\n";
176 williamc 1.15 print GNUmakefile "$objectname:$$hashref{name}.dep\n";
177     print GNUmakefile "$objectname_d:$$hashref{name}.dep\n";
178     print GNUmakefile "$objectname_Insure:$$hashref{name}.dep\n";
179 williamc 1.21.2.3 print GNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
180     print GNUmakefile "-include $$hashref{name}.dep\n";
181 williamc 1.10 # print GNUmakefile "$$hashref{name}:$$hashref{file}\n";
182 williamc 1.17 print GNUmakefile <<ENDTEXT;
183 williamc 1.19 $$hashref{name}_d.exe:\$(libslocal_d)
184     $$hashref{name}.exe:\$(libslocal)
185 williamc 1.21.2.4 ifdef MCCABE_DATA_DIR
186     $$hashref{name}_mccabe.exe: \$(libslocal_d) $(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
187     endif
188 williamc 1.19 $$hashref{name}_Insure.exe:\$(libslocal_I)
189 williamc 1.17 $$hashref{name}_d:$$hashref{name}_d.exe
190 williamc 1.21.2.7 \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
191 williamc 1.21.2.19 $$hashref{name}_l_d:$$hashref{name}_l_d.exe
192     \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
193 williamc 1.17 $$hashref{name}_Insure:$$hashref{name}_Insure.exe
194 williamc 1.21.2.7 \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
195 williamc 1.20 $$hashref{name}:$$hashref{name}_d.exe
196     \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
197 williamc 1.21.2.5 $$hashref{name}_o:$$hashref{name}.exe
198 williamc 1.18 \@mv $$hashref{name}.exe \$(binarystore)/$$hashref{name}
199 williamc 1.21.2.4 binfiles+=$$hashref{file}
200 williamc 1.17 bintargets+=$$hashref{name} $$hashref{name}_d $$hashref{name}_Insure
201     ENDTEXT
202 williamc 1.21.2.12 }
203     }
204    
205     sub Ext_start_export {
206     my $name=shift;
207     my @vars=@_;
208     my $hashref;
209    
210     $hashref=$switch->SetupValueHash(\@vars);
211     if ( $Arch ) {
212     if ( $switchex->context('export') ) {
213     $$hashref{'ref'}=~tr[A-Z][a-z];
214     print GNUmakefile $$hashref{'ref'};
215     if ( defined $$hashref{'version'} ) {
216     print GNUmakefile "_V_".$$hashref{'version'};
217     }
218     print GNUmakefile "=true\n";
219     }
220 williamc 1.21.2.1 }
221 williamc 1.1 }
222    
223     sub External_StartTag {
224     my $name=shift;
225     my @vars=@_;
226     my $hashref;
227    
228     $hashref=$switch->SetupValueHash(\@vars);
229 williamc 1.21 if ( $Arch ) {
230 williamc 1.6 $$hashref{'ref'}=~tr[A-Z][a-z];
231 williamc 1.1 print GNUmakefile $$hashref{'ref'};
232     if ( defined $$hashref{'version'} ) {
233     print GNUmakefile "_V_".$$hashref{'version'};
234     }
235     print GNUmakefile "=true\n";
236 williamc 1.21 }
237 williamc 1.1
238     }
239    
240     sub Group_start {
241     my $name=shift;
242     my @vars=@_;
243     my $hashref;
244    
245     $hashref=$switch->SetupValueHash(\@vars);
246     $switch->checkparam($hashref, $name, 'name');
247 williamc 1.21.2.1 if ( $Arch ) {
248 williamc 1.1 print GNUmakefile "GROUP_".$$hashref{'name'};
249     if ( defined $$hashref{'version'} ) {
250     print GNUmakefile "_V_".$$hashref{'version'};
251     }
252     print GNUmakefile "=true\n";
253 williamc 1.21.2.1 }
254 williamc 1.1 }
255    
256     sub External {
257     my $name=shift;
258     my @vars=@_;
259     # Will simply collect string into a seperate buffer for processind
260     # at the tag closure - used for specifying product defaults
261     # --- Oh oh all of string already in external buffer @!
262     }
263    
264     sub External_EndTag {
265     my $name=shift;
266     my @vars=@_;
267    
268     # process buffer and check consistency with product dtd
269     }
270    
271     sub Use_start {
272     my $name=shift;
273     my @vars=@_;
274     my $hashref;
275     my $filename;
276 williamc 1.2 use Utilities::SCRAMUtils;
277 williamc 1.1
278     $hashref=$switch->SetupValueHash(\@vars);
279     $switch->checkparam($hashref, $name, "name");
280 williamc 1.21.2.1 if ( $Arch ) {
281 williamc 1.21 $filename=SCRAMUtils::checkfile(
282     "$ENV{INTsrc}/$$hashref{name}/BuildFile");
283     if ( $filename ne "" ) {
284     ParseBuildFile_Export( $filename );
285 williamc 1.1 }
286 williamc 1.21.2.1 }
287 williamc 1.1 }
288    
289 williamc 1.5 sub CheckBuildFile {
290 williamc 1.1 my $classdir=shift;
291     $ClassName="";
292     $thisfile="$classdir/$buildfile";
293    
294     if ( -e $ENV{LOCALTOP}."/".$thisfile ) {
295     $DefaultBuildfile="$ENV{LOCALTOP}/$thisfile";
296     ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile);
297     }
298     elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) {
299     $DefaultBuildfile="$ENV{RELEASETOP}/$thisfile";
300     ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile);
301     }
302     return $ClassName;
303     }
304    
305     # List association groups between <AssociateGroup> tags
306     # seperated by newlines or spaces
307     sub AssociateGroup {
308     my $name=shift;
309     my @vars=@_;
310     my $word;
311    
312     foreach $word ( @vars ){
313     chomp $word;
314     next if /^#/;
315     push @groups, $word;
316     }
317 williamc 1.21.2.1 }
318    
319     sub ignoretag {
320     my $name=shift;
321     my @vars=@_;
322    
323     $Arch=0;
324     push @ARCHBLOCK, $Arch;
325     }
326    
327     sub ignoretag_end {
328     my $name=shift;
329     my @vars=@_;
330    
331     pop @ARCHBLOCK;
332     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
333     }
334    
335     sub Arch_Start {
336     my $name=shift;
337     my @vars=@_;
338     my $hashref;
339    
340     $hashref=$toolswitch->SetupValueHash( \@vars );
341     $toolswitch->checkparam($hashref, $name, 'name');
342     #( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
343     ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
344     push @ARCHBLOCK, $Arch;
345     }
346     sub Arch_End {
347     my $name=shift;
348     my @vars=@_;
349    
350     pop @ARCHBLOCK;
351     $Arch=$ARCHBLOCK[$#ARCHBLOCK];
352 williamc 1.1 }
353    
354     # Split up the Class Block String into a useable array
355 williamc 1.5 sub _CutBlock {
356 williamc 1.1 my $string= shift @_;
357     @BlockClassA = split /\//, $string;
358     }
359    
360     sub OutToMakefile {
361     my $name=shift;
362     my @vars=@_;
363    
364 williamc 1.21.2.15 if ( $Arch ) {
365     print GNUmakefile @vars;
366     }
367 williamc 1.21.2.14 }
368     sub OutToScreen {
369     my $name=shift;
370     my @vars=@_;
371    
372 williamc 1.21.2.15 if ( $Arch ) {
373     print @vars;
374     }
375 williamc 1.1 }
376     sub setBlockClassPath {
377     my $name=shift;
378     my @vars=@_;
379     my $hashref;
380    
381     $hashref=$switch->SetupValueHash(\@vars);
382     $switch->checkparam($hashref, $name, 'path');
383     $BlockClassPath=$BlockClassPath.":".$$hashref{path};
384     _CutBlock($$hashref{path});
385 williamc 1.21 }
386    
387     sub export_start {
388     #Set up a toolfile object
389     $exporttool=Tool->new();
390     }
391    
392     sub export_end {
393     #Write toolfile object to disk
394     $exporttool->envtomake(\*GNUmakefile);
395     }
396    
397     #
398     # Export Mode Lib Tag
399     #
400     sub lib_start_export {
401     my $name=shift;
402     my @vars=@_;
403     my $hashref;
404    
405     $hashref=$switchex->SetupValueHash( \@vars );
406     $switchex->checkparam($hashref, $name, 'name');
407     if ( $Arch ) {
408     if ( $switchex->context('export') ) {
409     #If export mode then add this env to the export tool
410     $exporttool->addenv('lib',$$hashref{name});
411     }
412     }
413     }
414    
415     #
416     # Standard lib tag
417     #
418     sub lib_start {
419     my $name=shift;
420     my @vars=@_;
421     my $hashref;
422    
423     $hashref=$switch->SetupValueHash( \@vars );
424     $switch->checkparam($hashref, $name, 'name');
425     if ( $Arch ) {
426     print GNUmakefile "lib+=$$hashref{name}\n";
427     }
428 williamc 1.21.2.6 }
429    
430     #
431     # libtype specification
432     #
433     sub LibType_Start {
434     my $name=shift;
435     my @vars=@_;
436     my $hashref;
437    
438 williamc 1.21.2.8 if ( $Arch ) {
439 williamc 1.21.2.6 $hashref=$switch->SetupValueHash( \@vars );
440     $switch->checkparam($hashref, $name, 'type');
441    
442     print GNUmakefile "# Specify Library Type\n";
443     print GNUmakefile "DefaultLibsOff=yes\n";
444     if ( $$hashref{'type'}=~/^archive/i ) {
445     print GNUmakefile "LibArchive=true\n";
446     }
447 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_archive/i ) {
448 williamc 1.21.2.6 print GNUmakefile "LibDebugArchive=true\n";
449     }
450 williamc 1.21.2.11 elsif ($$hashref{'type'}=~/debug_shared/i ) {
451     print GNUmakefile "LibDebugShared=true\n";
452     }
453 williamc 1.21.2.6 elsif ($$hashref{'type'}=~/shared/i ) {
454     print GNUmakefile 'LibShared=true'."\n";
455     }
456     print GNUmakefile "\n";
457 williamc 1.21.2.8 }
458 williamc 1.1 }
459 williamc 1.21.2.15 sub LibType_text {
460     my $name=shift;
461     my @vars=@_;
462    
463     if ( $Arch ) {
464 williamc 1.21.2.16 print GNUmakefile "libmsg::\n\t\@echo Library info: ";
465 williamc 1.21.2.15 print GNUmakefile @vars;
466     print GNUmakefile "\n";
467     }
468     }
469