5 |
|
# new(ConfigArea) |
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 |
14 |
|
|
15 |
|
package BuildSystem::BuildFile; |
16 |
|
use ActiveDoc::SimpleDoc; |
28 |
|
$self->{area}=shift; |
29 |
|
$self->{toolbox}=$self->{area}->toolbox(); |
30 |
|
$self->{localtop}=$self->{area}->location(); |
31 |
+ |
# -- set RELEASTOP |
32 |
+ |
my $rarea=$self->{area}->linkarea(); |
33 |
+ |
if ( ! defined $rarea ) { |
34 |
+ |
$self->{releasetop}=$self->{localtop}; |
35 |
+ |
} |
36 |
+ |
else { |
37 |
+ |
$self->{releasetop}=$rarea->location(); |
38 |
+ |
} |
39 |
+ |
$self->{releasetop}=$self->{area}->location(); |
40 |
|
$self->{Arch}=1; |
41 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
42 |
|
return $self; |
43 |
|
} |
44 |
|
|
45 |
+ |
sub buildfile { |
46 |
+ |
my $self=shift; |
47 |
+ |
if ( @_ ) { |
48 |
+ |
$self->{buildfile}=shift; |
49 |
+ |
} |
50 |
+ |
return $self->{buildfile}; |
51 |
+ |
} |
52 |
+ |
|
53 |
+ |
sub makefile { |
54 |
+ |
my $self=shift; |
55 |
+ |
if ( @_ ) { |
56 |
+ |
$self->{makefile}=shift; |
57 |
+ |
} |
58 |
+ |
return $self->{makefile}; |
59 |
+ |
} |
60 |
+ |
|
61 |
+ |
sub blockparse { |
62 |
+ |
my $self=shift; |
63 |
+ |
$self->{block}=shift; |
64 |
+ |
|
65 |
+ |
$self->{switch}=$self->_initswitcher(); |
66 |
+ |
$self->_initblockparse($self->{switch}); |
67 |
+ |
} |
68 |
+ |
|
69 |
|
sub ignore { |
70 |
|
my $self=shift; |
71 |
|
return (defined $self->{ignore})?$self->{ignore}:0; |
78 |
|
$switch->newparse($parse); |
79 |
|
$switch->addignoretags($parse); |
80 |
|
$self->_commontags($switch,$parse); |
81 |
< |
$switch->addtag($parse,"Build", \&Build_start, $self); |
81 |
> |
#$switch->addtag($parse,"Build", \&Build_start, $self); |
82 |
|
$switch->addtag($parse,"none", |
83 |
|
\&OutToMakefile,$self, |
84 |
|
\&OutToMakefile, $self, |
87 |
|
\&Bin_start,$self, |
88 |
|
\&OutToScreen, $self, |
89 |
|
"", $self); |
90 |
+ |
$switch->addtag($parse,"ProductStore", |
91 |
+ |
\&Store_start,$self, |
92 |
+ |
"", $self, |
93 |
+ |
"", $self); |
94 |
|
$switch->addtag($parse,"LibType", |
95 |
|
\&LibType_Start,$self, |
96 |
|
\&LibType_text, $self, |
118 |
|
return $switch; |
119 |
|
} |
120 |
|
|
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 |
+ |
|
135 |
|
sub _commontags { |
136 |
|
my $self=shift; |
137 |
|
my $switch=shift; |
183 |
|
if ( -e $ENV{LatestBuildFile} ) { |
184 |
|
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
185 |
|
} |
131 |
– |
$ENV{LatestBuildFile}=$outfile; |
186 |
|
$self->{switch}->parse("makebuild"); # sort out supported tags |
187 |
|
close GNUmakefile; |
188 |
+ |
return $outfile; |
189 |
|
} |
190 |
|
|
191 |
|
sub ParseBuildFile { |
205 |
|
$numbins=0; |
206 |
|
$self->{envnum}=0; |
207 |
|
$self->{envlevel}=0; |
208 |
< |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
208 |
> |
$self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
209 |
|
"BuildFile.mk"; |
210 |
+ |
$self->{currentenv}=$self->{makefile}; |
211 |
|
$self->{switch}=$self->_initswitcher(); |
212 |
|
$self->{switch}->filetoparse($fullfilename); |
213 |
|
|
215 |
|
#open a temporary gnumakefile to store output. |
216 |
|
use Utilities::AddDir; |
217 |
|
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
218 |
< |
my $fh=FileHandle->new(); |
219 |
< |
open ( $fh, ">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk" |
220 |
< |
) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n'; |
221 |
< |
@{$self->{filehandlestack}}=($fh); |
222 |
< |
# make an alias |
223 |
< |
*GNUmakefile=$fh; |
224 |
< |
if ( -e $ENV{LatestBuildFile} ) { |
225 |
< |
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
170 |
< |
} |
171 |
< |
# print "writing to :\n". |
172 |
< |
# "$self->{localtop}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n"; |
173 |
< |
$ENV{LatestBuildFile}="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"; |
174 |
< |
$self->{switch}->parse("makebuild"); # sort out supported tags |
175 |
< |
if ( $numbins > 0 ) { |
176 |
< |
print GNUmakefile <<ENDTEXT; |
177 |
< |
ifndef BINMODE |
178 |
< |
help:: |
179 |
< |
\t\@echo Generic Binary targets |
180 |
< |
\t\@echo ---------------------- |
181 |
< |
endif |
182 |
< |
ENDTEXT |
183 |
< |
foreach $target ( keys %$targettypes ) { |
184 |
< |
print GNUmakefile <<ENDTEXT; |
185 |
< |
ifndef BINMODE |
186 |
< |
help:: |
187 |
< |
\t\@echo $target |
188 |
< |
endif |
189 |
< |
ENDTEXT |
190 |
< |
} |
218 |
> |
$ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename, |
219 |
> |
$self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk"); |
220 |
> |
} |
221 |
> |
|
222 |
> |
sub classname { |
223 |
> |
my $self=shift; |
224 |
> |
if ( @_ ) { |
225 |
> |
$self->{classname}=shift; |
226 |
|
} |
227 |
< |
close GNUmakefile; |
227 |
> |
return $self->{classname}; |
228 |
|
} |
229 |
|
|
230 |
|
sub ParseBuildFile_Export { |
306 |
|
|
307 |
|
if ( $self->{Arch} ) { |
308 |
|
if ( defined $$hashref{'type'} ) { |
309 |
< |
$ClassName=$$hashref{'type'}; |
309 |
> |
$self->classname($$hashref{'type'}); |
310 |
|
} |
311 |
|
} |
312 |
|
} |
332 |
|
my $hashref=shift; |
333 |
|
|
334 |
|
$self->{switch}->checktag($name,$hashref,'class'); |
335 |
+ |
$self->{switch}->checktag($name,$hashref,'id'); |
336 |
|
if ( $self->{Arch} ) { |
337 |
|
|
338 |
|
# -- determine the build products name |
418 |
|
# print $typefile "\t\$(_quietbuild_)"; |
419 |
|
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
420 |
|
# print $typefile "\t\$(_quietstamp_)"; |
421 |
< |
# print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
421 |
> |
# print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
422 |
|
|
423 |
|
# -- cleaning targets |
424 |
|
push @targets, "clean_$dirname"; |
520 |
|
|
521 |
|
# the binary specifics makefile |
522 |
|
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
523 |
< |
print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n"; |
523 |
> |
print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n"; |
524 |
|
|
525 |
|
# alias for bin_Insure |
526 |
|
print binGNUmakefile <<ENDTEXT; |
576 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n"; |
577 |
|
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
578 |
|
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
579 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
579 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
580 |
|
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
581 |
|
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
582 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
582 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
583 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
584 |
|
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
585 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
585 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
586 |
|
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
587 |
|
print binGNUmakefile "\t\$(CClinkCmd)\n"; |
588 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
588 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
589 |
|
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
590 |
|
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
591 |
|
print binGNUmakefile <<ENDTEXT; |
715 |
|
} |
716 |
|
} |
717 |
|
|
682 |
– |
sub CheckBuildFile { |
683 |
– |
my $self=shift; |
684 |
– |
my $classdir=shift; |
685 |
– |
my $ClassName=""; |
686 |
– |
my $thisfile="$classdir/$buildfile"; |
687 |
– |
|
688 |
– |
if ( -e $self->{localtop}."/".$thisfile ) { |
689 |
– |
$DefaultBuildfile="$self->{localtop}/$thisfile"; |
690 |
– |
$self->ParseBuildFile($self->{localtop}, $classdir, $buildfile); |
691 |
– |
} |
692 |
– |
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) { |
693 |
– |
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile"; |
694 |
– |
$self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile); |
695 |
– |
} |
696 |
– |
return $ClassName; |
697 |
– |
} |
698 |
– |
|
718 |
|
# List association groups between <AssociateGroup> tags |
719 |
|
# seperated by newlines or spaces |
720 |
|
sub AssociateGroup { |
959 |
|
} |
960 |
|
} |
961 |
|
} |
962 |
+ |
|
963 |
+ |
sub Store_start { |
964 |
+ |
my $self=shift; |
965 |
+ |
my $name=shift; |
966 |
+ |
my $hashref=shift; |
967 |
+ |
|
968 |
+ |
if ( $self->{Arch} ) { |
969 |
+ |
$self->{switch}->checktag( $name, $hashref, 'name' ); |
970 |
+ |
|
971 |
+ |
# -- store creation |
972 |
+ |
my $dir=$$hashref{'name'}; |
973 |
+ |
AddDir::adddir($self->{area}->location()."/".$dir); |
974 |
+ |
if ( exists $$hashref{'type'} ) { |
975 |
+ |
# -- architecture specific store |
976 |
+ |
if ( $$hashref{'type'}=~/^arch/i ) { |
977 |
+ |
$dir=$dir."/".$ENV{SCRAM_ARCH}; |
978 |
+ |
AddDir::adddir($self->{area}->location()."/".$dir); |
979 |
+ |
} |
980 |
+ |
else { |
981 |
+ |
$self->parseerror("Unknown type in <$name> tag"); |
982 |
+ |
} |
983 |
+ |
} |
984 |
+ |
|
985 |
+ |
# -- set make variables for the store |
986 |
+ |
print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n"; |
987 |
+ |
print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=". |
988 |
+ |
$self->{localtop}."/".$dir."\n"; |
989 |
+ |
print GNUmakefile "VPATH+=".$self->{localtop} |
990 |
+ |
."/".$dir.":".$self->{releasetop}."/".$dir."\n"; |
991 |
+ |
} |
992 |
+ |
} |
993 |
+ |
|
994 |
+ |
sub DropDown { |
995 |
+ |
my $self=shift; |
996 |
+ |
my $name=shift; |
997 |
+ |
my $hashref=shift; |
998 |
+ |
|
999 |
+ |
if ( $self->{Arch} ) { |
1000 |
+ |
# - default values must always be specified |
1001 |
+ |
$self->{switch}->checktag( $name, $hashref, 'defaults' ); |
1002 |
+ |
my @blockdirs=split /,/ , $$hashref{'defaults'}; |
1003 |
+ |
$self->{block}->defaultblocks(@blockdirs); |
1004 |
+ |
} |
1005 |
+ |
} |