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

Comparing COMP/SCRAM/src/BuildSystem/BuildFile.pm (file contents):
Revision 1.9 by williamc, Fri Sep 29 10:32:18 2000 UTC vs.
Revision 1.11 by williamc, Thu Nov 2 15:24:09 2000 UTC

# Line 5 | Line 5
5   # new(ConfigArea)
6   # ParseBuildFile($base,$path,$file)
7   # ParseBuildFileExport(filename)
8 < # blockparse(Block) : perform a parse to modify the block
8 > # BlockParse(Block) : perform a parse to modify the block
9   # BlockClassPath() : Return the class path
10   # ignore()      : return 1 if directory should be ignored 0 otherwise
11   # classname()   : get/set the associated class
# Line 58 | Line 58 | sub makefile {
58          return $self->{makefile};
59   }
60  
61 < sub blockparse {
61 > sub BlockParse {
62          my $self=shift;
63          $self->{block}=shift;
64  
65 <        $self->{switch}=$self->_initswitcher();
66 <        $self->_initblockparse($self->{switch});
65 >        # -- set up the block parse
66 >        my $switch=$self->_initswitcher();
67 >        my $parse="block";
68 >        $switch->newparse($parse);
69 >        $switch->addignoretags($parse);
70 >        $switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self);
71 >        $switch->filetoparse($self->buildfile());
72 >
73 >        # -- parse away
74 >        $self->{switch}=$switch;
75 >        $switch->parse("block");
76 > }
77 >
78 > sub Parsetofh {
79 >        my $self=shift;
80 >        my $fh=shift;
81 >        $self->{buildblock}=shift;
82 >
83 >        # -- set up for parse
84 >        @{$self->{filehandlestack}}=($fh);
85 >        $self->{switch}->filetoparse($self->buildfile());
86 >        *GNUmakefile=$fh;
87 >
88 >        # -- generate makefile
89 >        $self->{switch}->parse("makebuild"); # sort out supported tags
90 >
91 >        # -- Clean up
92 >        close GNUmakefile;
93   }
94  
95   sub ignore {
# Line 118 | Line 144 | sub _initswitcher {
144          return $switch;
145   }
146  
121 sub _initblockparse {
122        my $self=shift;
123        my $switch=shift;
124
125        my $parse="block";
126        $switch->newparse($parse);
127        $switch->addignoretags($parse);
128        $switch->addtag($parse,"DropDown",
129                                        \&DropDown_start,$self,
130                                        "", $self,
131                                        "", $self);
132        $switch->addtag($parse,"Build", \&Build_start, $self);
133 }
134
147   sub _commontags {
148          my $self=shift;
149          my $switch=shift;
# Line 216 | Line 228 | sub ParseBuildFile {
228          use Utilities::AddDir;
229          AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}");
230          $ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename,
231 <          $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
231 >         $self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk");
232   }
233  
234   sub classname {
# Line 324 | Line 336 | sub IncludePath_Start {
336   }
337  
338   #
339 + # --- <Build class=> tag
340 + #
341 +
342 + #
343 + # Parameter collection
344 + #
345 + sub BuildBlock_start {
346 +        my $self=shift;
347 +        my $name=shift;
348 +        my $hashref=shift;
349 +
350 +
351 +        my $blockobjid=$self->__blockobjid($hashref);
352 +
353 +        if ( $self->{Arch} ) {
354 +
355 +           # -- get any objects that match
356 +           my $inheritobj=$self->{block}->getobj($blockobjid);
357 +
358 +           # -- create an object with inherited properties
359 +           my $obj;
360 +           if ( ! defined $inheritobj ) {
361 +               # -- check we have a lookup for the class type
362 +               my $mapper=$self->_toolmapper();
363 +               if ( ! $mapper->exists($$hashref{'class'}) ) {
364 +                 $self->{switch}->parseerror("Unknown class : ".
365 +                                                        $$hashref{'class'});
366 +               }
367 +               $obj=BuildSystem::BuildClass->new();
368 +           }
369 +           else {
370 +               # -- inherit the properties from class with the same id class
371 +               $obj=$inheritobj->child();
372 +           }
373 +
374 +           # -- add changes from our tag
375 +           $obj->paramupdate($hashref);
376 +
377 +           # -- store the new object in the block
378 +           $self->{block}->setobj($obj,$blockobjid);
379 +        }
380 + }
381 +
382 + sub BuilderClass_buildmakefile {
383 +        my $self=shift;
384 +        my $name=shift;
385 +        my $hashref=shift;
386 +
387 +        my $blockobjid=$self->__blockobjid($hashref);
388 +
389 +        if ( $self->{Arch} ) {
390 +           # -- get the matching block object
391 +           my $blockobj=$self->{buildblock}->getobj($blockobjid);
392 +
393 +           # -- top level buildfile
394 +           my $fh=$self->{filehandlestack}[0];
395 +
396 +           # -- var initialisation
397 +           my @deftypes=();
398 +           my $buildname="";
399 +           my @types=$self->_toolmapper()->types($$hashref{'class'});
400 +
401 +           # -- error checking
402 +           if ( ! defined $blockobj->param("default") ) {
403 +             $self->error("No default build parameter defined for ".
404 +                $$hashref{'class'}." ".$$hashref{'id'});
405 +           }
406 +           if ( ! defined $blockobj->param("name") ) {
407 +             $self->error("\"name\" parameter defined for ".
408 +                $$hashref{'class'}." ".$$hashref{'id'});
409 +           }
410 +
411 +
412 +           foreach $param ( $blockobj->paramlist() ) {
413 +             # -- check for params that need special handling
414 +             if ( $param eq "default" ) {
415 +                @deftypes=split /,/, $param;  
416 +             }
417 +             elsif ( $param eq "name" ) {
418 +                $buildname=$blockobj->param($param);
419 +             }
420 +             else {
421 +                # -- simple transfer of block object parameters to makefile
422 +                print $fh $param.":=".$blockobj->param($param)."\n";
423 +             }
424 +           }
425 +          
426 +           # -- construct the targets in the top makefile
427 +           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
428 +           $self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types);
429 +        }
430 + }
431 +
432 + sub _blockobjid {
433 +        my $self=shift;
434 +        my $hashref=shift;
435 +
436 +        $self->{switch}->checktag($name,$hashref,'class');
437 +        $self->{switch}->checktag($name,$hashref,'id');
438 +        my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'};
439 +
440 +        return $blockobjid;
441 + }
442 +
443 + sub _generatedefaulttargets {
444 +        my $self=shift;
445 +        my $fh=shift;
446 +        my $class=shift;
447 +
448 +        my @deftypes=shift;
449 +
450 +        print $fh "# -- Default type targets\n";
451 +        foreach $dtype ( @deftypes ) {
452 +            print $fh $class."::".$class."_".$dtype."\n";
453 +        }
454 +        print $fh "\n";
455 + }
456 +
457 + sub _generatetypetargets {
458 +        my $self=shift;
459 +        my $fh=shift;
460 +        my $class=shift;
461 +        my $name=shift;
462 +
463 +        my @types=shift;
464 +
465 +        print $fh "# -- Generic type targets\n";
466 +        foreach $type ( @types ) {
467 +            my $pattern=$class."_".$type;
468 +            my $dirname=$class."_".$type."_".$name;
469 +            my $makefile=$here."/BuildFile.mk";
470 +
471 +            # -- map to generic name for each type
472 +            print $fh "# ------ $pattern rules ---------------\n";
473 +            print $fh $class."_".$type."::".$class.
474 +                                                        "_".$type."_$name\n\n";
475 +
476 +            print $fh "# -- Link Targets to $type directories\n";
477 +            print $fh "$dirname: make_$dirname\n";
478 +            print $fh "\t\@cd $here; \\\n";
479 +            print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1".
480 +                        " workdir=$here ".
481 +                        " -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n";
482 +
483 +            # -- write target to make makefile for each directory
484 +            print $fh "# -- Build target directories\n";
485 +            print $fh "make_$dirname:\n";
486 +            print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n";
487 +            print $fh "\t if [ ! -d \"$here\" ]; then \\\n";
488 +            print $fh "\t  mkdir $here; \\\n";
489 +            print $fh "\t fi;\\\n";
490 +            print $fh "\t cd $dirname; \\\n";
491 +            print $fh "\t echo include ".$self->{currentenv}." > ".
492 +                                                        "$makefile; \\\n";
493 +            print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}.
494 +                                        " >> $makefile; \\\n";
495 +            print $fh "\t echo buildname=$name >> $makefile;\\\n";
496 +            print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n";
497 +            if ( defined (my @file=$mapper->rulesfile($class)) ) {
498 +             foreach $f ( @file ) {
499 +              print $fh "\t echo -include $f >> $makefile; \\\n";
500 +             }
501 +            }
502 +            print $fh "\tfi\n";
503 +            print $fh "\n";
504 +
505 +            # -- cleaning targets
506 +            push @targets, "clean_$dirname";
507 +            print $fh "# -- cleaning targets\n";
508 +            print $fh "clean::clean_$dirname\n";
509 +            print $fh "clean_".$dirname."::\n";
510 +            print $fh "\t\@echo cleaning $dirname\n";
511 +            print $fh "\t\@if [ -d $here ]; then \\\n";
512 +            print $fh "\tcd $here; \\\n";
513 +            print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=".
514 +                        $here." _BuildLink_=1 -f ".
515 +                        "\$(TOOL_HOME)/basics.mk clean; \\\n";
516 +            print $fh "\tfi\n\n";
517 +
518 +        }
519 +        print $fh "\n";
520 + }
521 +
522 + #
523   # generic build tag
524   #
525   sub Build_start {
# Line 359 | Line 555 | sub Build_start {
555  
556             # -- generate generic targets
557             print $fh "ifndef _BuildLink_\n";
558 <           print $fh "# -- Generic targets\n";
558 >           $self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes);
559 >
560             push @targets, $$hashref{'class'};
364           foreach $dtype ( @deftypes ) {
365            print $fh $$hashref{'class'}."::".$$hashref{'class'}."_".
366                                                                $dtype."\n";
367           }
368           print $fh "\n";
561  
562             # -- generate targets for each type
563             foreach $type ( @types ) {
# Line 380 | Line 572 | sub Build_start {
572              # -- create a new directory for each type
573              push @targets, $pattern;
574              my $dirname=$$hashref{'class'}."_".$type."_".$name;
575 <            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname;
575 >            my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}.
576 >                                                                "/".$dirname;
577              my $makefile=$here."/BuildFile.mk";
578   #           AddDir::adddir($here);
579  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines