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 |
+ |
# -- 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 |
|
} |
130 |
– |
$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}="$ENV{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 |
|
|
214 |
|
# $self->{switch}->{Strict_no_cr}='no'; |
215 |
|
#open a temporary gnumakefile to store output. |
216 |
|
use Utilities::AddDir; |
217 |
< |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}"); |
218 |
< |
my $fh=FileHandle->new(); |
219 |
< |
open ( $fh, ">$ENV{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"; |
169 |
< |
} |
170 |
< |
# print "writing to :\n". |
171 |
< |
# "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n"; |
172 |
< |
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"; |
173 |
< |
$self->{switch}->parse("makebuild"); # sort out supported tags |
174 |
< |
if ( $numbins > 0 ) { |
175 |
< |
print GNUmakefile <<ENDTEXT; |
176 |
< |
ifndef BINMODE |
177 |
< |
help:: |
178 |
< |
\t\@echo Generic Binary targets |
179 |
< |
\t\@echo ---------------------- |
180 |
< |
endif |
181 |
< |
ENDTEXT |
182 |
< |
foreach $target ( keys %$targettypes ) { |
183 |
< |
print GNUmakefile <<ENDTEXT; |
184 |
< |
ifndef BINMODE |
185 |
< |
help:: |
186 |
< |
\t\@echo $target |
187 |
< |
endif |
188 |
< |
ENDTEXT |
189 |
< |
} |
217 |
> |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
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 |
380 |
|
# -- create a new directory for each type |
381 |
|
push @targets, $pattern; |
382 |
|
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
383 |
< |
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
383 |
> |
my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
384 |
|
my $makefile=$here."/BuildFile.mk"; |
385 |
|
# AddDir::adddir($here); |
386 |
|
|
403 |
|
print $fh "\t cd $dirname; \\\n"; |
404 |
|
print $fh "\t echo include ".$self->{currentenv}." > ". |
405 |
|
"$makefile; \\\n"; |
406 |
< |
print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}. |
406 |
> |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
407 |
|
" >> $makefile; \\\n"; |
408 |
|
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
409 |
|
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
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"; |
469 |
|
|
470 |
|
# Create a new directory for each binary target |
471 |
|
my $dirname="bin_".$$hashref{name}; |
472 |
< |
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
472 |
> |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
473 |
|
open (binGNUmakefile, |
474 |
< |
">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/". |
474 |
> |
">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/". |
475 |
|
"BuildFile.mk $!\n"; |
476 |
|
|
477 |
|
# Create the link targets |
487 |
|
ifndef BINMODE |
488 |
|
|
489 |
|
define stepdown_$$hashref{'name'} |
490 |
< |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
491 |
< |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
492 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
490 |
> |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
491 |
> |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
492 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
493 |
|
fi |
494 |
|
endef |
495 |
|
|
496 |
|
define stepdown2_$$hashref{'name'} |
497 |
< |
if [ -d "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
498 |
< |
cd $ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
499 |
< |
\$(MAKE) BINMODE=true LatestBuildFile=$ENV{LOCALTOP}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
497 |
> |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
498 |
> |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
499 |
> |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
500 |
|
fi |
501 |
|
|
502 |
|
endef |
520 |
|
|
521 |
|
# the binary specifics makefile |
522 |
|
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
523 |
< |
print binGNUmakefile "VPATH+=$ENV{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 |
|
|
681 |
– |
sub CheckBuildFile { |
682 |
– |
my $self=shift; |
683 |
– |
my $classdir=shift; |
684 |
– |
my $ClassName=""; |
685 |
– |
my $thisfile="$classdir/$buildfile"; |
686 |
– |
|
687 |
– |
if ( -e $ENV{LOCALTOP}."/".$thisfile ) { |
688 |
– |
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile"; |
689 |
– |
$self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile); |
690 |
– |
} |
691 |
– |
elsif ( -e $ENV{RELEASETOP}."/".$thisfile ) { |
692 |
– |
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile"; |
693 |
– |
$self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile); |
694 |
– |
} |
695 |
– |
return $ClassName; |
696 |
– |
} |
697 |
– |
|
718 |
|
# List association groups between <AssociateGroup> tags |
719 |
|
# seperated by newlines or spaces |
720 |
|
sub AssociateGroup { |
910 |
|
$self->{envnum}++; |
911 |
|
|
912 |
|
# open a new Environment File |
913 |
< |
my $envfile="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_". |
913 |
> |
my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_". |
914 |
|
$self->{envnum}.".mk"; |
915 |
|
use FileHandle; |
916 |
|
my $fh=FileHandle->new(); |
920 |
|
|
921 |
|
# include the approprate environment file |
922 |
|
if ( $self->{envlevel} == 0 ) { |
923 |
< |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/". |
923 |
> |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
924 |
|
$self->{path}."/BuildFile.mk\n"; |
925 |
|
} |
926 |
|
else { |
927 |
< |
print GNUmakefile "include $ENV{LOCALTOP}/$ENV{INTwork}/". |
927 |
> |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
928 |
|
$self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n"; |
929 |
|
} |
930 |
|
$self->{envlevel}++; |
931 |
|
$self->{Envlevels}[$self->{envlevel}]=$self->{envnum}; |
932 |
< |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
932 |
> |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
933 |
|
} |
934 |
|
} |
935 |
|
|
949 |
|
close $fd; |
950 |
|
*GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}]; |
951 |
|
if ( $self->{envlevel} < 1 ) { |
952 |
< |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/". |
952 |
> |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
953 |
|
"BuildFile.mk"; |
954 |
|
} |
955 |
|
else { |
956 |
|
$self->{currentenv}= |
957 |
< |
"$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_". |
957 |
> |
$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_". |
958 |
|
$self->{Envlevels}[$self->{envlevel}]; |
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 |
+ |
} |