23 |
|
bless $self, $class; |
24 |
|
$self->{toolbox}=shift; |
25 |
|
$self->{Arch}=1; |
26 |
< |
push @{$self->{ARCHBLOCK}}, $Arch; |
26 |
> |
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
27 |
|
return $self; |
28 |
|
} |
29 |
|
|
39 |
|
$switch->newparse($parse); |
40 |
|
$switch->addignoretags($parse); |
41 |
|
$self->_commontags($switch,$parse); |
42 |
+ |
$switch->addtag($parse,"Build", \&Build_start, $self); |
43 |
|
$switch->addtag($parse,"none", |
44 |
|
\&OutToMakefile,$self, |
45 |
|
\&OutToMakefile, $self, |
51 |
|
$switch->addtag($parse,"LibType", |
52 |
|
\&LibType_Start,$self, |
53 |
|
\&LibType_text, $self, |
54 |
< |
"",$self); |
54 |
> |
\&LibType_end,$self); |
55 |
|
$switch->addtag($parse,"ConfigurationClass", |
56 |
|
\&Class_StartTag,$self, |
57 |
|
\&OutToMakefile, $self, |
94 |
|
"", $self); |
95 |
|
$switch->addtag($parse,"lib", |
96 |
|
\&lib_start,$self, |
97 |
< |
\&OutToScreen, $self, |
97 |
> |
\&OutToMakefile, $self, |
98 |
|
"", $self); |
99 |
|
$switch->addtag($parse,"Architecture", |
100 |
|
\&Arch_Start,$self, |
101 |
|
\&OutToMakefile, $self, |
102 |
|
\&Arch_End,$self); |
103 |
+ |
$switch->addtag($parse,"INCLUDE_PATH", |
104 |
+ |
\&IncludePath_Start,$self, |
105 |
+ |
\&OutToMakefile, $self, |
106 |
+ |
"",$self); |
107 |
|
return $switch; |
108 |
|
} |
109 |
|
|
112 |
|
my $base=shift; |
113 |
|
my $path=shift; |
114 |
|
my $filename=shift @_; |
115 |
< |
my $fullfilename="$base/$path/$filename"; |
115 |
> |
my $fullfilename; |
116 |
> |
if ( $filename!~/^\// ) { |
117 |
> |
$fullfilename="$base/$path/$filename"; |
118 |
> |
} |
119 |
> |
else { |
120 |
> |
$fullfilename=$filename; |
121 |
> |
} |
122 |
|
$self->{path}=$path; |
123 |
|
#print "Processing $fullfilename\n"; |
124 |
|
$numbins=0; |
125 |
|
$self->{envnum}=0; |
126 |
|
$self->{envlevel}=0; |
127 |
< |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk"; |
127 |
> |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/". |
128 |
> |
"BuildFile.mk"; |
129 |
|
$self->{switch}=$self->_initswitcher(); |
130 |
|
$self->{switch}->filetoparse($fullfilename); |
131 |
|
|
134 |
|
use Utilities::AddDir; |
135 |
|
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}"); |
136 |
|
my $fh=FileHandle->new(); |
137 |
< |
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk" |
138 |
< |
) or die 'Unable to open /$ENV{INTwork}/$self->{path}/BuildFile.mk $!\n'; |
137 |
> |
open ( $fh, ">$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk" |
138 |
> |
) or die 'Unable to open /$ENV{INTwork}/".$self->{path}."/BuildFile.mk $!\n'; |
139 |
|
@{$self->{filehandlestack}}=($fh); |
140 |
|
# make an alias |
141 |
|
*GNUmakefile=$fh; |
144 |
|
} |
145 |
|
# print "writing to :\n". |
146 |
|
# "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n"; |
147 |
< |
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk"; |
147 |
> |
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"; |
148 |
|
$self->{switch}->parse("makebuild"); # sort out supported tags |
149 |
|
if ( $numbins > 0 ) { |
150 |
|
print GNUmakefile <<ENDTEXT; |
169 |
|
sub ParseBuildFile_Export { |
170 |
|
my $self=shift; |
171 |
|
my $filename=shift; |
172 |
< |
my $bf=BuildSystem::BuildFile->new(); |
172 |
> |
my $bf=BuildSystem::BuildFile->new($self->{toolbox}); |
173 |
|
if ( defined $self->{remoteproject} ) { |
174 |
|
$bf->{remoteproject}=$self->{remoteproject}; |
175 |
|
} |
177 |
|
undef $bf; |
178 |
|
} |
179 |
|
|
180 |
+ |
sub _location { |
181 |
+ |
my $self=shift; |
182 |
+ |
use File::Basename; |
183 |
+ |
|
184 |
+ |
return dirname($self->{switch}->filetoparse()); |
185 |
+ |
} |
186 |
+ |
|
187 |
|
sub _parseexport { |
188 |
|
my $self=shift; |
189 |
|
my $filename=shift; |
223 |
|
} |
224 |
|
} |
225 |
|
|
226 |
+ |
sub _toolmapper { |
227 |
+ |
my $self=shift; |
228 |
+ |
if ( ! defined $self->{mapper} ) { |
229 |
+ |
require BuildSystem::ToolMapper; |
230 |
+ |
$self->{mapper}=BuildSystem::ToolMapper->new(); |
231 |
+ |
} |
232 |
+ |
return $self->{mapper}; |
233 |
+ |
} |
234 |
+ |
|
235 |
+ |
|
236 |
|
# ---- Tag routines |
237 |
|
|
238 |
|
#-- Override a class type with the <ConfigurationClass type=xxx> tag |
244 |
|
my $hashref=shift; |
245 |
|
|
246 |
|
if ( $self->{Arch} ) { |
247 |
< |
if ( defined $$hashref{'type'} ) { |
247 |
> |
if ( defined $$hashref{'type'} ) { |
248 |
|
$ClassName=$$hashref{'type'}; |
249 |
< |
} |
249 |
> |
} |
250 |
|
} |
251 |
|
} |
252 |
|
|
253 |
+ |
sub IncludePath_Start { |
254 |
+ |
my $self=shift; |
255 |
+ |
my $name=shift; |
256 |
+ |
my $hashref=shift; |
257 |
+ |
|
258 |
+ |
$self->{switch}->checktag( $name, $hashref, 'path'); |
259 |
+ |
if ( $self->{Arch} ) { |
260 |
+ |
print GNUmakefile "INCLUDE+=".$self->_location()."/". |
261 |
+ |
$$hashref{'path'}."\n"; |
262 |
+ |
} |
263 |
+ |
} |
264 |
+ |
|
265 |
+ |
# |
266 |
+ |
# generic build tag |
267 |
+ |
# |
268 |
+ |
sub Build_start { |
269 |
+ |
my $self=shift; |
270 |
+ |
my $name=shift; |
271 |
+ |
my $hashref=shift; |
272 |
+ |
|
273 |
+ |
$self->{switch}->checktag($name,$hashref,'class'); |
274 |
+ |
if ( $self->{Arch} ) { |
275 |
+ |
|
276 |
+ |
# -- determine the build products name |
277 |
+ |
my $name; |
278 |
+ |
if ( exists $$hashref{'name'} ) { |
279 |
+ |
$name=$$hashref{'name'}; |
280 |
+ |
} |
281 |
+ |
else { |
282 |
+ |
$self->{switch}->parseerror("No name specified for build product"); |
283 |
+ |
#$name="\$(buildname)"; |
284 |
+ |
} |
285 |
+ |
|
286 |
+ |
# -- check we have a lookup for the class type |
287 |
+ |
my $mapper=$self->_toolmapper(); |
288 |
+ |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
289 |
+ |
$self->{switch}->parseerror("Unknown class : ".$$hashref{'class'}); |
290 |
+ |
} |
291 |
+ |
else { |
292 |
+ |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
293 |
+ |
my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'}); |
294 |
+ |
|
295 |
+ |
my $fh=$self->{filehandlestack}[0]; |
296 |
+ |
my @targets=(); |
297 |
+ |
|
298 |
+ |
# -- generate generic targets |
299 |
+ |
print $fh "ifndef _BuildLink_\n"; |
300 |
+ |
print $fh "# -- Generic targets\n"; |
301 |
+ |
push @targets, $$hashref{'class'}; |
302 |
+ |
foreach $dtype ( @deftypes ) { |
303 |
+ |
print $fh $$hashref{'class'}."::".$$hashref{'class'}."_". |
304 |
+ |
$dtype."\n"; |
305 |
+ |
} |
306 |
+ |
print $fh "\n"; |
307 |
+ |
|
308 |
+ |
# -- generate targets for each type |
309 |
+ |
foreach $type ( @types ) { |
310 |
+ |
|
311 |
+ |
# -- generic name for each type |
312 |
+ |
my $pattern=$$hashref{'class'}."_".$type; |
313 |
+ |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
314 |
+ |
print $fh "# ------ $pattern rules ---------------\n"; |
315 |
+ |
print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}. |
316 |
+ |
"_".$type."_$name\n\n"; |
317 |
+ |
|
318 |
+ |
# -- create a new directory for each type |
319 |
+ |
push @targets, $pattern; |
320 |
+ |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
321 |
+ |
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
322 |
+ |
my $makefile=$here."/BuildFile.mk"; |
323 |
+ |
# AddDir::adddir($here); |
324 |
+ |
|
325 |
+ |
# -- create link targets to the directory |
326 |
+ |
push @targets, $dirname; |
327 |
+ |
print $fh "# -- Link Targets to $type directories\n"; |
328 |
+ |
print $fh "$dirname: make_$dirname\n"; |
329 |
+ |
print $fh "\t\@cd $here; \\\n"; |
330 |
+ |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1". |
331 |
+ |
" workdir=$here ". |
332 |
+ |
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n"; |
333 |
+ |
|
334 |
+ |
# -- write target to make makefile for each directory |
335 |
+ |
print $fh "# -- Build target directories\n"; |
336 |
+ |
print $fh "make_$dirname:\n"; |
337 |
+ |
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n"; |
338 |
+ |
print $fh "\t if [ ! -d \"$here\" ]; then \\\n"; |
339 |
+ |
print $fh "\t mkdir $here; \\\n"; |
340 |
+ |
print $fh "\t fi;\\\n"; |
341 |
+ |
print $fh "\t cd $dirname; \\\n"; |
342 |
+ |
print $fh "\t echo include ".$self->{currentenv}." > ". |
343 |
+ |
"$makefile; \\\n"; |
344 |
+ |
print $fh "\t echo VPATH+=$ENV{LOCALTOP}/".$self->{path}. |
345 |
+ |
" >> $makefile; \\\n"; |
346 |
+ |
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
347 |
+ |
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
348 |
+ |
if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) { |
349 |
+ |
foreach $f ( @file ) { |
350 |
+ |
print $fh "\t echo -include $f >> $makefile; \\\n"; |
351 |
+ |
} |
352 |
+ |
} |
353 |
+ |
print $fh "\tfi\n"; |
354 |
+ |
print $fh "\n"; |
355 |
+ |
# print $typefile "$name :\n"; |
356 |
+ |
# print $typefile "\t\$(_quietbuild_)"; |
357 |
+ |
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
358 |
+ |
# print $typefile "\t\$(_quietstamp_)"; |
359 |
+ |
# print $typefile "$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
360 |
+ |
|
361 |
+ |
# -- cleaning targets |
362 |
+ |
push @targets, "clean_$dirname"; |
363 |
+ |
print $fh "# -- cleaning targets\n"; |
364 |
+ |
print $fh "clean::clean_$dirname\n"; |
365 |
+ |
print $fh "clean_".$dirname."::\n"; |
366 |
+ |
print $fh "\t\@echo cleaning $dirname\n"; |
367 |
+ |
print $fh "\t\@if [ -d $here ]; then \\\n"; |
368 |
+ |
print $fh "\tcd $here; \\\n"; |
369 |
+ |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=". |
370 |
+ |
$here." _BuildLink_=1 -f ". |
371 |
+ |
"\$(TOOL_HOME)/basics.mk clean; \\\n"; |
372 |
+ |
print $fh "\tfi\n\n"; |
373 |
+ |
|
374 |
+ |
|
375 |
+ |
} |
376 |
+ |
# -- help targets |
377 |
+ |
print $fh "helpheader::\n"; |
378 |
+ |
print $fh "\t\@echo Targets available:\n"; |
379 |
+ |
print $fh "\t\@echo ------------------\n\n"; |
380 |
+ |
print $fh "help::helpheader\n"; |
381 |
+ |
foreach $target ( @targets ) { |
382 |
+ |
print $fh "help::\n"; |
383 |
+ |
print $fh "\t\@echo $target\n" |
384 |
+ |
} |
385 |
+ |
print $fh "endif\n"; |
386 |
+ |
} # end else |
387 |
+ |
} |
388 |
+ |
} |
389 |
+ |
|
390 |
|
sub Bin_start { |
391 |
|
my $self=shift; |
392 |
|
my $name=shift; |
403 |
|
if ( ! defined $$hashref{name} ) { |
404 |
|
($$hashref{name}=$$hashref{file})=~s/\..*//; |
405 |
|
} |
240 |
– |
# This stuff for later |
241 |
– |
#$fileclass=$toolbox->getclass($file); |
242 |
– |
#$toolbox->maketargets("exe",$fileclass, $$hashref{name}, $file ); |
243 |
– |
|
406 |
|
($filename=$$hashref{file})=~s/\..*//; |
407 |
|
|
408 |
|
# Create a new directory for each binary target |
457 |
|
|
458 |
|
|
459 |
|
# the binary specifics makefile |
460 |
< |
print binGNUmakefile "include $currentenv\n"; |
460 |
> |
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
461 |
|
print binGNUmakefile "VPATH+=$ENV{LOCALTOP}/$self{path}\n"; |
462 |
|
|
463 |
|
# alias for bin_Insure |
514 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n"; |
515 |
|
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
516 |
|
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
517 |
< |
print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
517 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
518 |
|
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
519 |
|
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
520 |
< |
print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
520 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
521 |
|
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
522 |
|
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
523 |
< |
print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
523 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
524 |
|
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
525 |
|
print binGNUmakefile "\t\$(CClinkCmd)\n"; |
526 |
< |
print binGNUmakefile "\t\@\$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
526 |
> |
print binGNUmakefile "\t\@\$(SCRAMPERL) $(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
527 |
|
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
528 |
|
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
529 |
|
print binGNUmakefile <<ENDTEXT; |
631 |
|
|
632 |
|
$self->{switch}->checktag($name, $hashref, "name"); |
633 |
|
if ( $self->{Arch} ) { |
634 |
+ |
if ( exists $$hashref{'group'} ) { |
635 |
+ |
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n"; |
636 |
+ |
} |
637 |
|
if ( ! defined $self->{remoteproject} ) { |
638 |
|
$filename=SCRAMUtils::checkfile( |
639 |
|
"/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
678 |
|
my $string=shift; |
679 |
|
my $word; |
680 |
|
|
681 |
+ |
if ( $self->{Arch} ) { |
682 |
|
foreach $word ( (split /\s/, $string) ){ |
683 |
|
chomp $word; |
684 |
|
next if /^#/; |
686 |
|
$self->{ignore}=1; |
687 |
|
} |
688 |
|
} |
689 |
+ |
} |
690 |
|
} |
691 |
|
|
692 |
|
sub Arch_Start { |
694 |
|
my $name=shift; |
695 |
|
my $hashref=shift; |
696 |
|
|
697 |
< |
$toolswitch->checktag($name, $hashref,'name'); |
697 |
> |
$self->{switch}->checktag($name, $hashref,'name'); |
698 |
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1) |
699 |
|
: ($self->{Arch}=0); |
700 |
|
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
809 |
|
my $hashref=shift; |
810 |
|
|
811 |
|
if ( $self->{Arch} ) { |
812 |
+ |
if ( defined $self->{libtype_conext} ) { |
813 |
+ |
$self->{switch}->parseerror("<$name> tag cannot be specified". |
814 |
+ |
" without a </$name> tag to close previous context"); |
815 |
+ |
} |
816 |
+ |
else { |
817 |
+ |
$self->{libtype_conext}=1; |
818 |
|
$self->{switch}->checktag($name, $hashref, 'type'); |
819 |
|
|
820 |
|
print GNUmakefile "# Specify Library Type\n"; |
833 |
|
} |
834 |
|
print GNUmakefile "\n"; |
835 |
|
} |
836 |
+ |
} |
837 |
|
} |
838 |
+ |
|
839 |
|
sub LibType_text { |
840 |
|
my $self=shift; |
841 |
|
my $name=shift; |
849 |
|
} |
850 |
|
} |
851 |
|
|
852 |
+ |
sub LibType_end { |
853 |
+ |
my $self=shift; |
854 |
+ |
my $name=shift; |
855 |
+ |
|
856 |
+ |
undef $self->{libtype_conext}; |
857 |
+ |
} |
858 |
+ |
|
859 |
|
sub Environment_start { |
860 |
|
my $self=shift; |
861 |
|
my $name=shift; |
884 |
|
} |
885 |
|
$self->{envlevel}++; |
886 |
|
$self->{Envlevels}[$self->{envlevel}]=$self->{envnum}; |
887 |
< |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
887 |
> |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
888 |
|
} |
889 |
|
} |
890 |
|
|
904 |
|
close $fd; |
905 |
|
*GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}]; |
906 |
|
if ( $self->{envlevel} < 1 ) { |
907 |
< |
$currentenv="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk"; |
907 |
> |
$self->{currentenv}="$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/". |
908 |
> |
"BuildFile.mk"; |
909 |
|
} |
910 |
|
else { |
911 |
< |
$currentenv= |
911 |
> |
$self->{currentenv}= |
912 |
|
"$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/Env_". |
913 |
|
$self->{Envlevels}[$self->{envlevel}]; |
914 |
|
} |