9 |
|
# ignore() : return 1 if directory should be ignored 0 otherwise |
10 |
|
|
11 |
|
package BuildSystem::BuildFile; |
12 |
+ |
use Utilities::Verbose; |
13 |
|
use ActiveDoc::SimpleDoc; |
14 |
|
use BuildSystem::ToolBox; |
15 |
|
require 5.004; |
16 |
+ |
@ISA=qw(Utilities::Verbose); |
17 |
|
|
18 |
|
BEGIN { |
19 |
|
$buildfile="BuildFile"; |
31 |
|
|
32 |
|
sub ignore { |
33 |
|
my $self=shift; |
34 |
+ |
$self->verbose(">> ignore......<<"); |
35 |
+ |
|
36 |
|
return (defined $self->{ignore})?$self->{ignore}:0; |
37 |
|
} |
38 |
|
|
40 |
|
my $self=shift; |
41 |
|
my $switch=ActiveDoc::SimpleDoc->new(); |
42 |
|
my $parse="makebuild"; |
43 |
+ |
$self->verbose(">> _initswitcher: <<"); |
44 |
|
$switch->newparse($parse); |
45 |
|
$switch->addignoretags($parse); |
46 |
|
$self->_commontags($switch,$parse); |
88 |
|
my $self=shift; |
89 |
|
my $switch=shift; |
90 |
|
my $parse=shift; |
91 |
< |
|
91 |
> |
|
92 |
> |
$self->verbose(">> _commontags: SW ".$switch." PARSE ".$parse." <<"); |
93 |
> |
|
94 |
|
$switch->grouptag("Export",$parse); |
95 |
|
$switch->addtag($parse,"Use",\&Use_start,$self, |
96 |
|
\&OutToMakefile, $self, |
130 |
|
else { |
131 |
|
$fullfilename=$filename; |
132 |
|
} |
133 |
+ |
|
134 |
+ |
$self->verbose(">> ParseBuildFile: FN ".$fullfilename." <<"); |
135 |
+ |
|
136 |
|
$self->{path}=$path; |
127 |
– |
#print "Processing $fullfilename\n"; |
137 |
|
$numbins=0; |
138 |
|
$self->{envnum}=0; |
139 |
|
$self->{envlevel}=0; |
142 |
|
$self->{switch}=$self->_initswitcher(); |
143 |
|
$self->{switch}->filetoparse($fullfilename); |
144 |
|
|
145 |
< |
# $self->{switch}->{Strict_no_cr}='no'; |
137 |
< |
#open a temporary gnumakefile to store output. |
145 |
> |
# open a temporary gnumakefile to store output. |
146 |
|
use Utilities::AddDir; |
147 |
|
AddDir::adddir("$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}"); |
148 |
|
my $fh=FileHandle->new(); |
154 |
|
if ( -e $ENV{LatestBuildFile} ) { |
155 |
|
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
156 |
|
} |
157 |
< |
# print "writing to :\n". |
150 |
< |
# "$ENV{LOCALTOP}/$ENV{INTwork}/$self->{path}/BuildFile.mk\n"; |
157 |
> |
|
158 |
|
$ENV{LatestBuildFile}="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/BuildFile.mk"; |
159 |
|
$self->{switch}->parse("makebuild"); # sort out supported tags |
160 |
|
if ( $numbins > 0 ) { |
180 |
|
sub ParseBuildFile_Export { |
181 |
|
my $self=shift; |
182 |
|
my $filename=shift; |
183 |
+ |
|
184 |
+ |
$self->verbose(">> ParseBuildFile_Export: FN ".$filename." <<"); |
185 |
+ |
|
186 |
|
my $bf=BuildSystem::BuildFile->new($self->{toolbox}); |
187 |
|
if ( defined $self->{remoteproject} ) { |
188 |
|
$bf->{remoteproject}=$self->{remoteproject}; |
194 |
|
sub _location { |
195 |
|
my $self=shift; |
196 |
|
use File::Basename; |
197 |
< |
|
197 |
> |
$self->verbose(">> _location: <<"); |
198 |
|
return dirname($self->{switch}->filetoparse()); |
199 |
|
} |
200 |
|
|
201 |
|
sub _parseexport { |
202 |
|
my $self=shift; |
203 |
|
my $filename=shift; |
204 |
< |
|
204 |
> |
$self->verbose(">> _parseexport: FN ".$filename." <<"); |
205 |
> |
|
206 |
|
my $switchex=ActiveDoc::SimpleDoc->new(); |
207 |
|
$switchex->filetoparse($filename); |
208 |
|
$switchex->newparse("export"); |
213 |
|
\&export_end_export,$self); |
214 |
|
$self->_commontags($switchex,"export"); |
215 |
|
$switchex->allowgroup("__export","export"); |
205 |
– |
# $switchex->{Strict_no_cr}='no'; |
216 |
|
$self->{switch}=$switchex; |
217 |
|
$switchex->parse("export"); # sort out supported tags |
218 |
|
} |
220 |
|
sub _pushremoteproject { |
221 |
|
my $self=shift; |
222 |
|
my $path=shift; |
223 |
+ |
|
224 |
+ |
$self->verbose(">> _pushremoteproject: PATH ".$path." <<"); |
225 |
|
|
226 |
|
if ( defined $self->{remoteproject} ) { |
227 |
|
push @{$self->{rpstack}}, $self->{remoteproject}; |
231 |
|
|
232 |
|
sub _popremoteproject { |
233 |
|
my $self=shift; |
234 |
+ |
$self->verbose(">> _popremoteproject: <<"); |
235 |
+ |
|
236 |
|
if ( $#{$self->{rpstack}} >=0 ) { |
237 |
|
$self->{remoteproject}=pop @{$self->{rpstack}}; |
238 |
|
} |
243 |
|
|
244 |
|
sub _toolmapper { |
245 |
|
my $self=shift; |
246 |
+ |
|
247 |
|
if ( ! defined $self->{mapper} ) { |
248 |
|
require BuildSystem::ToolMapper; |
249 |
|
$self->{mapper}=BuildSystem::ToolMapper->new(); |
250 |
|
} |
251 |
+ |
$self->verbose(">> _toolmapper: TM ".$self->{mapper}."<<"); |
252 |
|
return $self->{mapper}; |
253 |
|
} |
254 |
|
|
262 |
|
my $self=shift; |
263 |
|
my $name=shift; |
264 |
|
my $hashref=shift; |
265 |
+ |
|
266 |
+ |
$self->verbose(">> Classs_StartTag: NM ".$name." <<"); |
267 |
|
|
268 |
|
if ( $self->{Arch} ) { |
269 |
|
if ( defined $$hashref{'type'} ) { |
272 |
|
} |
273 |
|
} |
274 |
|
|
275 |
< |
sub IncludePath_Start { |
276 |
< |
my $self=shift; |
277 |
< |
my $name=shift; |
278 |
< |
my $hashref=shift; |
279 |
< |
|
280 |
< |
$self->{switch}->checktag( $name, $hashref, 'path'); |
281 |
< |
if ( $self->{Arch} ) { |
282 |
< |
print GNUmakefile "INCLUDE+=".$self->_location()."/". |
283 |
< |
$$hashref{'path'}."\n"; |
284 |
< |
} |
285 |
< |
} |
275 |
> |
sub IncludePath_Start |
276 |
> |
{ |
277 |
> |
my $self=shift; |
278 |
> |
my $name=shift; |
279 |
> |
my $hashref=shift; |
280 |
> |
|
281 |
> |
$self->verbose(">> IncludePath_Start: NM ".$name." <<"); |
282 |
> |
|
283 |
> |
$self->{switch}->checktag( $name, $hashref, 'path'); |
284 |
> |
if ( $self->{Arch} ) |
285 |
> |
{ |
286 |
> |
print GNUmakefile "INCLUDE:=\$(filter-out ".$self->_location()."/".$$hashref{'path'}.",\$(INCLUDE))","\n"; |
287 |
> |
print GNUmakefile "INCLUDE+=".$self->_location()."/".$$hashref{'path'}."\n"; |
288 |
> |
} |
289 |
> |
} |
290 |
|
|
291 |
|
# |
292 |
|
# generic build tag |
296 |
|
my $name=shift; |
297 |
|
my $hashref=shift; |
298 |
|
|
299 |
+ |
$self->verbose(">> Build_start: NM ".$name." <<"); |
300 |
+ |
|
301 |
|
$self->{switch}->checktag($name,$hashref,'class'); |
302 |
|
if ( $self->{Arch} ) { |
303 |
|
|
308 |
|
} |
309 |
|
else { |
310 |
|
$self->{switch}->parseerror("No name specified for build product"); |
287 |
– |
#$name="\$(buildname)"; |
311 |
|
} |
312 |
|
|
313 |
|
# -- check we have a lookup for the class type |
347 |
|
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
348 |
|
my $here="$ENV{LOCALTOP}/$ENV{INTwork}/".$self->{path}."/".$dirname; |
349 |
|
my $makefile=$here."/BuildFile.mk"; |
327 |
– |
# AddDir::adddir($here); |
350 |
|
|
351 |
|
# -- create link targets to the directory |
352 |
|
push @targets, $dirname; |
378 |
|
} |
379 |
|
print $fh "\tfi\n"; |
380 |
|
print $fh "\n"; |
359 |
– |
# print $typefile "$name :\n"; |
360 |
– |
# print $typefile "\t\$(_quietbuild_)"; |
361 |
– |
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
362 |
– |
# print $typefile "\t\$(_quietstamp_)"; |
363 |
– |
# print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
381 |
|
|
382 |
|
# -- cleaning targets |
383 |
|
push @targets, "clean_$dirname"; |
418 |
|
my $tool; |
419 |
|
my $filename; |
420 |
|
my $objectname; |
421 |
+ |
|
422 |
+ |
$self->verbose(">> <<"); |
423 |
|
|
424 |
|
$self->{switch}->checktag($name,$hashref,'file'); |
425 |
|
if ( $self->{Arch} ) { |
582 |
|
my $self=shift; |
583 |
|
my $name=shift; |
584 |
|
my $hashref=shift; |
585 |
+ |
|
586 |
+ |
$self->verbose(">> External_StartTag: NM ".$name." <<"); |
587 |
|
|
588 |
|
my $tool; |
589 |
|
if ( $self->{Arch} ) { |
637 |
|
my $name=shift; |
638 |
|
my $hashref=shift; |
639 |
|
|
640 |
+ |
$self->verbose(">> Group_start: NM ".$name." <<"); |
641 |
+ |
|
642 |
|
$self->{switch}->checktag($name, $hashref, 'name'); |
643 |
|
if ( $self->{Arch} ) { |
644 |
|
print GNUmakefile "GROUP_".$$hashref{'name'}; |
649 |
|
} |
650 |
|
} |
651 |
|
|
652 |
< |
sub Use_start { |
653 |
< |
my $self=shift; |
654 |
< |
my $name=shift; |
655 |
< |
my $hashref=shift; |
656 |
< |
my $filename; |
657 |
< |
use Utilities::SCRAMUtils; |
658 |
< |
|
659 |
< |
$self->{switch}->checktag($name, $hashref, "name"); |
660 |
< |
if ( $self->{Arch} ) { |
661 |
< |
if ( exists $$hashref{'group'} ) { |
662 |
< |
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n"; |
663 |
< |
} |
664 |
< |
if ( ! defined $self->{remoteproject} ) { |
665 |
< |
$filename=SCRAMUtils::checkfile( |
666 |
< |
"/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
667 |
< |
} |
668 |
< |
else { |
669 |
< |
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile"; |
670 |
< |
print "trying $filename\n"; |
671 |
< |
if ( ! -f $filename ) { $filename=""; }; |
672 |
< |
} |
673 |
< |
if ( $filename ne "" ) { |
674 |
< |
$self->ParseBuildFile_Export( $filename ); |
675 |
< |
} |
676 |
< |
else { |
677 |
< |
$self->{switch}->parseerror("Unable to detect Appropriate ". |
678 |
< |
"decription file for <$name name=".$$hashref{name}.">"); |
679 |
< |
} |
680 |
< |
} |
681 |
< |
} |
652 |
> |
sub Use_start |
653 |
> |
{ |
654 |
> |
my $self=shift; |
655 |
> |
my $name=shift; |
656 |
> |
my $hashref=shift; |
657 |
> |
my $filename; |
658 |
> |
use Utilities::SCRAMUtils; |
659 |
> |
|
660 |
> |
$self->verbose(">> Use_start: NM ".$name." <<"); |
661 |
> |
|
662 |
> |
$self->{switch}->checktag($name, $hashref, "name"); |
663 |
> |
if ( $self->{Arch} ) |
664 |
> |
{ |
665 |
> |
if ( exists $$hashref{'group'} ) |
666 |
> |
{ |
667 |
> |
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n"; |
668 |
> |
} |
669 |
> |
if ( ! defined $self->{remoteproject} ) |
670 |
> |
{ |
671 |
> |
$filename=SCRAMUtils::checkfile("/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
672 |
> |
} |
673 |
> |
else |
674 |
> |
{ |
675 |
> |
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile"; |
676 |
> |
print "Trying $filename\n"; |
677 |
> |
if ( ! -f $filename ) { $filename=""; }; |
678 |
> |
} |
679 |
> |
if ( $filename ne "" ) |
680 |
> |
{ |
681 |
> |
$self->ParseBuildFile_Export( $filename ); |
682 |
> |
} |
683 |
> |
else |
684 |
> |
{ |
685 |
> |
$self->{switch}->parseerror("Unable to detect Appropriate ". |
686 |
> |
"decription file for <$name name=".$$hashref{name}.">"); |
687 |
> |
} |
688 |
> |
} |
689 |
> |
} |
690 |
|
|
691 |
|
sub CheckBuildFile { |
692 |
|
my $self=shift; |
693 |
|
my $classdir=shift; |
694 |
|
my $ClassName=""; |
695 |
|
my $thisfile="$classdir/$buildfile"; |
696 |
< |
|
696 |
> |
|
697 |
|
if ( -e $ENV{LOCALTOP}."/".$thisfile ) { |
698 |
|
$DefaultBuildfile="$ENV{LOCALTOP}/$thisfile"; |
699 |
|
$self->ParseBuildFile($ENV{LOCALTOP}, $classdir, $buildfile); |
702 |
|
$DefaultBuildfile="$ENV{RELEASETOP}/$thisfile"; |
703 |
|
$self->ParseBuildFile($ENV{RELEASETOP}, $classdir, $buildfile); |
704 |
|
} |
705 |
+ |
$self->verbose(">> CheckBuildFile: FN ".$thisfile." CN ".$ClassName." <<"); |
706 |
|
return $ClassName; |
707 |
|
} |
708 |
|
|
714 |
|
my $string=shift; |
715 |
|
my $word; |
716 |
|
|
717 |
+ |
$self->verbose(">> AssociateGroup: NM ".$name." ST ".$string." <<"); |
718 |
+ |
|
719 |
|
if ( $self->{Arch} ) { |
720 |
|
foreach $word ( (split /\s/, $string) ){ |
721 |
|
chomp $word; |
732 |
|
my $name=shift; |
733 |
|
my $hashref=shift; |
734 |
|
|
735 |
+ |
$self->verbose(">> Arch_Start: NM ".$name." <<"); |
736 |
+ |
|
737 |
|
$self->{switch}->checktag($name, $hashref,'name'); |
738 |
|
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1) |
739 |
|
: ($self->{Arch}=0); |
743 |
|
sub Arch_End { |
744 |
|
my $self=shift; |
745 |
|
my $name=shift; |
746 |
+ |
|
747 |
+ |
$self->verbose(">> Arch_End: NM ".$name." <<"); |
748 |
|
|
749 |
< |
pop @{$self->{ARCHBLOCK}}; |
749 |
> |
pop @{$self->{ARCHBLOCK}}; |
750 |
|
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}]; |
751 |
|
} |
752 |
|
|
754 |
|
sub _CutBlock { |
755 |
|
my $self=shift; |
756 |
|
my $string= shift @_; |
757 |
+ |
|
758 |
+ |
$self->verbose(">> _CutBlock: ST ".$string." <<"); |
759 |
+ |
|
760 |
|
@BlockClassA = split /\//, $string; |
761 |
|
} |
762 |
|
|
764 |
|
my $self=shift; |
765 |
|
my $name=shift; |
766 |
|
my @vars=@_; |
767 |
+ |
|
768 |
+ |
$self->verbose(">> OutToMakefile: <<"); |
769 |
|
|
770 |
|
if ( $self->{Arch} ) { |
771 |
+ |
$self->verbose(">> CONT: ".$#vars." lines <<"); |
772 |
|
print GNUmakefile @vars; |
773 |
|
} |
774 |
|
} |
776 |
|
sub OutToScreen { |
777 |
|
my $name=shift; |
778 |
|
my @vars=@_; |
779 |
< |
|
779 |
> |
|
780 |
|
if ( $self->{Arch} ) { |
781 |
|
print @vars; |
782 |
|
} |
786 |
|
my $name=shift; |
787 |
|
my $hashref=shift; |
788 |
|
|
789 |
+ |
$self->verbose(">> setBlockClassPath: NM ".$name." <<"); |
790 |
+ |
|
791 |
|
$self->{switch}->checktag($name, $hashref, 'path'); |
792 |
|
$self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path}; |
793 |
|
$self->_CutBlock($$hashref{path}); |
795 |
|
|
796 |
|
sub BlockClassPath { |
797 |
|
my $self=shift; |
798 |
+ |
|
799 |
+ |
$self->verbose(">> BlockClassPath: <<"); |
800 |
+ |
|
801 |
|
return $self->{BlockClassPath}; |
802 |
|
} |
803 |
|
|
806 |
|
my $name=shift; |
807 |
|
my $hashref=shift; |
808 |
|
|
809 |
+ |
$self->verbose(">> export_start_export: NM ".$name." <<"); |
810 |
+ |
|
811 |
|
$self->{switch}->opengroup("__export"); |
812 |
|
} |
813 |
|
|
816 |
|
my $name=shift; |
817 |
|
my $hashref=shift; |
818 |
|
|
819 |
+ |
$self->verbose(">> export_start: NM ".$name." <<"); |
820 |
+ |
|
821 |
|
$self->{switch}->opengroup("__export"); |
822 |
|
if ( exists $$hashref{autoexport} ) { |
823 |
|
print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n"; |
834 |
|
|
835 |
|
sub export_end_export { |
836 |
|
my $self=shift; |
837 |
+ |
$self->verbose(">> export_end_export: <<"); |
838 |
|
$self->{switch}->closegroup("__export"); |
839 |
|
} |
840 |
|
|
841 |
|
sub export_end { |
842 |
|
my $self=shift; |
843 |
+ |
$self->verbose(">> export_end: <<"); |
844 |
|
$self->{switch}->closegroup("__export"); |
845 |
|
print GNUmakefile "endif\n"; |
846 |
|
} |
848 |
|
# |
849 |
|
# Standard lib tag |
850 |
|
# |
851 |
< |
sub lib_start { |
852 |
< |
my $self=shift; |
853 |
< |
my $name=shift; |
854 |
< |
my $hashref=shift; |
855 |
< |
|
856 |
< |
$self->{switch}->checktag($name, $hashref, 'name'); |
857 |
< |
if ( $self->{Arch} ) { |
858 |
< |
print GNUmakefile "lib+=$$hashref{name}\n"; |
859 |
< |
} |
860 |
< |
} |
851 |
> |
sub lib_start |
852 |
> |
{ |
853 |
> |
my $self=shift; |
854 |
> |
my $name=shift; |
855 |
> |
my $hashref=shift; |
856 |
> |
|
857 |
> |
$self->verbose(">> lib_start: NM ".$name." <<"); |
858 |
> |
|
859 |
> |
$self->{switch}->checktag($name, $hashref, 'name'); |
860 |
> |
|
861 |
> |
if ( $self->{Arch} ) |
862 |
> |
{ |
863 |
> |
print GNUmakefile "lib+=$$hashref{name}\n"; |
864 |
> |
} |
865 |
> |
} |
866 |
|
|
867 |
|
# |
868 |
|
# libtype specification |
871 |
|
my $self=shift; |
872 |
|
my $name=shift; |
873 |
|
my $hashref=shift; |
874 |
< |
|
874 |
> |
|
875 |
> |
$self->verbose(">> LibType_Start: NM ".$name." <<"); |
876 |
> |
|
877 |
|
if ( $self->{Arch} ) { |
878 |
|
if ( defined $self->{libtype_conext} ) { |
879 |
|
$self->{switch}->parseerror("<$name> tag cannot be specified". |
906 |
|
my $self=shift; |
907 |
|
my $name=shift; |
908 |
|
my $string=shift; |
909 |
+ |
$self->verbose(">> LibType_text: NM ".$name." <<"); |
910 |
|
|
911 |
< |
if ( $self->{Arch} ) { |
911 |
> |
if ( $self->{Arch} ) { |
912 |
|
$string=~s/\n/ /g; |
913 |
|
print GNUmakefile "libmsg::\n\t\@echo Library info: "; |
914 |
|
print GNUmakefile $string; |
920 |
|
my $self=shift; |
921 |
|
my $name=shift; |
922 |
|
|
923 |
+ |
$self->verbose(">> LibType_end: NM ".$name." <<"); |
924 |
+ |
|
925 |
|
undef $self->{libtype_conext}; |
926 |
|
} |
927 |
|
|
930 |
|
my $name=shift; |
931 |
|
my $hashref=shift; |
932 |
|
|
933 |
+ |
$self->verbose(">> Environment_start: NM ".$name." <<"); |
934 |
+ |
|
935 |
|
if ( $self->{Arch} ) { |
936 |
|
$self->{envnum}++; |
937 |
|
|
963 |
|
my $self=shift; |
964 |
|
my $fd; |
965 |
|
|
966 |
+ |
$self->verbose(">> Environment_end: NM ".$name." <<"); |
967 |
+ |
|
968 |
|
if ( $self->{Arch} ) { |
969 |
|
$self->{envlevel}--; |
970 |
|
if ( $self->{envlevel} < 0 ) { |
993 |
|
my $name=shift; |
994 |
|
my $hashref=shift; |
995 |
|
|
996 |
+ |
$self->verbose(">> Store_start: NM ".$name." <<"); |
997 |
+ |
|
998 |
|
if ( $self->{Arch} ) { |
999 |
|
$self->{switch}->checktag( $name, $hashref, 'name' ); |
1000 |
|
|
1020 |
|
."/".$dir.":".$ENV{RELEASETOP}."/".$dir."\n"; |
1021 |
|
} |
1022 |
|
} |
952 |
– |
|