2 |
|
# |
3 |
|
# Interface |
4 |
|
# --------- |
5 |
< |
# new(ConfigArea) |
5 |
> |
# new(ConfigArea,Builder) |
6 |
|
# ParseBuildFile($base,$path,$file) |
7 |
|
# ParseBuildFileExport(filename) |
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 |
12 |
< |
# buildfile() : get/set BuildFile location |
13 |
< |
# makefile() : get the generated makefile |
11 |
> |
# classname() : get/set the associated class |
12 |
> |
# buildfile() : get/set BuildFile location |
13 |
> |
# makefile() : get the generated makefile |
14 |
|
|
15 |
|
package BuildSystem::BuildFile; |
16 |
|
use ActiveDoc::SimpleDoc; |
26 |
|
my $self={}; |
27 |
|
bless $self, $class; |
28 |
|
$self->{area}=shift; |
29 |
< |
$self->{toolbox}=$self->{area}->toolbox(); |
30 |
< |
$self->{localtop}=$self->{area}->location(); |
29 |
> |
$self->{Builder}=shift; |
30 |
> |
$self->{toolbox}=$self->{area}->toolbox(); |
31 |
> |
$self->{localtop}=$self->{area}->location(); |
32 |
> |
# -- set RELEASTOP |
33 |
> |
my $rarea=$self->{area}->linkarea(); |
34 |
> |
if ( ! defined $rarea ) { |
35 |
> |
$self->{releasetop}=$self->{localtop}; |
36 |
> |
} |
37 |
> |
else { |
38 |
> |
$self->{releasetop}=$rarea->location(); |
39 |
> |
} |
40 |
> |
$self->{releasetop}=$self->{area}->location(); |
41 |
|
$self->{Arch}=1; |
42 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
43 |
|
return $self; |
44 |
|
} |
45 |
|
|
46 |
|
sub buildfile { |
47 |
< |
my $self=shift; |
48 |
< |
if ( @_ ) { |
49 |
< |
$self->{buildfile}=shift; |
50 |
< |
} |
51 |
< |
return $self->{buildfile}; |
47 |
> |
my $self=shift; |
48 |
> |
if ( @_ ) { |
49 |
> |
$self->{buildfile}=shift; |
50 |
> |
} |
51 |
> |
return $self->{buildfile}; |
52 |
|
} |
53 |
|
|
54 |
|
sub makefile { |
55 |
< |
my $self=shift; |
56 |
< |
if ( @_ ) { |
57 |
< |
$self->{makefile}=shift; |
58 |
< |
} |
59 |
< |
return $self->{makefile}; |
55 |
> |
my $self=shift; |
56 |
> |
if ( @_ ) { |
57 |
> |
$self->{makefile}=shift; |
58 |
> |
} |
59 |
> |
return $self->{makefile}; |
60 |
> |
} |
61 |
> |
|
62 |
> |
sub BlockParse { |
63 |
> |
my $self=shift; |
64 |
> |
$self->{block}=shift; |
65 |
> |
|
66 |
> |
# -- set up the block parse |
67 |
> |
my $switch=$self->_initswitcher(); |
68 |
> |
my $parse="block"; |
69 |
> |
$switch->newparse($parse); |
70 |
> |
$switch->addignoretags($parse); |
71 |
> |
$switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self); |
72 |
> |
$switch->filetoparse($self->buildfile()); |
73 |
> |
|
74 |
> |
# -- parse away |
75 |
> |
$self->{switch}=$switch; |
76 |
> |
$switch->parse("block"); |
77 |
> |
} |
78 |
> |
|
79 |
> |
sub Parsetofh { |
80 |
> |
my $self=shift; |
81 |
> |
my $fh=shift; |
82 |
> |
$self->{buildblock}=shift; |
83 |
> |
|
84 |
> |
# -- set up for parse |
85 |
> |
@{$self->{filehandlestack}}=($fh); |
86 |
> |
$self->{switch}->filetoparse($self->buildfile()); |
87 |
> |
*GNUmakefile=$fh; |
88 |
> |
|
89 |
> |
# -- generate makefile |
90 |
> |
$self->{switch}->parse("makebuild"); # sort out supported tags |
91 |
> |
|
92 |
> |
# -- Clean up |
93 |
> |
close GNUmakefile; |
94 |
|
} |
95 |
|
|
96 |
|
sub ignore { |
105 |
|
$switch->newparse($parse); |
106 |
|
$switch->addignoretags($parse); |
107 |
|
$self->_commontags($switch,$parse); |
108 |
< |
$switch->addtag($parse,"Build", \&Build_start, $self); |
108 |
> |
#$switch->addtag($parse,"Build", \&Build_start, $self); |
109 |
|
$switch->addtag($parse,"none", |
110 |
|
\&OutToMakefile,$self, |
111 |
|
\&OutToMakefile, $self, |
114 |
|
\&Bin_start,$self, |
115 |
|
\&OutToScreen, $self, |
116 |
|
"", $self); |
117 |
+ |
$switch->addtag($parse,"ProductStore", |
118 |
+ |
\&Store_start,$self, |
119 |
+ |
"", $self, |
120 |
+ |
"", $self); |
121 |
|
$switch->addtag($parse,"LibType", |
122 |
|
\&LibType_Start,$self, |
123 |
|
\&LibType_text, $self, |
196 |
|
if ( -e $ENV{LatestBuildFile} ) { |
197 |
|
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
198 |
|
} |
150 |
– |
$ENV{LatestBuildFile}=$outfile; |
199 |
|
$self->{switch}->parse("makebuild"); # sort out supported tags |
200 |
|
close GNUmakefile; |
201 |
+ |
return $outfile; |
202 |
|
} |
203 |
|
|
204 |
|
sub ParseBuildFile { |
219 |
|
$self->{envnum}=0; |
220 |
|
$self->{envlevel}=0; |
221 |
|
$self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
222 |
< |
"BuildFile.mk"; |
223 |
< |
$self->{currentenv}=$self->{makefile}; |
222 |
> |
"BuildFile.mk"; |
223 |
> |
$self->{currentenv}=$self->{makefile}; |
224 |
|
$self->{switch}=$self->_initswitcher(); |
225 |
|
$self->{switch}->filetoparse($fullfilename); |
226 |
|
|
227 |
|
# $self->{switch}->{Strict_no_cr}='no'; |
228 |
|
#open a temporary gnumakefile to store output. |
229 |
|
use Utilities::AddDir; |
230 |
< |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
231 |
< |
$self->GenerateMakefile($fullfilename, |
232 |
< |
$self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk"); |
230 |
> |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
231 |
> |
$ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename, |
232 |
> |
$self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk"); |
233 |
|
} |
234 |
|
|
235 |
|
sub classname { |
236 |
< |
my $self=shift; |
237 |
< |
if ( @_ ) { |
238 |
< |
$self->{classname}=shift; |
239 |
< |
} |
240 |
< |
return $self->{classname}; |
236 |
> |
my $self=shift; |
237 |
> |
if ( @_ ) { |
238 |
> |
$self->{classname}=shift; |
239 |
> |
} |
240 |
> |
return $self->{classname}; |
241 |
|
} |
242 |
|
|
243 |
|
sub ParseBuildFile_Export { |
244 |
|
my $self=shift; |
245 |
|
my $filename=shift; |
246 |
< |
my $bf=BuildSystem::BuildFile->new($self->{area}); |
246 |
> |
my $bf=BuildSystem::BuildFile->new($self->{area},$self->{Builder}); |
247 |
|
if ( defined $self->{remoteproject} ) { |
248 |
|
$bf->{remoteproject}=$self->{remoteproject}; |
249 |
|
} |
319 |
|
|
320 |
|
if ( $self->{Arch} ) { |
321 |
|
if ( defined $$hashref{'type'} ) { |
322 |
< |
$self->classname($$hashref{'type'}); |
322 |
> |
$self->classname($$hashref{'type'}); |
323 |
|
} |
324 |
|
} |
325 |
|
} |
337 |
|
} |
338 |
|
|
339 |
|
# |
340 |
< |
# generic build tag |
340 |
> |
# --- <Build class=> tag |
341 |
|
# |
342 |
+ |
|
343 |
+ |
# |
344 |
+ |
# Parameter collection |
345 |
+ |
# |
346 |
+ |
sub BuildBlock_start { |
347 |
+ |
my $self=shift; |
348 |
+ |
my $name=shift; |
349 |
+ |
my $hashref=shift; |
350 |
+ |
|
351 |
+ |
|
352 |
+ |
my $blockobjid=$self->__blockobjid($hashref); |
353 |
+ |
|
354 |
+ |
if ( $self->{Arch} ) { |
355 |
+ |
|
356 |
+ |
# -- get any objects that match |
357 |
+ |
my $inheritobj=$self->{block}->getobj($blockobjid); |
358 |
+ |
|
359 |
+ |
# -- create an object with inherited properties |
360 |
+ |
my $obj; |
361 |
+ |
if ( ! defined $inheritobj ) { |
362 |
+ |
# -- check we have a lookup for the class type |
363 |
+ |
my $mapper=$self->_toolmapper(); |
364 |
+ |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
365 |
+ |
$self->{switch}->parseerror("Unknown class : ". |
366 |
+ |
$$hashref{'class'}); |
367 |
+ |
} |
368 |
+ |
$obj=BuildSystem::BuildClass->new(); |
369 |
+ |
} |
370 |
+ |
else { |
371 |
+ |
# -- inherit the properties from class with the same id class |
372 |
+ |
$obj=$inheritobj->child(); |
373 |
+ |
} |
374 |
+ |
|
375 |
+ |
# -- add changes from our tag |
376 |
+ |
$obj->paramupdate($hashref); |
377 |
+ |
|
378 |
+ |
# -- store the new object in the block |
379 |
+ |
$self->{block}->setobj($obj,$blockobjid); |
380 |
+ |
} |
381 |
+ |
} |
382 |
+ |
|
383 |
+ |
sub BuilderClass_buildmakefile { |
384 |
+ |
my $self=shift; |
385 |
+ |
my $name=shift; |
386 |
+ |
my $hashref=shift; |
387 |
+ |
|
388 |
+ |
my $blockobjid=$self->__blockobjid($hashref); |
389 |
+ |
|
390 |
+ |
if ( $self->{Arch} ) { |
391 |
+ |
# -- get the matching block object |
392 |
+ |
my $blockobj=$self->{buildblock}->getobj($blockobjid); |
393 |
+ |
|
394 |
+ |
# -- top level buildfile |
395 |
+ |
my $fh=$self->{filehandlestack}[0]; |
396 |
+ |
|
397 |
+ |
# -- var initialisation |
398 |
+ |
my @deftypes=(); |
399 |
+ |
my $buildname=""; |
400 |
+ |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
401 |
+ |
|
402 |
+ |
# -- error checking |
403 |
+ |
if ( ! defined $blockobj->param("default") ) { |
404 |
+ |
$self->error("No default build parameter defined for ". |
405 |
+ |
$$hashref{'class'}." ".$$hashref{'id'}); |
406 |
+ |
} |
407 |
+ |
if ( ! defined $blockobj->param("name") ) { |
408 |
+ |
$self->error("\"name\" parameter defined for ". |
409 |
+ |
$$hashref{'class'}." ".$$hashref{'id'}); |
410 |
+ |
} |
411 |
+ |
|
412 |
+ |
|
413 |
+ |
foreach $param ( $blockobj->paramlist() ) { |
414 |
+ |
# -- check for params that need special handling |
415 |
+ |
if ( $param eq "default" ) { |
416 |
+ |
@deftypes=split /,/, $param; |
417 |
+ |
} |
418 |
+ |
elsif ( $param eq "name" ) { |
419 |
+ |
$buildname=$blockobj->param($param); |
420 |
+ |
} |
421 |
+ |
else { |
422 |
+ |
# -- simple transfer of block object parameters to makefile |
423 |
+ |
print $fh $param.":=".$blockobj->param($param)."\n"; |
424 |
+ |
} |
425 |
+ |
} |
426 |
+ |
|
427 |
+ |
# -- construct the targets in the top makefile |
428 |
+ |
$self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes); |
429 |
+ |
$self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types); |
430 |
+ |
} |
431 |
+ |
} |
432 |
+ |
|
433 |
+ |
sub _blockobjid { |
434 |
+ |
my $self=shift; |
435 |
+ |
my $hashref=shift; |
436 |
+ |
|
437 |
+ |
$self->{switch}->checktag($name,$hashref,'class'); |
438 |
+ |
$self->{switch}->checktag($name,$hashref,'id'); |
439 |
+ |
my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'}; |
440 |
+ |
|
441 |
+ |
return $blockobjid; |
442 |
+ |
} |
443 |
+ |
|
444 |
|
sub Build_start { |
445 |
|
my $self=shift; |
446 |
|
my $name=shift; |
447 |
|
my $hashref=shift; |
448 |
|
|
449 |
|
$self->{switch}->checktag($name,$hashref,'class'); |
450 |
+ |
$self->{switch}->checktag($name,$hashref,'id'); |
451 |
|
if ( $self->{Arch} ) { |
452 |
|
|
453 |
|
# -- determine the build products name |
495 |
|
# -- create a new directory for each type |
496 |
|
push @targets, $pattern; |
497 |
|
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
498 |
< |
my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
498 |
> |
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
499 |
|
my $makefile=$here."/BuildFile.mk"; |
500 |
|
# AddDir::adddir($here); |
501 |
|
|
518 |
|
print $fh "\t cd $dirname; \\\n"; |
519 |
|
print $fh "\t echo include ".$self->{currentenv}." > ". |
520 |
|
"$makefile; \\\n"; |
521 |
< |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
521 |
> |
print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}. |
522 |
|
" >> $makefile; \\\n"; |
523 |
|
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
524 |
|
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
584 |
|
|
585 |
|
# Create a new directory for each binary target |
586 |
|
my $dirname="bin_".$$hashref{name}; |
587 |
< |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
587 |
> |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
588 |
|
open (binGNUmakefile, |
589 |
< |
">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/". |
589 |
> |
">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/". |
590 |
|
"BuildFile.mk $!\n"; |
591 |
|
|
592 |
|
# Create the link targets |
602 |
|
ifndef BINMODE |
603 |
|
|
604 |
|
define stepdown_$$hashref{'name'} |
605 |
< |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
606 |
< |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
607 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
605 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
606 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
607 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
608 |
|
fi |
609 |
|
endef |
610 |
|
|
611 |
|
define stepdown2_$$hashref{'name'} |
612 |
< |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
613 |
< |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
614 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
612 |
> |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
613 |
> |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
614 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
615 |
|
fi |
616 |
|
|
617 |
|
endef |
635 |
|
|
636 |
|
# the binary specifics makefile |
637 |
|
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
638 |
< |
print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n"; |
638 |
> |
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n"; |
639 |
|
|
640 |
|
# alias for bin_Insure |
641 |
|
print binGNUmakefile <<ENDTEXT; |
814 |
|
if ( ! defined $self->{remoteproject} ) { |
815 |
|
$filename=SCRAMUtils::checkfile( |
816 |
|
"/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
817 |
+ |
# -- force a dependency check if local |
818 |
+ |
if ( $filename=~/^$self->{localtop}/ ) { |
819 |
+ |
$self->{Builder}->BuildDir($ENV{INTsrc}."/".$$hashref{'name'}); |
820 |
+ |
} |
821 |
|
} |
822 |
|
else { |
823 |
|
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile"; |
1029 |
|
$self->{envnum}++; |
1030 |
|
|
1031 |
|
# open a new Environment File |
1032 |
< |
my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_". |
1032 |
> |
my $envfile=$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_". |
1033 |
|
$self->{envnum}.".mk"; |
1034 |
|
use FileHandle; |
1035 |
|
my $fh=FileHandle->new(); |
1078 |
|
} |
1079 |
|
} |
1080 |
|
} |
1081 |
+ |
|
1082 |
+ |
sub Store_start { |
1083 |
+ |
my $self=shift; |
1084 |
+ |
my $name=shift; |
1085 |
+ |
my $hashref=shift; |
1086 |
+ |
|
1087 |
+ |
if ( $self->{Arch} ) { |
1088 |
+ |
$self->{switch}->checktag( $name, $hashref, 'name' ); |
1089 |
+ |
|
1090 |
+ |
# -- store creation |
1091 |
+ |
my $dir=$$hashref{'name'}; |
1092 |
+ |
AddDir::adddir($self->{localtop}."/".$dir); |
1093 |
+ |
if ( exists $$hashref{'type'} ) { |
1094 |
+ |
# -- architecture specific store |
1095 |
+ |
if ( $$hashref{'type'}=~/^arch/i ) { |
1096 |
+ |
$dir=$dir."/".$ENV{SCRAM_ARCH}; |
1097 |
+ |
AddDir::adddir($self->{localtop}."/".$dir); |
1098 |
+ |
} |
1099 |
+ |
else { |
1100 |
+ |
$self->parseerror("Unknown type in <$name> tag"); |
1101 |
+ |
} |
1102 |
+ |
} |
1103 |
+ |
|
1104 |
+ |
# -- set make variables for the store |
1105 |
+ |
print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n"; |
1106 |
+ |
print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=". |
1107 |
+ |
$self->{localtop}."/".$dir."\n"; |
1108 |
+ |
print GNUmakefile "VPATH+=".$self->{localtop} |
1109 |
+ |
."/".$dir.":".$self->{releasetop}."/".$dir."\n"; |
1110 |
+ |
} |
1111 |
+ |
} |
1112 |
+ |
|