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

Comparing COMP/SCRAM/src/BuildFile.pm (file contents):
Revision 1.5 by williamc, Thu Mar 18 10:32:03 1999 UTC vs.
Revision 1.21.2.21 by williamc, Tue Oct 12 16:47:13 1999 UTC

# Line 8 | Line 8 | 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;
18 >        $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 +        $numbins=0;
24 +        $envnum=0;
25 +        $envlevel=0;
26 +        $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
27          my $SupportedTags={
28                  'Use' => \&OutToMakefile,
29                  'Use_StartTag' => \&Use_start,
# Line 29 | Line 35 | sub ParseBuildFile {
35                  'ConfigurationClass' => \&OutToMakefile,
36                  'AssociateGroup' => \&AssociateGroup,
37                  'none' => \&OutToMakefile,
38 <                'Bin' => \&OutToMakefile,
38 >                'Bin' => 'none',
39                  'Bin_StartTag' => \&Bin_start,
40                  'ClassPath' => \&OutToMakefile,
41 <                'ClassPath_StartTag' => \&setBlockClassPath
41 >                'ClassPath_StartTag' => \&setBlockClassPath,
42 >                'Environment' => \&OutToMakefile,
43 >                'Environment_StartTag' => \&Environment_start,
44 >                'Environment_EndTag' => \&Environment_end,
45 >                'lib' => 'none',
46 >                'lib_StartTag' => \&lib_start,
47 >                'lib_EndTag' => 'none',
48 >                'ignore' => 'none',
49 >                'ignore_EndTag' => \&ignoretag_end,
50 >                'ignore_StartTag' => \&ignoretag,
51 >                'Architecture_StartTag' => \&Arch_Start,
52 >                'Architecture_EndTag' => \&Arch_End,
53 >                'Architecture' => \&OutToMakefile,
54 >                'LibType_StartTag' => \&LibType_Start,
55 >                'LibType_EndTag' => 'none',
56 >                #'LibType' => \&OutToScreen
57 >                'LibType' => \&LibType_text
58          };
59          use Utilities::Switcher;
60          $switch=Switcher->new($SupportedTags, $fullfilename);
# Line 51 | Line 73 | sub ParseBuildFile {
73          close GNUmakefile;
74   }
75  
76 + sub ParseBuildFile_Export {
77 +        my $filename=shift;
78 +        use Tool;
79 +        # This hash defines which Document Elements we can use
80 +        my $SupportedTags={
81 +                'none' => 'none',
82 +                'export' => \&OutToMakefile,
83 +                'export_StartTag' => \&export_start,
84 +                'export_EndTag' => \&export_end,
85 +                'lib_StartTag' => \&lib_start_export,
86 +                'External_StartTag' => \&Ext_start_export,
87 +                'lib' => 'none'
88 +        };
89 +        use Utilities::Switcher;
90 +        $switchex=Switcher->new($SupportedTags, $filename);
91 +        $switchex->{Strict_no_cr}='no';
92 +        $switchex->parse(); # sort out supported tags
93 + }
94 +
95   sub initialterms() {
96          my $name=shift;
97          my @string=@_;
# Line 80 | Line 121 | sub Class_StartTag {
121          my @vars=@_;
122          
123          $hashref=$switch->SetupValueHash(\@vars);
124 +        if ( $Arch ) {
125          if ( defined $$hashref{'type'} ) {
126                  $ClassName=$$hashref{'type'};
127          }
128 +        }
129   }
130  
131   sub ClassPath_StartTag {
# Line 91 | Line 134 | sub ClassPath_StartTag {
134          my $hashref;
135  
136          $hashref=$switch->SetupValueHash(\@vars);
137 +        if ( $Arch ) {
138          if ( defined $$hashref{'defaultpath'} ) {
139          }
140 +        }
141   }
142  
143   sub Bin_start {
# Line 102 | Line 147 | sub Bin_start {
147          my $fileclass;
148          my @tools;
149          my $tool;
150 +        my $filename;
151 +        my $objectname;
152          
153          $hashref=$switch->SetupValueHash(\@vars);
154          $switch->checkparam($hashref, $name, 'file');
155 +        if ( $Arch ) {
156          if ( ! defined $$hashref{name} ) {
157                  ($$hashref{name}=$$hashref{file})=~s/\..*//;
158          }
159          # This stuff for later
160          #$fileclass=$toolbox->getclass($file);
161          #$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file );
162 <        print GNUmakefile "bin::$$hashref{name}\n";
163 <        print GNUmakefile "$$hashref{name}::$$hashref{file}\n";
162 >
163 >        ($filename=$$hashref{file})=~s/\..*//;
164 >
165 >        # Create a new directory for each binary target
166 >        my $dirname="bin_".$$hashref{name};
167 >        AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname");
168 >        open (binGNUmakefile,
169 >           ">$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk") or die           "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/".
170 >           "BuildFile.mk $!\n";
171 >
172 >        # Create the link targets
173 >        $numbins++;
174 >        print GNUmakefile <<ENDTEXT;
175 > ifndef BINMADE
176 > bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy
177 > #\t\@echo - Invoking binary makefile \$\@
178 > \t\@if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname" ]; then \\
179 > \tchdir $ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname; \\
180 > \t\$(MAKE) BINMADE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/${path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk \$\@; \\
181 > \tfi
182 > endif
183 >
184 > ENDTEXT
185 >
186 >
187 > # the binary specifics makefile
188 > #       print binGNUmakefile "include $ENV{LatestBuildFile}\n";
189 >        print binGNUmakefile "include $currentenv\n";
190 > #       print binGNUmakefile "include \$(TOOL_HOME)/basics.mk\n";
191 >        print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/${path}\n";
192 > # alias for bin_Insure
193 >        print binGNUmakefile <<ENDTEXT;
194 > bin_insure:bin_Insure
195 > ifdef MAKETARGET_bin_insure
196 > MAKETARGET_$$hashref{name}_Insure=1
197 > endif
198 > ENDTEXT
199 >
200 > # Make generic rules for each type
201 >        $targettypes={
202 >                "bin" => 'o',
203 >                "bin_debug" => 'd',
204 >                "bin_debug_local" => 'l_d',
205 >                "bin_Insure" => 'Insure'
206 >        };
207 >        #
208 >        foreach $target ( keys %$targettypes ) {
209 >          print binGNUmakefile <<ENDTEXT;
210 >
211 > # Type $target specifics
212 > ifdef MAKETARGET_$target
213 > MAKETARGET_$$hashref{name}_$$targettypes{$target}=1
214 > endif
215 > $target ::$$hashref{name}_$$targettypes{$target}
216 >
217 > bintargets+=$$hashref{name}_$$targettypes{$target}
218 > clean::
219 > \t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\
220 > \techo Removing \$(binarystore)/$$hashref{name}; \\
221 > \trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\
222 > \tfi
223 >
224 > ENDTEXT
225 >          ($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/;
226 >          ${"objectname_$$targettypes{$target}"}=$objectname;
227 >          print binGNUmakefile "$objectname:$$hashref{name}.dep\n";
228 >        } # end loop
229 >
230 >        print binGNUmakefile "$$hashref{name}_Insure:.psrc\n";
231 >        print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n";
232 >        print binGNUmakefile "\t\$(CClinkCmdDebug)\n";
233 >        print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n";
234 >        print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n";
235 >        print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n";
236 >        print binGNUmakefile "\t\$(CClinkCmdInsure)\n";
237 >        print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n";
238 >        print binGNUmakefile "\t\$(CClinkCmd)\n";
239 >        print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n";
240 >        print binGNUmakefile "-include $$hashref{name}.dep\n";
241 > print binGNUmakefile <<ENDTEXT;
242 > clean::
243 > \t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\
244 > \techo Removing \$(binarystore)/$$hashref{name}; \\
245 > \trm \$(binarystore)/$$hashref{name}; \\
246 > \tfi
247 >
248 > $$hashref{name}_d.exe:\$(libslocal_d)
249 > $$hashref{name}_o.exe:\$(libslocal)
250 > ifdef MCCABE_DATA_DIR
251 > $$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp
252 > endif
253 > $$hashref{name}_Insure.exe:\$(libslocal_I)
254 > $$hashref{name}_d:$$hashref{name}_d.exe
255 >        \@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
256 > $$hashref{name}_l_d:$$hashref{name}_l_d.exe
257 >        \@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name}
258 > $$hashref{name}_Insure:$$hashref{name}_Insure.exe
259 >        \@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure
260 > $$hashref{name}:$$hashref{name}_d.exe
261 >        \@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name}
262 > $$hashref{name}_o:$$hashref{name}_o.exe
263 >        \@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name}
264 > binfiles+=$$hashref{file}
265 > ENDTEXT
266 >        }
267 > }
268 >
269 > sub Ext_start_export {
270 >        my $name=shift;
271 >        my @vars=@_;
272 >        my $hashref;
273 >        
274 >        $hashref=$switch->SetupValueHash(\@vars);
275 >        if ( $Arch ) {
276 >         if ( $switchex->context('export') ) {
277 >          $$hashref{'ref'}=~tr[A-Z][a-z];
278 >          print GNUmakefile $$hashref{'ref'};
279 >          if ( defined $$hashref{'version'} ) {
280 >                print GNUmakefile "_V_".$$hashref{'version'};
281 >          }
282 >          print GNUmakefile "=true\n";
283 >         }
284 >        }
285   }
286  
287   sub External_StartTag {
# Line 121 | Line 290 | sub External_StartTag {
290          my $hashref;
291          
292          $hashref=$switch->SetupValueHash(\@vars);
293 +        if ( $Arch ) {
294 +        $$hashref{'ref'}=~tr[A-Z][a-z];
295          print GNUmakefile $$hashref{'ref'};
296          if ( defined $$hashref{'version'} ) {
297                  print GNUmakefile "_V_".$$hashref{'version'};
298          }
299          print GNUmakefile "=true\n";
300 +        }
301          
302   }      
303  
# Line 136 | Line 308 | sub Group_start {
308          
309          $hashref=$switch->SetupValueHash(\@vars);
310          $switch->checkparam($hashref, $name, 'name');
311 +        if ( $Arch ) {
312          print GNUmakefile "GROUP_".$$hashref{'name'};
313          if ( defined $$hashref{'version'} ) {
314                  print GNUmakefile "_V_".$$hashref{'version'};
315          }
316          print GNUmakefile "=true\n";
317 +        }
318   }      
319  
320   sub External {
# Line 167 | Line 341 | sub Use_start {
341          
342          $hashref=$switch->SetupValueHash(\@vars);
343          $switch->checkparam($hashref, $name, "name");
344 <        if ( $filename=checkfile("$ENV{INTsrc}/$$hashref{name}/BuildFile")
345 <                                                 ne "" ) {
346 <          print GNUmakefile "ReqDependencies += $filename\n";
344 >        if ( $Arch ) {
345 >        $filename=SCRAMUtils::checkfile(
346 >                "$ENV{INTsrc}/$$hashref{name}/BuildFile");
347 >        if ( $filename ne "" ) {
348 >          ParseBuildFile_Export( $filename );
349 >        }
350          }
174        print GNUmakefile "local__$$hashref{name}=true\n";
351   }
352  
353   sub CheckBuildFile {
# Line 204 | Line 380 | sub AssociateGroup {
380          }
381   }
382  
383 + sub ignoretag {
384 +        my $name=shift;
385 +        my @vars=@_;
386 +        
387 +        $Arch=0;
388 +        push @ARCHBLOCK, $Arch;
389 + }
390 +
391 + sub ignoretag_end {
392 +        my $name=shift;
393 +        my @vars=@_;
394 +        
395 +        pop @ARCHBLOCK;
396 +        $Arch=$ARCHBLOCK[$#ARCHBLOCK];
397 + }
398 +
399 + sub Arch_Start {
400 +        my $name=shift;
401 +        my @vars=@_;
402 +        my $hashref;
403 +
404 +        $hashref=$toolswitch->SetupValueHash( \@vars );
405 +        $toolswitch->checkparam($hashref, $name, 'name');
406 +        #( ($$hashref{name}=~/$ENV{SCRAM_ARCH}/) )?$Arch=1:$Arch=0;
407 +        ( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($Arch=1) : ($Arch=0);
408 +        push @ARCHBLOCK, $Arch;
409 + }
410 + sub Arch_End {
411 +        my $name=shift;
412 +        my @vars=@_;
413 +
414 +        pop @ARCHBLOCK;
415 +        $Arch=$ARCHBLOCK[$#ARCHBLOCK];
416 + }
417 +
418   # Split up the Class Block String into a useable array
419   sub _CutBlock {
420      my $string= shift @_;
# Line 214 | Line 425 | sub OutToMakefile {
425          my $name=shift;
426          my @vars=@_;
427  
428 <        print GNUmakefile @vars;
428 >        if ( $Arch ) {
429 >          print GNUmakefile @vars;
430 >        }
431 > }
432 > sub OutToScreen {
433 >        my $name=shift;
434 >        my @vars=@_;
435 >
436 >        if ( $Arch ) {
437 >          print @vars;
438 >        }
439   }
440   sub setBlockClassPath {
441          my $name=shift;
# Line 226 | Line 447 | sub setBlockClassPath {
447          $BlockClassPath=$BlockClassPath.":".$$hashref{path};
448          _CutBlock($$hashref{path});
449   }
450 +
451 + sub export_start {
452 + #Set up a toolfile object
453 +        $exporttool=Tool->new();
454 + }
455 +
456 + sub export_end {
457 + #Write toolfile object to disk
458 +        $exporttool->envtomake(\*GNUmakefile);
459 + }
460 +
461 + #
462 + # Export Mode Lib Tag
463 + #
464 + sub lib_start_export {
465 +        my $name=shift;
466 +        my @vars=@_;
467 +        my $hashref;
468 +
469 +        $hashref=$switchex->SetupValueHash( \@vars );
470 +        $switchex->checkparam($hashref, $name, 'name');
471 +        if ( $Arch ) {
472 +         if ( $switchex->context('export') ) {
473 +                #If export mode then add this env to the export tool
474 +                $exporttool->addenv('lib',$$hashref{name});
475 +         }
476 +        }
477 + }
478 +
479 + #
480 + # Standard lib tag
481 + #
482 + sub lib_start {
483 +        my $name=shift;
484 +        my @vars=@_;
485 +        my $hashref;
486 +
487 +        $hashref=$switch->SetupValueHash( \@vars );
488 +        $switch->checkparam($hashref, $name, 'name');
489 +        if ( $Arch ) {
490 +           print GNUmakefile "lib+=$$hashref{name}\n";
491 +        }
492 + }
493 +
494 + #
495 + # libtype specification
496 + #
497 + sub LibType_Start {
498 +        my $name=shift;
499 +        my @vars=@_;
500 +        my $hashref;
501 +
502 +        if ( $Arch ) {
503 +        $hashref=$switch->SetupValueHash( \@vars );
504 +        $switch->checkparam($hashref, $name, 'type');
505 +        
506 +        print GNUmakefile "# Specify Library Type\n";
507 +        print GNUmakefile "DefaultLibsOff=yes\n";
508 +        if ( $$hashref{'type'}=~/^archive/i ) {
509 +          print GNUmakefile "LibArchive=true\n";
510 +        }
511 +        elsif ($$hashref{'type'}=~/debug_archive/i ) {
512 +          print GNUmakefile "LibDebugArchive=true\n";
513 +        }
514 +        elsif ($$hashref{'type'}=~/debug_shared/i ) {
515 +          print GNUmakefile "LibDebugShared=true\n";
516 +        }
517 +        elsif ($$hashref{'type'}=~/shared/i ) {
518 +          print GNUmakefile 'LibShared=true'."\n";
519 +        }
520 +        print GNUmakefile "\n";
521 +        }
522 + }
523 + sub LibType_text {
524 +        my $name=shift;
525 +        my @vars=@_;
526 +
527 +        if ( $Arch ) {
528 +          print GNUmakefile "libmsg::\n\t\@echo Library info: ";
529 +          print GNUmakefile @vars;
530 +          print GNUmakefile "\n";
531 +        }
532 + }
533 +
534 + sub Environment_start {
535 +        my $name=shift;
536 +        my @vars=@_;
537 +        my $hashref;
538 +
539 +        if ( $Arch ) {
540 +          $envnum++;
541 +          # copy the current GNUmakefile Filehandle
542 +          use FileHandle;
543 +          my $fh=FileHandle->new();
544 +          open ($fh,">&GNUmakefile");
545 +          push @filehandlestack, $fh;
546 +
547 +          # open up an environment file
548 +          open ( GNUmakefile,
549 +                "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk");
550 +          # include the approprate environment file
551 +          if ( $envlevel == 0 ) {
552 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
553 +                                "BuildFile.mk";
554 +          }
555 +          else {
556 +             print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/${path}/".
557 +                                "Env_$Envlevels[$envlevel]";
558 +          }
559 +          $envlevel++;
560 +          $Envlevels[$envlevel]=$envnum;
561 +          $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$envnum.mk";
562 +        }
563 + }
564 +
565 + sub Environment_end {
566 +        my $fd;
567 +
568 +        if ( $Arch ) {
569 +          $envlevel--;
570 +          if ( $envlevel < 0 ) {
571 +            print "Too many </Environent> Tags on $switch->line()\n";
572 +            exit;
573 +          }
574 +          close GNUmakefile;
575 +          # restore the last filehandle
576 +          $fd=pop @filehandlestack;
577 +          open (GNUmakefile, ">&$fd" ) ;
578 +          close $fd;
579 +          if ( $envlevel < 1 ) {
580 +            $currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/${path}/BuildFile.mk";
581 +          }
582 +          else {
583 +            $currentenv=
584 +             "$ENV{LOCALTOP}/$ENV{INTwork}/${path}/Env_$Envlevels[$envlevel]";
585 +          }
586 +        }
587 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines