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; |
27 |
|
bless $self, $class; |
28 |
|
$self->{area}=shift; |
29 |
|
$self->{toolbox}=$self->{area}->toolbox(); |
30 |
+ |
$self->{localtop}=$self->{area}->location(); |
31 |
|
$self->{Arch}=1; |
32 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
33 |
|
return $self; |
34 |
|
} |
35 |
|
|
36 |
+ |
sub buildfile { |
37 |
+ |
my $self=shift; |
38 |
+ |
if ( @_ ) { |
39 |
+ |
$self->{buildfile}=shift; |
40 |
+ |
} |
41 |
+ |
return $self->{buildfile}; |
42 |
+ |
} |
43 |
+ |
|
44 |
+ |
sub makefile { |
45 |
+ |
my $self=shift; |
46 |
+ |
if ( @_ ) { |
47 |
+ |
$self->{makefile}=shift; |
48 |
+ |
} |
49 |
+ |
return $self->{makefile}; |
50 |
+ |
} |
51 |
+ |
|
52 |
+ |
sub blockparse { |
53 |
+ |
my $self=shift; |
54 |
+ |
$self->{block}=shift; |
55 |
+ |
|
56 |
+ |
$self->{switch}=$self->_initswitcher(); |
57 |
+ |
$self->_initblockparse($self->{switch}); |
58 |
+ |
} |
59 |
+ |
|
60 |
|
sub ignore { |
61 |
|
my $self=shift; |
62 |
|
return (defined $self->{ignore})?$self->{ignore}:0; |
69 |
|
$switch->newparse($parse); |
70 |
|
$switch->addignoretags($parse); |
71 |
|
$self->_commontags($switch,$parse); |
72 |
< |
$switch->addtag($parse,"Build", \&Build_start, $self); |
72 |
> |
#$switch->addtag($parse,"Build", \&Build_start, $self); |
73 |
|
$switch->addtag($parse,"none", |
74 |
|
\&OutToMakefile,$self, |
75 |
|
\&OutToMakefile, $self, |
78 |
|
\&Bin_start,$self, |
79 |
|
\&OutToScreen, $self, |
80 |
|
"", $self); |
81 |
+ |
$switch->addtag($parse,"ProductStore", |
82 |
+ |
\&Store_start,$self, |
83 |
+ |
"", $self, |
84 |
+ |
"", $self); |
85 |
|
$switch->addtag($parse,"LibType", |
86 |
|
\&LibType_Start,$self, |
87 |
|
\&LibType_text, $self, |
109 |
|
return $switch; |
110 |
|
} |
111 |
|
|
112 |
+ |
sub _initblockparse { |
113 |
+ |
my $self=shift; |
114 |
+ |
my $switch=shift; |
115 |
+ |
|
116 |
+ |
my $parse="block"; |
117 |
+ |
$switch->newparse($parse); |
118 |
+ |
$switch->addignoretags($parse); |
119 |
+ |
$switch->addtag($parse,"DropDown", |
120 |
+ |
\&DropDown_start,$self, |
121 |
+ |
"", $self, |
122 |
+ |
"", $self); |
123 |
+ |
$switch->addtag($parse,"Build", \&Build_start, $self); |
124 |
+ |
} |
125 |
+ |
|
126 |
|
sub _commontags { |
127 |
|
my $self=shift; |
128 |
|
my $switch=shift; |
155 |
|
return $switch; |
156 |
|
} |
157 |
|
|
158 |
+ |
sub GenerateMakefile { |
159 |
+ |
my $self=shift; |
160 |
+ |
my $infile=shift; |
161 |
+ |
my $outfile=shift; |
162 |
+ |
|
163 |
+ |
$self->{switch}=$self->_initswitcher(); |
164 |
+ |
$self->{switch}->filetoparse($infile); |
165 |
+ |
|
166 |
+ |
# open a temporary gnumakefile to store output. |
167 |
+ |
my $fh=FileHandle->new(); |
168 |
+ |
open ( $fh, ">$outfile") or die "Unable to open $outfile for output ". |
169 |
+ |
"$!\n"; |
170 |
+ |
@{$self->{filehandlestack}}=($fh); |
171 |
+ |
|
172 |
+ |
# -- make an alias |
173 |
+ |
*GNUmakefile=$fh; |
174 |
+ |
if ( -e $ENV{LatestBuildFile} ) { |
175 |
+ |
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
176 |
+ |
} |
177 |
+ |
$self->{switch}->parse("makebuild"); # sort out supported tags |
178 |
+ |
close GNUmakefile; |
179 |
+ |
return $outfile; |
180 |
+ |
} |
181 |
+ |
|
182 |
|
sub ParseBuildFile { |
183 |
|
my $self=shift; |
184 |
|
my $base=shift; |
196 |
|
$numbins=0; |
197 |
|
$self->{envnum}=0; |
198 |
|
$self->{envlevel}=0; |
199 |
< |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/". |
199 |
> |
$self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
200 |
|
"BuildFile.mk"; |
201 |
+ |
$self->{currentenv}=$self->{makefile}; |
202 |
|
$self->{switch}=$self->_initswitcher(); |
203 |
|
$self->{switch}->filetoparse($fullfilename); |
204 |
|
|
205 |
|
# $self->{switch}->{Strict_no_cr}='no'; |
206 |
|
#open a temporary gnumakefile to store output. |
207 |
|
use Utilities::AddDir; |
208 |
< |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}"); |
209 |
< |
my $fh=FileHandle->new(); |
210 |
< |
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk" |
211 |
< |
) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n'; |
212 |
< |
@{$self->{filehandlestack}}=($fh); |
213 |
< |
# make an alias |
214 |
< |
*GNUmakefile=$fh; |
215 |
< |
if ( -e $ENV{LatestBuildFile} ) { |
216 |
< |
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
145 |
< |
} |
146 |
< |
# print "writing to :\n". |
147 |
< |
# "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n"; |
148 |
< |
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"; |
149 |
< |
$self->{switch}->parse("makebuild"); # sort out supported tags |
150 |
< |
if ( $numbins > 0 ) { |
151 |
< |
print GNUmakefile <<ENDTEXT; |
152 |
< |
ifndef BINMODE |
153 |
< |
help:: |
154 |
< |
\t\@echo Generic Binary targets |
155 |
< |
\t\@echo ---------------------- |
156 |
< |
endif |
157 |
< |
ENDTEXT |
158 |
< |
foreach $target ( keys %$targettypes ) { |
159 |
< |
print GNUmakefile <<ENDTEXT; |
160 |
< |
ifndef BINMODE |
161 |
< |
help:: |
162 |
< |
\t\@echo $target |
163 |
< |
endif |
164 |
< |
ENDTEXT |
165 |
< |
} |
208 |
> |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
209 |
> |
$ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename, |
210 |
> |
$self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk"); |
211 |
> |
} |
212 |
> |
|
213 |
> |
sub classname { |
214 |
> |
my $self=shift; |
215 |
> |
if ( @_ ) { |
216 |
> |
$self->{classname}=shift; |
217 |
|
} |
218 |
< |
close GNUmakefile; |
218 |
> |
return $self->{classname}; |
219 |
|
} |
220 |
|
|
221 |
|
sub ParseBuildFile_Export { |
297 |
|
|
298 |
|
if ( $self->{Arch} ) { |
299 |
|
if ( defined $$hashref{'type'} ) { |
300 |
< |
$ClassName=$$hashref{'type'}; |
300 |
> |
$self->classname($$hashref{'type'}); |
301 |
|
} |
302 |
|
} |
303 |
|
} |
323 |
|
my $hashref=shift; |
324 |
|
|
325 |
|
$self->{switch}->checktag($name,$hashref,'class'); |
326 |
+ |
$self->{switch}->checktag($name,$hashref,'id'); |
327 |
|
if ( $self->{Arch} ) { |
328 |
|
|
329 |
|
# -- determine the build products name |
371 |
|
# -- create a new directory for each type |
372 |
|
push @targets, $pattern; |
373 |
|
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
374 |
< |
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
374 |
> |
my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
375 |
|
my $makefile=$here."/BuildFile.mk"; |
376 |
|
# AddDir::adddir($here); |
377 |
|
|
394 |
|
print $fh "\t cd $dirname; \\\n"; |
395 |
|
print $fh "\t echo include ".$self->{currentenv}." > ". |
396 |
|
"$makefile; \\\n"; |
397 |
< |
print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}. |
397 |
> |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
398 |
|
" >> $makefile; \\\n"; |
399 |
|
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
400 |
|
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
409 |
|
# print $typefile "\t\$(_quietbuild_)"; |
410 |
|
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
411 |
|
# print $typefile "\t\$(_quietstamp_)"; |
412 |
< |
# print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
412 |
> |
# print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
413 |
|
|
414 |
|
# -- cleaning targets |
415 |
|
push @targets, "clean_$dirname"; |
460 |
|
|
461 |
|
# Create a new directory for each binary target |
462 |
|
my $dirname="bin_".$$hashref{name}; |
463 |
< |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
463 |
> |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
464 |
|
open (binGNUmakefile, |
465 |
< |
">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/". |
465 |
> |
">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/". |
466 |
|
"BuildFile.mk $!\n"; |
467 |
|
|
468 |
|
# Create the link targets |
478 |
|
ifndef BINMODE |
479 |
|
|
480 |
|
define stepdown_$$hashref{'name'} |
481 |
< |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
482 |
< |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
483 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
481 |
> |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
482 |
> |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
483 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
484 |
|
fi |
485 |
|
endef |
486 |
|
|
487 |
|
define stepdown2_$$hashref{'name'} |
488 |
< |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
489 |
< |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
490 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
488 |
> |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
489 |
> |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
490 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
491 |
|
fi |
492 |
|
|
493 |
|
endef |
511 |
|
|
512 |
|
# the binary specifics makefile |
513 |
|
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
514 |
< |
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n"; |
514 |
> |
print binGNUmakefile "VPATH+=$self->{localtop}/$self{path}\n"; |
515 |
|
|
516 |
|
# alias for bin_Insure |
517 |
|
print binGNUmakefile <<ENDTEXT; |
567 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n"; |
568 |
|
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
569 |
|
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
570 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
570 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
571 |
|
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
572 |
|
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
573 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
573 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
574 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
575 |
|
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
576 |
< |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
576 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
577 |
|
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
578 |
|
print binGNUmakefile "\t\$(CClinkCmd)\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}.dep:$$hashref{file}\n"; |
581 |
|
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
582 |
|
print binGNUmakefile <<ENDTEXT; |
706 |
|
} |
707 |
|
} |
708 |
|
|
657 |
– |
sub CheckBuildFile { |
658 |
– |
my $self=shift; |
659 |
– |
my $classdir=shift; |
660 |
– |
my $ClassName=""; |
661 |
– |
my $thisfile="$classdir/$buildfile"; |
662 |
– |
|
663 |
– |
if ( -e $ENV{LOCALTOP}."/".$thisfile ) { |
664 |
– |
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile"; |
665 |
– |
$self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile); |
666 |
– |
} |
667 |
– |
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) { |
668 |
– |
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile"; |
669 |
– |
$self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile); |
670 |
– |
} |
671 |
– |
return $ClassName; |
672 |
– |
} |
673 |
– |
|
709 |
|
# List association groups between <AssociateGroup> tags |
710 |
|
# seperated by newlines or spaces |
711 |
|
sub AssociateGroup { |
901 |
|
$self->{envnum}++; |
902 |
|
|
903 |
|
# open a new Environment File |
904 |
< |
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_". |
904 |
> |
my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_". |
905 |
|
$self->{envnum}.".mk"; |
906 |
|
use FileHandle; |
907 |
|
my $fh=FileHandle->new(); |
911 |
|
|
912 |
|
# include the approprate environment file |
913 |
|
if ( $self->{envlevel} == 0 ) { |
914 |
< |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/". |
914 |
> |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
915 |
|
$self->{path}."/BuildFile.mk\n"; |
916 |
|
} |
917 |
|
else { |
918 |
< |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/". |
918 |
> |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
919 |
|
$self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n"; |
920 |
|
} |
921 |
|
$self->{envlevel}++; |
922 |
|
$self->{Envlevels}[$self->{envlevel}]=$self->{envnum}; |
923 |
< |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
923 |
> |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
924 |
|
} |
925 |
|
} |
926 |
|
|
940 |
|
close $fd; |
941 |
|
*GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}]; |
942 |
|
if ( $self->{envlevel} < 1 ) { |
943 |
< |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/". |
943 |
> |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
944 |
|
"BuildFile.mk"; |
945 |
|
} |
946 |
|
else { |
947 |
|
$self->{currentenv}= |
948 |
< |
"$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_". |
948 |
> |
$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_". |
949 |
|
$self->{Envlevels}[$self->{envlevel}]; |
950 |
|
} |
951 |
|
} |
952 |
|
} |
953 |
+ |
|
954 |
+ |
sub Store_start { |
955 |
+ |
my $self=shift; |
956 |
+ |
my $name=shift; |
957 |
+ |
my $hashref=shift; |
958 |
+ |
|
959 |
+ |
if ( $self->{Arch} ) { |
960 |
+ |
$self->{switch}->checktag( $name, $hashref, 'name' ); |
961 |
+ |
|
962 |
+ |
# -- store creation |
963 |
+ |
my $dir=$$hashref{'name'}; |
964 |
+ |
AddDir::adddir($self->{area}->location()."/".$dir); |
965 |
+ |
if ( exists $$hashref{'type'} ) { |
966 |
+ |
# -- architecture specific store |
967 |
+ |
if ( $$hashref{'type'}=~/^arch/i ) { |
968 |
+ |
$dir=$dir."/".$ENV{SCRAM_ARCH}; |
969 |
+ |
AddDir::adddir($self->{area}->location()."/".$dir); |
970 |
+ |
} |
971 |
+ |
else { |
972 |
+ |
$self->parseerror("Unknown type in <$name> tag"); |
973 |
+ |
} |
974 |
+ |
} |
975 |
+ |
|
976 |
+ |
# -- set make variables for the store |
977 |
+ |
print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n"; |
978 |
+ |
print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=". |
979 |
+ |
$self->{localtop}."/".$dir."\n"; |
980 |
+ |
print GNUmakefile "VPATH+=".$self->{localtop} |
981 |
+ |
."/".$dir.":".$self->{releasetop}."/".$dir."\n"; |
982 |
+ |
} |
983 |
+ |
} |
984 |
+ |
|
985 |
+ |
sub DropDown { |
986 |
+ |
my $self=shift; |
987 |
+ |
my $name=shift; |
988 |
+ |
my $hashref=shift; |
989 |
+ |
|
990 |
+ |
if ( $self->{Arch} ) { |
991 |
+ |
# - default values must always be specified |
992 |
+ |
$self->{switch}->checktag( $name, $hashref, 'defaults' ); |
993 |
+ |
my @blockdirs=split /,/ , $$hashref{'defaults'}; |
994 |
+ |
$self->{block}->defaultblocks(@blockdirs); |
995 |
+ |
} |
996 |
+ |
} |