ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/src/BuildFile.pm
Revision: 1.21.2.6
Committed: Fri Aug 27 14:01:15 1999 UTC (25 years, 8 months ago) by williamc
Content type: text/plain
Branch: V0_9branch
CVS Tags: V0_9_25, V0_9_24, V0_9_23, V0_9_22
Changes since 1.21.2.5: +32 -1 lines
Log Message:
Add the libtype tag

File Contents

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