1 |
< |
# BuildFile |
1 |
> |
#____________________________________________________________________ |
2 |
> |
# File: BuildFile.pm |
3 |
> |
#____________________________________________________________________ |
4 |
> |
# |
5 |
> |
# Author: Shaun Ashby <Shaun.Ashby@cern.ch> |
6 |
> |
# Update: 2003-12-03 19:03:15+0100 |
7 |
> |
# Revision: $Id$ |
8 |
|
# |
9 |
< |
# Interface |
10 |
< |
# --------- |
11 |
< |
# 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 |
< |
|
9 |
> |
# Copyright: 2003 (C) Shaun Ashby |
10 |
> |
# |
11 |
> |
#-------------------------------------------------------------------- |
12 |
|
package BuildSystem::BuildFile; |
16 |
– |
use ActiveDoc::SimpleDoc; |
17 |
– |
use BuildSystem::ToolBox; |
13 |
|
require 5.004; |
14 |
+ |
use Exporter; |
15 |
+ |
use ActiveDoc::SimpleDoc; |
16 |
|
|
17 |
< |
BEGIN { |
18 |
< |
$buildfile="BuildFile"; |
22 |
< |
} |
23 |
< |
|
24 |
< |
sub new { |
25 |
< |
my $class=shift; |
26 |
< |
my $self={}; |
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 |
< |
# -- set up the block parse |
66 |
< |
my $switch=$self->_initswitcher(); |
67 |
< |
my $parse="block"; |
68 |
< |
$switch->newparse($parse); |
69 |
< |
$switch->addignoretags($parse); |
70 |
< |
$switch->addtag($parse,"BuildParam", \&BuildBlock_start, $self); |
71 |
< |
|
72 |
< |
# -- parse away |
73 |
< |
$self->{switch}->parse("block"); |
74 |
< |
} |
75 |
< |
|
76 |
< |
sub Parsetofh { |
77 |
< |
my $self=shift; |
78 |
< |
my $fh=shift; |
79 |
< |
$self->{buildblock}=shift; |
80 |
< |
|
81 |
< |
# -- set up for parse |
82 |
< |
@{$self->{filehandlestack}}=($fh); |
83 |
< |
$self->{switch}->filetoparse($self->buildfile()); |
84 |
< |
*GNUmakefile=$fh; |
85 |
< |
|
86 |
< |
# -- generate makefile |
87 |
< |
$self->{switch}->parse("makebuild"); # sort out supported tags |
88 |
< |
|
89 |
< |
# -- Clean up |
90 |
< |
close GNUmakefile; |
91 |
< |
} |
92 |
< |
|
93 |
< |
sub ignore { |
94 |
< |
my $self=shift; |
95 |
< |
return (defined $self->{ignore})?$self->{ignore}:0; |
96 |
< |
} |
97 |
< |
|
98 |
< |
sub _initswitcher { |
99 |
< |
my $self=shift; |
100 |
< |
my $switch=ActiveDoc::SimpleDoc->new(); |
101 |
< |
my $parse="makebuild"; |
102 |
< |
$switch->newparse($parse); |
103 |
< |
$switch->addignoretags($parse); |
104 |
< |
$self->_commontags($switch,$parse); |
105 |
< |
#$switch->addtag($parse,"Build", \&Build_start, $self); |
106 |
< |
$switch->addtag($parse,"none", |
107 |
< |
\&OutToMakefile,$self, |
108 |
< |
\&OutToMakefile, $self, |
109 |
< |
"", $self); |
110 |
< |
$switch->addtag($parse,"Bin", |
111 |
< |
\&Bin_start,$self, |
112 |
< |
\&OutToScreen, $self, |
113 |
< |
"", $self); |
114 |
< |
$switch->addtag($parse,"ProductStore", |
115 |
< |
\&Store_start,$self, |
116 |
< |
"", $self, |
117 |
< |
"", $self); |
118 |
< |
$switch->addtag($parse,"LibType", |
119 |
< |
\&LibType_Start,$self, |
120 |
< |
\&LibType_text, $self, |
121 |
< |
\&LibType_end,$self); |
122 |
< |
$switch->addtag($parse,"ConfigurationClass", |
123 |
< |
\&Class_StartTag,$self, |
124 |
< |
\&OutToMakefile, $self, |
125 |
< |
"", $self); |
126 |
< |
$switch->addtag($parse,"ClassPath", |
127 |
< |
\&setBlockClassPath,$self, |
128 |
< |
\&OutToMakefile, $self, |
129 |
< |
"", $self); |
130 |
< |
$switch->addtag($parse,"AssociateGroup", |
131 |
< |
"",$self, |
132 |
< |
\&AssociateGroup,$self, |
133 |
< |
"", $self); |
134 |
< |
$switch->addtag($parse,"Environment", |
135 |
< |
\&Environment_start,$self, |
136 |
< |
\&OutToMakefile, $self, |
137 |
< |
\&Environment_end,$self); |
138 |
< |
$switch->addtag($parse,"Export", |
139 |
< |
\&export_start,$self, |
140 |
< |
\&OutToMakefile, $self, |
141 |
< |
\&export_end,$self); |
142 |
< |
return $switch; |
143 |
< |
} |
144 |
< |
|
145 |
< |
sub _commontags { |
146 |
< |
my $self=shift; |
147 |
< |
my $switch=shift; |
148 |
< |
my $parse=shift; |
149 |
< |
|
150 |
< |
$switch->grouptag("Export",$parse); |
151 |
< |
$switch->addtag($parse,"Use",\&Use_start,$self, |
152 |
< |
\&OutToMakefile, $self, |
153 |
< |
"", $self); |
154 |
< |
$switch->addtag($parse,"Group",\&Group_start,$self, |
155 |
< |
\&OutToMakefile, $self, |
156 |
< |
"", $self); |
157 |
< |
$switch->grouptag("Group",$parse); |
158 |
< |
$switch->addtag($parse,"External", |
159 |
< |
\&External_StartTag,$self, |
160 |
< |
\&OutToMakefile, $self, |
161 |
< |
"", $self); |
162 |
< |
$switch->addtag($parse,"lib", |
163 |
< |
\&lib_start,$self, |
164 |
< |
\&OutToMakefile, $self, |
165 |
< |
"", $self); |
166 |
< |
$switch->addtag($parse,"Architecture", |
167 |
< |
\&Arch_Start,$self, |
168 |
< |
\&OutToMakefile, $self, |
169 |
< |
\&Arch_End,$self); |
170 |
< |
$switch->addtag($parse,"INCLUDE_PATH", |
171 |
< |
\&IncludePath_Start,$self, |
172 |
< |
\&OutToMakefile, $self, |
173 |
< |
"",$self); |
174 |
< |
return $switch; |
175 |
< |
} |
176 |
< |
|
177 |
< |
sub GenerateMakefile { |
178 |
< |
my $self=shift; |
179 |
< |
my $infile=shift; |
180 |
< |
my $outfile=shift; |
181 |
< |
|
182 |
< |
$self->{switch}=$self->_initswitcher(); |
183 |
< |
$self->{switch}->filetoparse($infile); |
184 |
< |
|
185 |
< |
# open a temporary gnumakefile to store output. |
186 |
< |
my $fh=FileHandle->new(); |
187 |
< |
open ( $fh, ">$outfile") or die "Unable to open $outfile for output ". |
188 |
< |
"$!\n"; |
189 |
< |
@{$self->{filehandlestack}}=($fh); |
190 |
< |
|
191 |
< |
# -- make an alias |
192 |
< |
*GNUmakefile=$fh; |
193 |
< |
if ( -e $ENV{LatestBuildFile} ) { |
194 |
< |
print GNUmakefile "include $ENV{LatestBuildFile}\n"; |
195 |
< |
} |
196 |
< |
$self->{switch}->parse("makebuild"); # sort out supported tags |
197 |
< |
close GNUmakefile; |
198 |
< |
return $outfile; |
199 |
< |
} |
200 |
< |
|
201 |
< |
sub ParseBuildFile { |
202 |
< |
my $self=shift; |
203 |
< |
my $base=shift; |
204 |
< |
my $path=shift; |
205 |
< |
my $filename=shift @_; |
206 |
< |
my $fullfilename; |
207 |
< |
if ( $filename!~/^\// ) { |
208 |
< |
$fullfilename="$base/$path/$filename"; |
209 |
< |
} |
210 |
< |
else { |
211 |
< |
$fullfilename=$filename; |
212 |
< |
} |
213 |
< |
$self->{path}=$path; |
214 |
< |
#print "Processing $fullfilename\n"; |
215 |
< |
$numbins=0; |
216 |
< |
$self->{envnum}=0; |
217 |
< |
$self->{envlevel}=0; |
218 |
< |
$self->{makefile}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
219 |
< |
"BuildFile.mk"; |
220 |
< |
$self->{currentenv}=$self->{makefile}; |
221 |
< |
$self->{switch}=$self->_initswitcher(); |
222 |
< |
$self->{switch}->filetoparse($fullfilename); |
223 |
< |
|
224 |
< |
# $self->{switch}->{Strict_no_cr}='no'; |
225 |
< |
#open a temporary gnumakefile to store output. |
226 |
< |
use Utilities::AddDir; |
227 |
< |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/$self->{path}"); |
228 |
< |
$ENV{LatestBuildFile}=$self->GenerateMakefile($fullfilename, |
229 |
< |
$self->{localtop}."/".$ENV{INTwork}."/".$self->{path}."/BuildFile.mk"); |
230 |
< |
} |
231 |
< |
|
232 |
< |
sub classname { |
233 |
< |
my $self=shift; |
234 |
< |
if ( @_ ) { |
235 |
< |
$self->{classname}=shift; |
236 |
< |
} |
237 |
< |
return $self->{classname}; |
238 |
< |
} |
239 |
< |
|
240 |
< |
sub ParseBuildFile_Export { |
241 |
< |
my $self=shift; |
242 |
< |
my $filename=shift; |
243 |
< |
my $bf=BuildSystem::BuildFile->new($self->{area}); |
244 |
< |
if ( defined $self->{remoteproject} ) { |
245 |
< |
$bf->{remoteproject}=$self->{remoteproject}; |
246 |
< |
} |
247 |
< |
$bf->_parseexport($filename); |
248 |
< |
undef $bf; |
249 |
< |
} |
250 |
< |
|
251 |
< |
sub _location { |
252 |
< |
my $self=shift; |
253 |
< |
use File::Basename; |
254 |
< |
|
255 |
< |
return dirname($self->{switch}->filetoparse()); |
256 |
< |
} |
257 |
< |
|
258 |
< |
sub _parseexport { |
259 |
< |
my $self=shift; |
260 |
< |
my $filename=shift; |
261 |
< |
|
262 |
< |
my $switchex=ActiveDoc::SimpleDoc->new(); |
263 |
< |
$switchex->filetoparse($filename); |
264 |
< |
$switchex->newparse("export"); |
265 |
< |
$switchex->addignoretags("export"); |
266 |
< |
$switchex->addtag("export","Export", |
267 |
< |
\&export_start_export,$self, |
268 |
< |
\&OutToMakefile, $self, |
269 |
< |
\&export_end_export,$self); |
270 |
< |
$self->_commontags($switchex,"export"); |
271 |
< |
$switchex->allowgroup("__export","export"); |
272 |
< |
# $switchex->{Strict_no_cr}='no'; |
273 |
< |
$self->{switch}=$switchex; |
274 |
< |
$switchex->parse("export"); # sort out supported tags |
275 |
< |
} |
276 |
< |
|
277 |
< |
sub _pushremoteproject { |
278 |
< |
my $self=shift; |
279 |
< |
my $path=shift; |
280 |
< |
|
281 |
< |
if ( defined $self->{remoteproject} ) { |
282 |
< |
push @{$self->{rpstack}}, $self->{remoteproject}; |
283 |
< |
} |
284 |
< |
$self->{remoteproject}=$path; |
285 |
< |
} |
286 |
< |
|
287 |
< |
sub _popremoteproject { |
288 |
< |
my $self=shift; |
289 |
< |
if ( $#{$self->{rpstack}} >=0 ) { |
290 |
< |
$self->{remoteproject}=pop @{$self->{rpstack}}; |
291 |
< |
} |
292 |
< |
else { |
293 |
< |
undef $self->{remoteproject}; |
294 |
< |
} |
295 |
< |
} |
296 |
< |
|
297 |
< |
sub _toolmapper { |
298 |
< |
my $self=shift; |
299 |
< |
if ( ! defined $self->{mapper} ) { |
300 |
< |
require BuildSystem::ToolMapper; |
301 |
< |
$self->{mapper}=BuildSystem::ToolMapper->new(); |
302 |
< |
} |
303 |
< |
return $self->{mapper}; |
304 |
< |
} |
305 |
< |
|
306 |
< |
|
307 |
< |
# ---- Tag routines |
308 |
< |
|
309 |
< |
#-- Override a class type with the <ConfigurationClass type=xxx> tag |
310 |
< |
# the type tag will pick up a pre-defined class type from project space. |
311 |
< |
|
312 |
< |
sub Class_StartTag { |
313 |
< |
my $self=shift; |
314 |
< |
my $name=shift; |
315 |
< |
my $hashref=shift; |
316 |
< |
|
317 |
< |
if ( $self->{Arch} ) { |
318 |
< |
if ( defined $$hashref{'type'} ) { |
319 |
< |
$self->classname($$hashref{'type'}); |
320 |
< |
} |
321 |
< |
} |
322 |
< |
} |
323 |
< |
|
324 |
< |
sub IncludePath_Start { |
325 |
< |
my $self=shift; |
326 |
< |
my $name=shift; |
327 |
< |
my $hashref=shift; |
328 |
< |
|
329 |
< |
$self->{switch}->checktag( $name, $hashref, 'path'); |
330 |
< |
if ( $self->{Arch} ) { |
331 |
< |
print GNUmakefile "INCLUDE+=".$self->_location()."/". |
332 |
< |
$$hashref{'path'}."\n"; |
333 |
< |
} |
334 |
< |
} |
335 |
< |
|
336 |
< |
# |
337 |
< |
# --- <Build class=> tag |
338 |
< |
# |
339 |
< |
|
17 |
> |
@ISA=qw(Exporter); |
18 |
> |
@EXPORT_OK=qw( ); |
19 |
|
# |
20 |
< |
# Parameter collection |
21 |
< |
# |
22 |
< |
sub BuildBlock_start { |
23 |
< |
my $self=shift; |
24 |
< |
my $name=shift; |
25 |
< |
my $hashref=shift; |
26 |
< |
|
27 |
< |
|
28 |
< |
my $blockobjid=$self->__blockobjid($hashref); |
29 |
< |
|
30 |
< |
if ( $self->{Arch} ) { |
31 |
< |
|
32 |
< |
|
33 |
< |
# -- get any objects that match |
34 |
< |
my $inheritobj=$self->{block}->getobj($blockobjid); |
35 |
< |
|
36 |
< |
# -- create an object with inherited properties |
37 |
< |
my $obj; |
38 |
< |
if ( ! defined $inheritobj ) { |
39 |
< |
# -- check we have a lookup for the class type |
40 |
< |
my $mapper=$self->_toolmapper(); |
41 |
< |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
42 |
< |
$self->{switch}->parseerror("Unknown class : ". |
43 |
< |
$$hashref{'class'}); |
44 |
< |
} |
45 |
< |
$obj=BuildSystem::BuildClass->new(); |
46 |
< |
} |
47 |
< |
else { |
48 |
< |
# -- inherit the properties from class with the same id class |
49 |
< |
$obj=$inheritobj->child(); |
50 |
< |
} |
51 |
< |
|
52 |
< |
# -- add changes from our tag |
53 |
< |
$obj->paramupdate($hashref); |
54 |
< |
|
55 |
< |
# -- store the new object in the block |
56 |
< |
$self->{block}->setobj($obj,$blockobjid); |
57 |
< |
} |
58 |
< |
} |
59 |
< |
|
60 |
< |
sub BuilderClass_buildmakefile { |
61 |
< |
my $self=shift; |
62 |
< |
my $name=shift; |
63 |
< |
my $hashref=shift; |
64 |
< |
|
65 |
< |
my $blockobjid=$self->__blockobjid($hashref); |
66 |
< |
|
67 |
< |
if ( $self->{Arch} ) { |
68 |
< |
# -- get the matching block object |
69 |
< |
my $blockobj=$self->{buildblock}->getobj($blockobjid); |
70 |
< |
|
71 |
< |
# -- top level buildfile |
72 |
< |
my $fh=$self->{filehandlestack}[0]; |
73 |
< |
|
74 |
< |
# -- var initialisation |
75 |
< |
my @deftypes=(); |
76 |
< |
my $buildname=""; |
77 |
< |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
78 |
< |
|
79 |
< |
# -- error checking |
80 |
< |
if ( ! defined $blockobj->param("default") ) { |
81 |
< |
$self->error("No default build parameter defined for ". |
82 |
< |
$$hashref{'class'}." ".$$hashref{'id'}); |
83 |
< |
} |
84 |
< |
if ( ! defined $blockobj->param("name") ) { |
85 |
< |
$self->error("\"name\" parameter defined for ". |
86 |
< |
$$hashref{'class'}." ".$$hashref{'id'}); |
87 |
< |
} |
88 |
< |
|
89 |
< |
|
90 |
< |
foreach $param ( $blockobj->paramlist() ) { |
91 |
< |
# -- check for params that need special handling |
92 |
< |
if ( $param eq "default" ) { |
93 |
< |
@deftypes=split /,/, $param; |
94 |
< |
} |
95 |
< |
elsif ( $param eq "name" ) { |
96 |
< |
$buildname=$blockobj->param($param); |
97 |
< |
} |
98 |
< |
else { |
99 |
< |
# -- simple transfer of block object parameters to makefile |
100 |
< |
print $fh $param.":=".$blockobj->param($param)."\n"; |
101 |
< |
} |
102 |
< |
} |
103 |
< |
|
104 |
< |
# -- construct the targets in the top makefile |
105 |
< |
$self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes); |
106 |
< |
$self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types); |
107 |
< |
|
108 |
< |
} |
109 |
< |
} |
110 |
< |
|
111 |
< |
sub _blockobjid { |
112 |
< |
my $self=shift; |
113 |
< |
my $hashref=shift; |
114 |
< |
|
115 |
< |
$self->{switch}->checktag($name,$hashref,'class'); |
116 |
< |
$self->{switch}->checktag($name,$hashref,'id'); |
117 |
< |
my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'}; |
118 |
< |
|
119 |
< |
return $blockobjid; |
120 |
< |
} |
121 |
< |
|
122 |
< |
sub _generatedefaulttargets { |
123 |
< |
my $self=shift; |
124 |
< |
my $fh=shift; |
125 |
< |
my $class=shift; |
126 |
< |
|
127 |
< |
my @deftypes=shift; |
128 |
< |
|
129 |
< |
print $fh "# -- Default type targets\n"; |
130 |
< |
foreach $dtype ( @deftypes ) { |
131 |
< |
print $fh $class."::".$class."_".$dtype."\n"; |
132 |
< |
} |
133 |
< |
print $fh "\n"; |
134 |
< |
} |
135 |
< |
|
136 |
< |
sub _generatetypetargets { |
137 |
< |
my $self=shift; |
138 |
< |
my $fh=shift; |
139 |
< |
my $class=shift; |
140 |
< |
my $name=shift; |
141 |
< |
|
142 |
< |
my @types=shift; |
143 |
< |
|
144 |
< |
print $fh "# -- Generic type targets\n"; |
145 |
< |
foreach $type ( @types ) { |
146 |
< |
my $pattern=$class."_".$type; |
147 |
< |
my $dirname=$class."_".$type."_".$name; |
148 |
< |
my $makefile=$here."/BuildFile.mk"; |
149 |
< |
|
150 |
< |
# -- map to generic name for each type |
151 |
< |
print $fh "# ------ $pattern rules ---------------\n"; |
152 |
< |
print $fh $class."_".$type."::".$class. |
153 |
< |
"_".$type."_$name\n\n"; |
154 |
< |
|
155 |
< |
print $fh "# -- Link Targets to $type directories\n"; |
156 |
< |
print $fh "$dirname: make_$dirname\n"; |
157 |
< |
print $fh "\t\@cd $here; \\\n"; |
158 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1". |
159 |
< |
" workdir=$here ". |
160 |
< |
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n"; |
161 |
< |
|
162 |
< |
# -- write target to make makefile for each directory |
163 |
< |
print $fh "# -- Build target directories\n"; |
164 |
< |
print $fh "make_$dirname:\n"; |
165 |
< |
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n"; |
166 |
< |
print $fh "\t if [ ! -d \"$here\" ]; then \\\n"; |
167 |
< |
print $fh "\t mkdir $here; \\\n"; |
168 |
< |
print $fh "\t fi;\\\n"; |
169 |
< |
print $fh "\t cd $dirname; \\\n"; |
170 |
< |
print $fh "\t echo include ".$self->{currentenv}." > ". |
171 |
< |
"$makefile; \\\n"; |
172 |
< |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
173 |
< |
" >> $makefile; \\\n"; |
174 |
< |
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
175 |
< |
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
176 |
< |
if ( defined (my @file=$mapper->rulesfile($class)) ) { |
177 |
< |
foreach $f ( @file ) { |
178 |
< |
print $fh "\t echo -include $f >> $makefile; \\\n"; |
179 |
< |
} |
180 |
< |
} |
181 |
< |
print $fh "\tfi\n"; |
182 |
< |
print $fh "\n"; |
183 |
< |
|
184 |
< |
# -- cleaning targets |
185 |
< |
push @targets, "clean_$dirname"; |
186 |
< |
print $fh "# -- cleaning targets\n"; |
187 |
< |
print $fh "clean::clean_$dirname\n"; |
188 |
< |
print $fh "clean_".$dirname."::\n"; |
189 |
< |
print $fh "\t\@echo cleaning $dirname\n"; |
190 |
< |
print $fh "\t\@if [ -d $here ]; then \\\n"; |
191 |
< |
print $fh "\tcd $here; \\\n"; |
192 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=". |
193 |
< |
$here." _BuildLink_=1 -f ". |
194 |
< |
"\$(TOOL_HOME)/basics.mk clean; \\\n"; |
195 |
< |
print $fh "\tfi\n\n"; |
196 |
< |
|
197 |
< |
} |
198 |
< |
print $fh "\n"; |
199 |
< |
} |
20 |
> |
sub new() |
21 |
> |
############################################################### |
22 |
> |
# new # |
23 |
> |
############################################################### |
24 |
> |
# modified : Wed Dec 3 19:03:22 2003 / SFA # |
25 |
> |
# params : # |
26 |
> |
# : # |
27 |
> |
# function : # |
28 |
> |
# : # |
29 |
> |
############################################################### |
30 |
> |
{ |
31 |
> |
my $proto=shift; |
32 |
> |
my $class=ref($proto) || $proto; |
33 |
> |
$self={}; |
34 |
> |
bless $self,$class; |
35 |
> |
$self->{DEPENDENCIES} = {}; |
36 |
> |
$self->{content} = {}; |
37 |
> |
$self->{scramdoc}=ActiveDoc::SimpleDoc->new(); |
38 |
> |
$self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs'); |
39 |
> |
return $self; |
40 |
> |
} |
41 |
> |
|
42 |
> |
sub parse() |
43 |
> |
{ |
44 |
> |
my $self=shift; |
45 |
> |
my ($filename)=@_; |
46 |
> |
my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::BuildFile" version="1.0">'; |
47 |
> |
my $ftail='</doc>'; |
48 |
> |
$self->{scramdoc}->filetoparse($filename); |
49 |
> |
$self->{scramdoc}->parse("builder",$fhead,$ftail); |
50 |
> |
# We're done with the SimpleDoc object so delete it: |
51 |
> |
delete $self->{scramdoc}; |
52 |
> |
} |
53 |
> |
|
54 |
> |
sub classpath() |
55 |
> |
{ |
56 |
> |
my ($object,$name,%attributes)=@_; |
57 |
> |
# The getter part: |
58 |
> |
if (ref($object) eq __PACKAGE__) |
59 |
> |
{ |
60 |
> |
return $self->{content}->{CLASSPATH}; |
61 |
> |
} |
62 |
> |
|
63 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'}) |
64 |
> |
: push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'}); |
65 |
> |
} |
66 |
> |
|
67 |
> |
sub productstore() |
68 |
> |
{ |
69 |
> |
my ($object,$name,%attributes)=@_; |
70 |
> |
# The getter part: |
71 |
> |
if (ref($object) eq __PACKAGE__) |
72 |
> |
{ |
73 |
> |
# Return an array of ProductStore hashes: |
74 |
> |
return $self->{content}->{PRODUCTSTORE}; |
75 |
> |
} |
76 |
> |
|
77 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes) |
78 |
> |
: push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ; |
79 |
> |
} |
80 |
> |
|
81 |
> |
sub include() |
82 |
> |
{ |
83 |
> |
my $self=shift; |
84 |
> |
# Return an array of required includes: |
85 |
> |
return $self->{content}->{INCLUDE}; |
86 |
> |
} |
87 |
> |
|
88 |
> |
sub include_path() |
89 |
> |
{ |
90 |
> |
my ($object,$name,%attributes)=@_; |
91 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{INCLUDE}}, $attributes{'path'}) |
92 |
> |
: push(@{$self->{content}->{INCLUDE}}, $attributes{'path'}); |
93 |
> |
} |
94 |
> |
|
95 |
> |
sub use() |
96 |
> |
{ |
97 |
> |
my $object=shift; |
98 |
> |
# The getter part: |
99 |
> |
if (ref($object) eq __PACKAGE__) |
100 |
> |
{ |
101 |
> |
# Add or return uses (package deps): |
102 |
> |
@_ ? push(@{$self->{content}->{USE}},@_) |
103 |
> |
: @{$self->{content}->{USE}}; |
104 |
> |
} |
105 |
> |
else |
106 |
> |
{ |
107 |
> |
my ($name,%attributes)=@_; |
108 |
> |
$self->{DEPENDENCIES}->{$attributes{'name'}} = 1; |
109 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'}) |
110 |
> |
: push(@{$self->{content}->{USE}}, $attributes{'name'}); |
111 |
> |
} |
112 |
> |
} |
113 |
> |
|
114 |
> |
sub architecture() |
115 |
> |
{ |
116 |
> |
my ($object,$name,%attributes)=@_; |
117 |
> |
$self->pushlevel(\%attributes); # Set nested to 1; |
118 |
> |
} |
119 |
> |
|
120 |
> |
sub architecture_() |
121 |
> |
{ |
122 |
> |
$self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent}; |
123 |
> |
$self->poplevel(); |
124 |
> |
} |
125 |
> |
|
126 |
> |
sub export() |
127 |
> |
{ |
128 |
> |
$self->pushlevel(); # Set nested to 1; |
129 |
> |
} |
130 |
> |
|
131 |
> |
sub export_() |
132 |
> |
{ |
133 |
> |
$self->{content}->{EXPORT} = $self->{tagcontent}; |
134 |
> |
$self->poplevel(); |
135 |
> |
} |
136 |
> |
|
137 |
> |
sub lib() |
138 |
> |
{ |
139 |
> |
my ($object,$name,%attributes)=@_; |
140 |
> |
# The getter part: |
141 |
> |
if (ref($object) eq __PACKAGE__) |
142 |
> |
{ |
143 |
> |
# Return an array of required libs: |
144 |
> |
return $self->{content}->{LIB}; |
145 |
> |
} |
146 |
> |
|
147 |
> |
my $libname; |
148 |
> |
|
149 |
> |
if (exists($attributes{'position'})) |
150 |
> |
{ |
151 |
> |
if ($attributes{'position'} eq 'first') |
152 |
> |
{ |
153 |
> |
$libname = "F:".$attributes{'name'}; |
154 |
> |
} |
155 |
> |
else |
156 |
> |
{ |
157 |
> |
# There was a position entry but it didn't make sense: |
158 |
> |
$libname = $attributes{'name'}; |
159 |
> |
} |
160 |
> |
} |
161 |
> |
else |
162 |
> |
{ |
163 |
> |
$libname = $attributes{'name'}; |
164 |
> |
} |
165 |
> |
# We have a libname, add it to the list: |
166 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname) |
167 |
> |
: push(@{$self->{content}->{LIB}}, $libname); |
168 |
> |
} |
169 |
> |
|
170 |
> |
sub libtype() |
171 |
> |
{ |
172 |
> |
my ($object,$name,%attributes)=@_; |
173 |
> |
# The getter part: |
174 |
> |
if (ref($object) eq __PACKAGE__) |
175 |
> |
{ |
176 |
> |
# Return an array of required libs: |
177 |
> |
return $self->{content}->{LIBTYPE}; |
178 |
> |
} |
179 |
> |
|
180 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'}) |
181 |
> |
: push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'}); |
182 |
> |
} |
183 |
> |
|
184 |
> |
sub skip() |
185 |
> |
{ |
186 |
> |
my ($object,$name,%attributes)=@_; |
187 |
> |
$self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ] |
188 |
> |
: $self->{content}->{SKIPPEDDIRS} = [ 1 ]; |
189 |
> |
} |
190 |
> |
|
191 |
> |
sub skip_message() |
192 |
> |
{ |
193 |
> |
my ($object,$name,@message) = @_; |
194 |
> |
# Save any message text between <skip> tags: |
195 |
> |
if ($#message > -1) |
196 |
> |
{ |
197 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ]) |
198 |
> |
: push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]); |
199 |
> |
} |
200 |
> |
} |
201 |
> |
|
202 |
> |
sub skip_() |
203 |
> |
{ |
204 |
> |
my ($object,$name)=@_; |
205 |
> |
} |
206 |
> |
|
207 |
> |
sub makefile() |
208 |
> |
{ |
209 |
> |
my ($object,$name,%attributes)=@_; |
210 |
> |
# The getter part: |
211 |
> |
if (ref($object) eq __PACKAGE__) |
212 |
> |
{ |
213 |
> |
# Return Makefile content: |
214 |
> |
return $self->{content}->{MAKEFILE}; |
215 |
> |
} |
216 |
> |
|
217 |
> |
# Set our own Char handler so we can collect the content |
218 |
> |
# of the Makefile tag: |
219 |
> |
$object->setHandlers(Char => \&makefile_content); |
220 |
> |
$self->{makefilecontent} = []; |
221 |
> |
} |
222 |
> |
|
223 |
> |
sub makefile_content() |
224 |
> |
{ |
225 |
> |
my ($object, @strings) = @_; |
226 |
> |
foreach my $str (@strings) |
227 |
> |
{ |
228 |
> |
push(@{$self->{makefilecontent}},$str); |
229 |
> |
} |
230 |
> |
} |
231 |
> |
|
232 |
> |
sub makefile_() |
233 |
> |
{ |
234 |
> |
my ($object,$name)=@_; |
235 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@{$self->{makefilecontent}})) |
236 |
> |
: push(@{$self->{content}->{MAKEFILE}}, join("\n",@{$self->{makefilecontent}})); |
237 |
> |
delete $self->{makefilecontent}; |
238 |
> |
# Unset the Char handler to revert to the default behaviour: |
239 |
> |
$object->setHandlers(Char => 0); |
240 |
> |
} |
241 |
> |
|
242 |
> |
sub define_group() |
243 |
> |
{ |
244 |
> |
my ($object,$name,%attributes)=@_; |
245 |
> |
$self->pushlevel(\%attributes); # Set nested to 1; |
246 |
> |
} |
247 |
> |
|
248 |
> |
sub define_group_() |
249 |
> |
{ |
250 |
> |
$self->{content}->{DEFINED_GROUP}->{$self->{id}->{'name'}}=$self->{tagcontent}; |
251 |
> |
$self->poplevel(); |
252 |
> |
} |
253 |
> |
|
254 |
> |
sub group() |
255 |
> |
{ |
256 |
> |
my $object=shift; |
257 |
> |
# The getter part: |
258 |
> |
if (ref($object) eq __PACKAGE__) |
259 |
> |
{ |
260 |
> |
# Add or return groups: |
261 |
> |
@_ ? push(@{$self->{content}->{GROUP}},@_) |
262 |
> |
: @{$self->{content}->{GROUP}}; |
263 |
> |
} |
264 |
> |
else |
265 |
> |
{ |
266 |
> |
my ($name,%attributes)=@_; |
267 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{GROUP}}, $attributes{'name'}) |
268 |
> |
: push(@{$self->{content}->{GROUP}}, $attributes{'name'}); |
269 |
> |
} |
270 |
> |
} |
271 |
> |
|
272 |
> |
sub flags() |
273 |
> |
{ |
274 |
> |
my ($object,$name,%attributes)=@_; |
275 |
> |
# The getter part: |
276 |
> |
if (ref($object) eq __PACKAGE__) |
277 |
> |
{ |
278 |
> |
# Return an array of ProductStore hashes: |
279 |
> |
return $self->{content}->{FLAGS}; |
280 |
> |
} |
281 |
> |
|
282 |
> |
# Extract the flag name and its value: |
283 |
> |
my ($flagname,$flagvaluestring) = each %attributes; |
284 |
> |
$flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase |
285 |
> |
chomp($flagvaluestring); |
286 |
> |
my @flagvalues = ( $flagvaluestring ); |
287 |
> |
# Is current tag within another tag block? |
288 |
> |
if ($self->{nested} == 1) |
289 |
> |
{ |
290 |
> |
# Check to see if the current flag name is already stored in the hash. If so, |
291 |
> |
# just add the new values to the array of flag values: |
292 |
> |
if (exists ($self->{tagcontent}->{FLAGS}->{$flagname})) |
293 |
> |
{ |
294 |
> |
push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues); |
295 |
> |
} |
296 |
> |
else |
297 |
> |
{ |
298 |
> |
$self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ]; |
299 |
> |
} |
300 |
> |
} |
301 |
> |
else |
302 |
> |
{ |
303 |
> |
if (exists ($self->{content}->{FLAGS}->{$flagname})) |
304 |
> |
{ |
305 |
> |
push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues); |
306 |
> |
} |
307 |
> |
else |
308 |
> |
{ |
309 |
> |
$self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ]; |
310 |
> |
} |
311 |
> |
} |
312 |
> |
} |
313 |
|
|
314 |
< |
# |
315 |
< |
# generic build tag |
316 |
< |
# |
317 |
< |
sub Build_start { |
318 |
< |
my $self=shift; |
319 |
< |
my $name=shift; |
320 |
< |
my $hashref=shift; |
321 |
< |
|
322 |
< |
$self->{switch}->checktag($name,$hashref,'class'); |
323 |
< |
$self->{switch}->checktag($name,$hashref,'id'); |
324 |
< |
if ( $self->{Arch} ) { |
325 |
< |
|
326 |
< |
# -- determine the build products name |
327 |
< |
my $name; |
328 |
< |
if ( exists $$hashref{'name'} ) { |
329 |
< |
$name=$$hashref{'name'}; |
330 |
< |
} |
331 |
< |
else { |
332 |
< |
$self->{switch}->parseerror("No name specified for build product"); |
541 |
< |
#$name="\$(buildname)"; |
542 |
< |
} |
543 |
< |
|
544 |
< |
# -- check we have a lookup for the class type |
545 |
< |
my $mapper=$self->_toolmapper(); |
546 |
< |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
547 |
< |
$self->{switch}->parseerror("Unknown class : ".$$hashref{'class'}); |
548 |
< |
} |
549 |
< |
else { |
550 |
< |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
551 |
< |
my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'}); |
552 |
< |
|
553 |
< |
my $fh=$self->{filehandlestack}[0]; |
554 |
< |
my @targets=(); |
555 |
< |
|
556 |
< |
# -- generate generic targets |
557 |
< |
print $fh "ifndef _BuildLink_\n"; |
558 |
< |
$self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes); |
559 |
< |
|
560 |
< |
push @targets, $$hashref{'class'}; |
561 |
< |
|
562 |
< |
# -- generate targets for each type |
563 |
< |
foreach $type ( @types ) { |
564 |
< |
|
565 |
< |
# -- generic name for each type |
566 |
< |
my $pattern=$$hashref{'class'}."_".$type; |
567 |
< |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
568 |
< |
print $fh "# ------ $pattern rules ---------------\n"; |
569 |
< |
print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}. |
570 |
< |
"_".$type."_$name\n\n"; |
571 |
< |
|
572 |
< |
# -- create a new directory for each type |
573 |
< |
push @targets, $pattern; |
574 |
< |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
575 |
< |
my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}. |
576 |
< |
"/".$dirname; |
577 |
< |
my $makefile=$here."/BuildFile.mk"; |
578 |
< |
# AddDir::adddir($here); |
579 |
< |
|
580 |
< |
# -- create link targets to the directory |
581 |
< |
push @targets, $dirname; |
582 |
< |
print $fh "# -- Link Targets to $type directories\n"; |
583 |
< |
print $fh "$dirname: make_$dirname\n"; |
584 |
< |
print $fh "\t\@cd $here; \\\n"; |
585 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1". |
586 |
< |
" workdir=$here ". |
587 |
< |
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n"; |
588 |
< |
|
589 |
< |
# -- write target to make makefile for each directory |
590 |
< |
print $fh "# -- Build target directories\n"; |
591 |
< |
print $fh "make_$dirname:\n"; |
592 |
< |
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n"; |
593 |
< |
print $fh "\t if [ ! -d \"$here\" ]; then \\\n"; |
594 |
< |
print $fh "\t mkdir $here; \\\n"; |
595 |
< |
print $fh "\t fi;\\\n"; |
596 |
< |
print $fh "\t cd $dirname; \\\n"; |
597 |
< |
print $fh "\t echo include ".$self->{currentenv}." > ". |
598 |
< |
"$makefile; \\\n"; |
599 |
< |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
600 |
< |
" >> $makefile; \\\n"; |
601 |
< |
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
602 |
< |
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
603 |
< |
if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) { |
604 |
< |
foreach $f ( @file ) { |
605 |
< |
print $fh "\t echo -include $f >> $makefile; \\\n"; |
606 |
< |
} |
314 |
> |
sub allflags() |
315 |
> |
{ |
316 |
> |
my $self=shift; |
317 |
> |
# Return hash data for flags: |
318 |
> |
return $self->{content}->{FLAGS}; |
319 |
> |
} |
320 |
> |
|
321 |
> |
sub archspecific() |
322 |
> |
{ |
323 |
> |
my $self=shift; |
324 |
> |
|
325 |
> |
# Check to see if there is arch-dependent data. If so, return it: |
326 |
> |
if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0) |
327 |
> |
{ |
328 |
> |
while (my ($k,$v) = each %{$self->{content}->{ARCH}}) |
329 |
> |
{ |
330 |
> |
if ( $ENV{SCRAM_ARCH} =~ /$k.*/ ) |
331 |
> |
{ |
332 |
> |
return $self->{content}->{ARCH}->{$k}; |
333 |
|
} |
608 |
– |
print $fh "\tfi\n"; |
609 |
– |
print $fh "\n"; |
610 |
– |
# print $typefile "$name :\n"; |
611 |
– |
# print $typefile "\t\$(_quietbuild_)"; |
612 |
– |
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
613 |
– |
# print $typefile "\t\$(_quietstamp_)"; |
614 |
– |
# print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
615 |
– |
|
616 |
– |
# -- cleaning targets |
617 |
– |
push @targets, "clean_$dirname"; |
618 |
– |
print $fh "# -- cleaning targets\n"; |
619 |
– |
print $fh "clean::clean_$dirname\n"; |
620 |
– |
print $fh "clean_".$dirname."::\n"; |
621 |
– |
print $fh "\t\@echo cleaning $dirname\n"; |
622 |
– |
print $fh "\t\@if [ -d $here ]; then \\\n"; |
623 |
– |
print $fh "\tcd $here; \\\n"; |
624 |
– |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=". |
625 |
– |
$here." _BuildLink_=1 -f ". |
626 |
– |
"\$(TOOL_HOME)/basics.mk clean; \\\n"; |
627 |
– |
print $fh "\tfi\n\n"; |
628 |
– |
|
629 |
– |
|
630 |
– |
} |
631 |
– |
# -- help targets |
632 |
– |
print $fh "helpheader::\n"; |
633 |
– |
print $fh "\t\@echo Targets available:\n"; |
634 |
– |
print $fh "\t\@echo ------------------\n\n"; |
635 |
– |
print $fh "help::helpheader\n"; |
636 |
– |
foreach $target ( @targets ) { |
637 |
– |
print $fh "help::\n"; |
638 |
– |
print $fh "\t\@echo $target\n" |
639 |
– |
} |
640 |
– |
print $fh "endif\n"; |
641 |
– |
} # end else |
642 |
– |
} |
643 |
– |
} |
644 |
– |
|
645 |
– |
sub Bin_start { |
646 |
– |
my $self=shift; |
647 |
– |
my $name=shift; |
648 |
– |
my $hashref=shift; |
649 |
– |
|
650 |
– |
my $fileclass; |
651 |
– |
my @tools; |
652 |
– |
my $tool; |
653 |
– |
my $filename; |
654 |
– |
my $objectname; |
655 |
– |
|
656 |
– |
$self->{switch}->checktag($name,$hashref,'file'); |
657 |
– |
if ( $self->{Arch} ) { |
658 |
– |
if ( ! defined $$hashref{name} ) { |
659 |
– |
($$hashref{name}=$$hashref{file})=~s/\..*//; |
660 |
– |
} |
661 |
– |
($filename=$$hashref{file})=~s/\..*//; |
662 |
– |
|
663 |
– |
# Create a new directory for each binary target |
664 |
– |
my $dirname="bin_".$$hashref{name}; |
665 |
– |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
666 |
– |
open (binGNUmakefile, |
667 |
– |
">$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname/BuildFile.mk") or die "Unable to make $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/". |
668 |
– |
"BuildFile.mk $!\n"; |
669 |
– |
|
670 |
– |
# Create the link targets |
671 |
– |
$numbins++; |
672 |
– |
my $fh=$self->{filehandlestack}[0]; |
673 |
– |
print $fh <<ENDTEXT; |
674 |
– |
|
675 |
– |
# Link Targets to binary directories |
676 |
– |
ifdef BINMODE |
677 |
– |
# We dont want to build a library here |
678 |
– |
override files:= |
679 |
– |
endif |
680 |
– |
ifndef BINMODE |
681 |
– |
|
682 |
– |
define stepdown_$$hashref{'name'} |
683 |
– |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
684 |
– |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
685 |
– |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \\ |
686 |
– |
fi |
687 |
– |
endef |
688 |
– |
|
689 |
– |
define stepdown2_$$hashref{'name'} |
690 |
– |
if [ -d "$self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname" ]; then \\ |
691 |
– |
cd $self->{localtop}/$ENV{INTwork}/$self->{path}/$dirname; \\ |
692 |
– |
\$(MAKE) BINMODE=true LatestBuildFile=$self->{localtop}/$ENV{INTwork}/$self{path}/$dirname/BuildFile.mk workdir=\$(workdir)/$dirname -f \$(TOOL_HOME)/basics.mk datestamp \$\*; \\ |
693 |
– |
fi |
694 |
– |
|
695 |
– |
endef |
696 |
– |
|
697 |
– |
bin_$$hashref{'name'}_%:: dummy |
698 |
– |
\@\$(stepdown2_$$hashref{'name'}) |
699 |
– |
|
700 |
– |
$$hashref{'name'}_%:: dummy |
701 |
– |
\@\$(stepdown_$$hashref{'name'}) |
702 |
– |
|
703 |
– |
help bin bin_debug bin_debug_local bin_insure bin_Insure clean $$hashref{'name'}:: dummy |
704 |
– |
\@\$(stepdown_$$hashref{'name'}) |
705 |
– |
|
706 |
– |
binfiles+=$$hashref{'file'} |
707 |
– |
locbinfiles+=$dirname/$$hashref{'file'} |
708 |
– |
endif |
709 |
– |
|
710 |
– |
|
711 |
– |
ENDTEXT |
712 |
– |
|
713 |
– |
|
714 |
– |
# the binary specifics makefile |
715 |
– |
print binGNUmakefile "include ".$self->{currentenv}."\n"; |
716 |
– |
print binGNUmakefile "VPATH+=".$self->{localtop}."/$self{path}\n"; |
717 |
– |
|
718 |
– |
# alias for bin_Insure |
719 |
– |
print binGNUmakefile <<ENDTEXT; |
720 |
– |
|
721 |
– |
bin_insure:bin_Insure |
722 |
– |
ifdef MAKETARGET_bin_insure |
723 |
– |
MAKETARGET_$$hashref{name}_Insure=1 |
724 |
– |
endif |
725 |
– |
|
726 |
– |
# debuggging target |
727 |
– |
$$hashref{'name'}_echo_% :: echo_% |
728 |
– |
|
729 |
– |
# help targets |
730 |
– |
help:: |
731 |
– |
\t\@echo Targets For $$hashref{'name'} |
732 |
– |
\t\@echo ------------------------------------- |
733 |
– |
\t\@echo $$hashref{'name'} - default build |
734 |
– |
\t\@echo bin_$$hashref{'name'}_clean - executable specific cleaning |
735 |
– |
ENDTEXT |
736 |
– |
|
737 |
– |
# Make generic rules for each type |
738 |
– |
$targettypes={ |
739 |
– |
"bin" => 'o', |
740 |
– |
"bin_debug" => 'd', |
741 |
– |
"bin_debug_local" => 'l_d', |
742 |
– |
"bin_Insure" => 'Insure' |
743 |
– |
}; |
744 |
– |
# |
745 |
– |
foreach $target ( keys %$targettypes ) { |
746 |
– |
print binGNUmakefile <<ENDTEXT; |
747 |
– |
|
748 |
– |
# Type $target specifics |
749 |
– |
ifdef MAKETARGET_$target |
750 |
– |
MAKETARGET_$$hashref{name}_$$targettypes{$target}=1 |
751 |
– |
endif |
752 |
– |
$target ::$$hashref{name}_$$targettypes{$target} |
753 |
– |
|
754 |
– |
bintargets+=$$hashref{name}_$$targettypes{$target} |
755 |
– |
help:: |
756 |
– |
\t\@echo $$hashref{name}_$$targettypes{$target} |
757 |
– |
clean:: |
758 |
– |
\t\@if [ -f \$(binarystore)/$$hashref{name}_$$targettypes{$target} ]; then \\ |
759 |
– |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
760 |
– |
\trm \$(binarystore)/$$hashref{name}_$$targettypes{$target}; \\ |
761 |
– |
\tfi |
762 |
– |
|
763 |
– |
ENDTEXT |
764 |
– |
($objectname=$$hashref{file})=~s/\..*/_$$targettypes{$target}\.o/; |
765 |
– |
${"objectname_$$targettypes{$target}"}=$objectname; |
766 |
– |
print binGNUmakefile "$objectname:$$hashref{name}.dep\n"; |
767 |
– |
} # end loop |
768 |
– |
|
769 |
– |
print binGNUmakefile "$$hashref{name}_Insure.exe:.psrc\n"; |
770 |
– |
print binGNUmakefile "$$hashref{name}_d.exe:$objectname_d\n"; |
771 |
– |
print binGNUmakefile "\t\$(CClinkCmdDebug)\n"; |
772 |
– |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
773 |
– |
print binGNUmakefile "$$hashref{name}_l_d.exe:$objectname_d\n"; |
774 |
– |
print binGNUmakefile "\t\$(CClinkCmdDebugLocal)\n"; |
775 |
– |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
776 |
– |
print binGNUmakefile "$$hashref{name}_Insure.exe:$objectname_Insure\n"; |
777 |
– |
print binGNUmakefile "\t\$(CClinkCmdInsure)\n"; |
778 |
– |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
779 |
– |
print binGNUmakefile "$$hashref{name}_o.exe:$objectname_o\n"; |
780 |
– |
print binGNUmakefile "\t\$(CClinkCmd)\n"; |
781 |
– |
print binGNUmakefile "\t\@\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$\@\.ds \$\@ \$\^\n"; |
782 |
– |
print binGNUmakefile "$$hashref{name}.dep:$$hashref{file}\n"; |
783 |
– |
print binGNUmakefile "-include $$hashref{name}.dep\n"; |
784 |
– |
print binGNUmakefile <<ENDTEXT; |
785 |
– |
clean:: |
786 |
– |
\t\@if [ -f \$(binarystore)/$$hashref{name} ]; then \\ |
787 |
– |
\techo Removing \$(binarystore)/$$hashref{name}; \\ |
788 |
– |
\trm \$(binarystore)/$$hashref{name}; \\ |
789 |
– |
\tfi |
790 |
– |
|
791 |
– |
$$hashref{name}_d.exe:\$(libslocal_d) |
792 |
– |
$$hashref{name}_o.exe:\$(libslocal) |
793 |
– |
ifdef MCCABE_DATA_DIR |
794 |
– |
$$hashref{name}_mccabe.exe: \$(libslocal_d) \$(MCCABE_DATA_DIR)/mccabeinstr/instplus.cpp |
795 |
– |
endif |
796 |
– |
$$hashref{name}_Insure.exe:\$(libslocal_I) |
797 |
– |
$$hashref{name}_d:$$hashref{name}_d.exe |
798 |
– |
\@cp $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
799 |
– |
$$hashref{name}_l_d:$$hashref{name}_l_d.exe |
800 |
– |
\@cp $$hashref{name}_l_d.exe \$(binarystore)/$$hashref{name} |
801 |
– |
$$hashref{name}_Insure:$$hashref{name}_Insure.exe |
802 |
– |
\@cp $$hashref{name}_Insure.exe \$(binarystore)/$$hashref{name}_Insure |
803 |
– |
$$hashref{name}:$$hashref{name}_d.exe |
804 |
– |
\@mv $$hashref{name}_d.exe \$(binarystore)/$$hashref{name} |
805 |
– |
$$hashref{name}_o:$$hashref{name}_o.exe |
806 |
– |
\@mv $$hashref{name}_o.exe \$(binarystore)/$$hashref{name} |
807 |
– |
binfiles+=$$hashref{file} |
808 |
– |
ENDTEXT |
809 |
– |
} |
810 |
– |
close binGNUmakefile; |
811 |
– |
} |
812 |
– |
|
813 |
– |
sub External_StartTag { |
814 |
– |
my $self=shift; |
815 |
– |
my $name=shift; |
816 |
– |
my $hashref=shift; |
817 |
– |
|
818 |
– |
my $tool; |
819 |
– |
if ( $self->{Arch} ) { |
820 |
– |
$self->{switch}->checktag($name,$hashref,'ref'); |
821 |
– |
|
822 |
– |
# -- oo toolbox stuff |
823 |
– |
# - get the appropriate tool object |
824 |
– |
$$hashref{'ref'}=~tr[A-Z][a-z]; |
825 |
– |
if ( ! exists $$hashref{'version'} ) { |
826 |
– |
$tool=$self->{toolbox}->gettool($$hashref{'ref'}); |
827 |
– |
} |
828 |
– |
else { |
829 |
– |
$tool=$self->{toolbox}->gettool($$hashref{'ref'},$$hashref{'version'}); |
830 |
– |
} |
831 |
– |
if ( ! defined $tool ) { |
832 |
– |
$self->{switch}->parseerror("Unknown Tool Specified (" |
833 |
– |
.$$hashref{'ref'}.")"); |
834 |
– |
} |
835 |
– |
|
836 |
– |
# -- old fashioned GNUmakefile stuff |
837 |
– |
print GNUmakefile $$hashref{'ref'}; |
838 |
– |
if ( defined $$hashref{'version'} ) { |
839 |
– |
print GNUmakefile "_V_".$$hashref{'version'}; |
840 |
– |
} |
841 |
– |
print GNUmakefile "=true\n"; |
842 |
– |
|
843 |
– |
# -- Sub system also specified? |
844 |
– |
if ( exists $$hashref{'use'} ) { |
845 |
– |
# -- look for a buildfile |
846 |
– |
my @paths=$tool->getfeature("INCLUDE"); |
847 |
– |
my $file=""; |
848 |
– |
my ($path,$testfile); |
849 |
– |
foreach $path ( @paths ) { |
850 |
– |
$testfile=$path."/".$$hashref{'use'}."/BuildFile" ; |
851 |
– |
if ( -f $testfile ) { |
852 |
– |
$file=$testfile; |
853 |
– |
$self->_pushremoteproject($path); |
854 |
– |
} |
855 |
– |
} |
856 |
– |
if ( $file eq "" ) { |
857 |
– |
$self->{switch}->parseerror("Unable to find SubSystem $testfile"); |
858 |
– |
} |
859 |
– |
$self->ParseBuildFile_Export($file); |
860 |
– |
$self->_popremoteproject(); |
334 |
|
} |
335 |
< |
} |
336 |
< |
} |
337 |
< |
|
338 |
< |
sub Group_start { |
339 |
< |
my $self=shift; |
340 |
< |
my $name=shift; |
341 |
< |
my $hashref=shift; |
342 |
< |
|
343 |
< |
$self->{switch}->checktag($name, $hashref, 'name'); |
344 |
< |
if ( $self->{Arch} ) { |
345 |
< |
print GNUmakefile "GROUP_".$$hashref{'name'}; |
346 |
< |
if ( defined $$hashref{'version'} ) { |
347 |
< |
print GNUmakefile "_V_".$$hashref{'version'}; |
348 |
< |
} |
349 |
< |
print GNUmakefile "=true\n"; |
350 |
< |
} |
351 |
< |
} |
352 |
< |
|
353 |
< |
sub Use_start { |
354 |
< |
my $self=shift; |
355 |
< |
my $name=shift; |
356 |
< |
my $hashref=shift; |
357 |
< |
my $filename; |
358 |
< |
use Utilities::SCRAMUtils; |
359 |
< |
|
360 |
< |
$self->{switch}->checktag($name, $hashref, "name"); |
361 |
< |
if ( $self->{Arch} ) { |
362 |
< |
if ( exists $$hashref{'group'} ) { |
363 |
< |
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n"; |
364 |
< |
} |
365 |
< |
if ( ! defined $self->{remoteproject} ) { |
366 |
< |
$filename=SCRAMUtils::checkfile( |
367 |
< |
"/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
368 |
< |
} |
369 |
< |
else { |
370 |
< |
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile"; |
371 |
< |
print "trying $filename\n"; |
372 |
< |
if ( ! -f $filename ) { $filename=""; }; |
373 |
< |
} |
374 |
< |
if ( $filename ne "" ) { |
375 |
< |
$self->ParseBuildFile_Export( $filename ); |
376 |
< |
} |
377 |
< |
else { |
378 |
< |
$self->{switch}->parseerror("Unable to detect Appropriate ". |
379 |
< |
"decription file for <$name name=".$$hashref{name}.">"); |
380 |
< |
} |
381 |
< |
} |
382 |
< |
} |
383 |
< |
|
384 |
< |
# List association groups between <AssociateGroup> tags |
385 |
< |
# seperated by newlines or spaces |
386 |
< |
sub AssociateGroup { |
387 |
< |
my $self=shift; |
388 |
< |
my $name=shift; |
389 |
< |
my $string=shift; |
390 |
< |
my $word; |
391 |
< |
|
392 |
< |
if ( $self->{Arch} ) { |
393 |
< |
foreach $word ( (split /\s/, $string) ){ |
394 |
< |
chomp $word; |
395 |
< |
next if /^#/; |
396 |
< |
if ( $word=~/none/ ) { |
397 |
< |
$self->{ignore}=1; |
398 |
< |
} |
399 |
< |
} |
400 |
< |
} |
401 |
< |
} |
402 |
< |
|
403 |
< |
sub Arch_Start { |
404 |
< |
my $self=shift; |
405 |
< |
my $name=shift; |
406 |
< |
my $hashref=shift; |
407 |
< |
|
408 |
< |
$self->{switch}->checktag($name, $hashref,'name'); |
409 |
< |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1) |
410 |
< |
: ($self->{Arch}=0); |
411 |
< |
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
412 |
< |
} |
413 |
< |
|
414 |
< |
sub Arch_End { |
415 |
< |
my $self=shift; |
416 |
< |
my $name=shift; |
417 |
< |
|
418 |
< |
pop @{$self->{ARCHBLOCK}}; |
419 |
< |
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}]; |
420 |
< |
} |
421 |
< |
|
422 |
< |
# Split up the Class Block String into a useable array |
423 |
< |
sub _CutBlock { |
424 |
< |
my $self=shift; |
425 |
< |
my $string= shift @_; |
426 |
< |
@BlockClassA = split /\//, $string; |
427 |
< |
} |
428 |
< |
|
429 |
< |
sub OutToMakefile { |
430 |
< |
my $self=shift; |
431 |
< |
my $name=shift; |
432 |
< |
my @vars=@_; |
433 |
< |
|
434 |
< |
if ( $self->{Arch} ) { |
435 |
< |
print GNUmakefile @vars; |
436 |
< |
} |
437 |
< |
} |
438 |
< |
|
439 |
< |
sub OutToScreen { |
440 |
< |
my $name=shift; |
441 |
< |
my @vars=@_; |
442 |
< |
|
443 |
< |
if ( $self->{Arch} ) { |
444 |
< |
print @vars; |
445 |
< |
} |
446 |
< |
} |
447 |
< |
sub setBlockClassPath { |
448 |
< |
my $self=shift; |
449 |
< |
my $name=shift; |
450 |
< |
my $hashref=shift; |
451 |
< |
|
452 |
< |
$self->{switch}->checktag($name, $hashref, 'path'); |
453 |
< |
$self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path}; |
454 |
< |
$self->_CutBlock($$hashref{path}); |
455 |
< |
} |
456 |
< |
|
457 |
< |
sub BlockClassPath { |
458 |
< |
my $self=shift; |
459 |
< |
return $self->{BlockClassPath}; |
460 |
< |
} |
461 |
< |
|
462 |
< |
sub export_start_export { |
463 |
< |
my $self=shift; |
464 |
< |
my $name=shift; |
465 |
< |
my $hashref=shift; |
466 |
< |
|
467 |
< |
$self->{switch}->opengroup("__export"); |
468 |
< |
} |
469 |
< |
|
470 |
< |
sub export_start { |
471 |
< |
my $self=shift; |
472 |
< |
my $name=shift; |
473 |
< |
my $hashref=shift; |
474 |
< |
|
475 |
< |
$self->{switch}->opengroup("__export"); |
476 |
< |
if ( exists $$hashref{autoexport} ) { |
477 |
< |
print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n"; |
478 |
< |
if ( $$hashref{autoexport}=~/true/ ) { |
479 |
< |
$self->{switch}->allowgroup("__export","makebuild"); |
480 |
< |
} |
481 |
< |
else { |
482 |
< |
$self->{switch}->disallowgroup("__export","makebuild"); |
483 |
< |
} |
484 |
< |
} |
485 |
< |
# -- allow default setting from other makefiles |
486 |
< |
print GNUmakefile "ifeq (\$(scram_autoexport),true)\n"; |
487 |
< |
} |
488 |
< |
|
489 |
< |
sub export_end_export { |
490 |
< |
my $self=shift; |
491 |
< |
$self->{switch}->closegroup("__export"); |
492 |
< |
} |
493 |
< |
|
494 |
< |
sub export_end { |
495 |
< |
my $self=shift; |
496 |
< |
$self->{switch}->closegroup("__export"); |
497 |
< |
print GNUmakefile "endif\n"; |
498 |
< |
} |
335 |
> |
} |
336 |
> |
return ""; |
337 |
> |
} |
338 |
> |
|
339 |
> |
sub bin() |
340 |
> |
{ |
341 |
> |
my ($object,$name,%attributes) = @_; |
342 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
343 |
> |
} |
344 |
> |
|
345 |
> |
sub bin_() |
346 |
> |
{ |
347 |
> |
# Need unique name for the binary (always use name of product). Either use "name" |
348 |
> |
# given, or use "file" value minus the ending: |
349 |
> |
if (exists ($self->{id}->{'name'})) |
350 |
> |
{ |
351 |
> |
$name = $self->{id}->{'name'}; |
352 |
> |
} |
353 |
> |
else |
354 |
> |
{ |
355 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
356 |
> |
} |
357 |
> |
|
358 |
> |
# Store the data: |
359 |
> |
$self->productcollector($name,'bin','BIN'); |
360 |
> |
$self->poplevel(); |
361 |
> |
} |
362 |
> |
|
363 |
> |
sub module() |
364 |
> |
{ |
365 |
> |
my ($object,$name,%attributes) = @_; |
366 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
367 |
> |
} |
368 |
> |
|
369 |
> |
sub module_() |
370 |
> |
{ |
371 |
> |
# Need unique name for the module (always use name of product). Either use "name" |
372 |
> |
# given, or use "file" value minus the ending: |
373 |
> |
if (exists ($self->{id}->{'name'})) |
374 |
> |
{ |
375 |
> |
$name = $self->{id}->{'name'}; |
376 |
> |
} |
377 |
> |
else |
378 |
> |
{ |
379 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
380 |
> |
} |
381 |
> |
|
382 |
> |
# Store the data: |
383 |
> |
$self->productcollector($name,'mod','MODULE'); |
384 |
> |
$self->poplevel(); |
385 |
> |
} |
386 |
> |
|
387 |
> |
sub application() |
388 |
> |
{ |
389 |
> |
my ($object,$name,%attributes) = @_; |
390 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
391 |
> |
} |
392 |
> |
|
393 |
> |
sub application_() |
394 |
> |
{ |
395 |
> |
# Need unique name for the application (always use name of product). Either use "name" |
396 |
> |
# given, or use "file" value minus the ending: |
397 |
> |
if (exists ($self->{id}->{'name'})) |
398 |
> |
{ |
399 |
> |
$name = $self->{id}->{'name'}; |
400 |
> |
} |
401 |
> |
else |
402 |
> |
{ |
403 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
404 |
> |
} |
405 |
> |
|
406 |
> |
# Store the data: |
407 |
> |
$self->productcollector($name,'app','APPLICATION'); |
408 |
> |
$self->poplevel(); |
409 |
> |
} |
410 |
> |
|
411 |
> |
sub library() |
412 |
> |
{ |
413 |
> |
my ($object,$name,%attributes) = @_; |
414 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
415 |
> |
} |
416 |
> |
|
417 |
> |
sub library_() |
418 |
> |
{ |
419 |
> |
# Need unique name for the library (always use name of product). Either use "name" |
420 |
> |
# given, or use "file" value minus the ending: |
421 |
> |
if (exists ($self->{id}->{'name'})) |
422 |
> |
{ |
423 |
> |
$name = $self->{id}->{'name'}; |
424 |
> |
} |
425 |
> |
else |
426 |
> |
{ |
427 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
428 |
> |
} |
429 |
> |
|
430 |
> |
# Store the data: |
431 |
> |
$self->productcollector($name,'lib','LIBRARY'); |
432 |
> |
$self->poplevel(); |
433 |
> |
} |
434 |
> |
|
435 |
> |
sub plugin() |
436 |
> |
{ |
437 |
> |
my ($object,$name,%attributes) = @_; |
438 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
439 |
> |
} |
440 |
> |
|
441 |
> |
sub plugin_() |
442 |
> |
{ |
443 |
> |
# Need unique name for the plugin (always use name of product). Either use "name" |
444 |
> |
# given, or use "file" value minus the ending: |
445 |
> |
if (exists ($self->{id}->{'name'})) |
446 |
> |
{ |
447 |
> |
$name = $self->{id}->{'name'}; |
448 |
> |
} |
449 |
> |
else |
450 |
> |
{ |
451 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
452 |
> |
} |
453 |
> |
|
454 |
> |
# Store the data: |
455 |
> |
$self->productcollector($name,'plugin','PLUGIN'); |
456 |
> |
$self->poplevel(); |
457 |
> |
} |
458 |
> |
|
459 |
> |
sub unittest() |
460 |
> |
{ |
461 |
> |
my ($object,$name,%attributes) = @_; |
462 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
463 |
> |
} |
464 |
> |
|
465 |
> |
sub unittest_() |
466 |
> |
{ |
467 |
> |
# Need unique name for the unittest (always use name of product). Either use "name" |
468 |
> |
# given, or use "file" value minus the ending: |
469 |
> |
if (exists ($self->{id}->{'name'})) |
470 |
> |
{ |
471 |
> |
$name = $self->{id}->{'name'}; |
472 |
> |
} |
473 |
> |
else |
474 |
> |
{ |
475 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
476 |
> |
} |
477 |
> |
|
478 |
> |
# Store the data: |
479 |
> |
$self->productcollector($name,'unittest','unittest'); |
480 |
> |
$self->poplevel(); |
481 |
> |
} |
482 |
> |
|
483 |
> |
sub productcollector() |
484 |
> |
{ |
485 |
> |
my $self=shift; |
486 |
> |
my ($name,$typeshort,$typefull)=@_; |
487 |
> |
# Create a new Product object for storage of data: |
488 |
> |
use BuildSystem::Product; |
489 |
> |
my $product = BuildSystem::Product->new(); |
490 |
> |
# Store the name: |
491 |
> |
$product->name($name); |
492 |
> |
$product->type($typeshort); |
493 |
> |
# Store the files. Take the BuildFile path as the initial path for |
494 |
> |
# expanding source file globs: |
495 |
> |
$product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]); |
496 |
> |
# Store the data content: |
497 |
> |
$product->_data($self->{tagcontent}); |
498 |
> |
# And store in a hash (all build products in same place): |
499 |
> |
$self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product; |
500 |
> |
} |
501 |
> |
|
502 |
> |
sub pushlevel |
503 |
> |
{ |
504 |
> |
my $self = shift; |
505 |
> |
my ($info)=@_; |
506 |
> |
|
507 |
> |
$self->{id} = $info if (defined $info); |
508 |
> |
$self->{nested} = 1; |
509 |
> |
$self->{tagcontent}={}; |
510 |
> |
} |
511 |
> |
|
512 |
> |
sub poplevel |
513 |
> |
{ |
514 |
> |
my $self = shift; |
515 |
> |
delete $self->{id}; |
516 |
> |
delete $self->{nested}; |
517 |
> |
delete $self->{tagcontent}; |
518 |
> |
} |
519 |
> |
|
520 |
> |
sub dependencies() |
521 |
> |
{ |
522 |
> |
my $self=shift; |
523 |
> |
# Make a copy of the variable so that |
524 |
> |
# we don't have a DEPENDENCIES entry in RAWDATA: |
525 |
> |
my %DEPS=%{$self->{DEPENDENCIES}}; |
526 |
> |
delete $self->{DEPENDENCIES}; |
527 |
> |
return \%DEPS; |
528 |
> |
} |
529 |
> |
|
530 |
> |
sub skippeddirs() |
531 |
> |
{ |
532 |
> |
my $self=shift; |
533 |
> |
my ($here)=@_; |
534 |
> |
my $skipped; |
535 |
> |
|
536 |
> |
if ($self->{content}->{SKIPPEDDIRS}->[0] == 1) |
537 |
> |
{ |
538 |
> |
$skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ]; |
539 |
> |
delete $self->{content}->{SKIPPEDDIRS}; |
540 |
> |
} |
541 |
> |
|
542 |
> |
delete $self->{content}->{SKIPPEDDIRS}; |
543 |
> |
return $skipped; |
544 |
> |
} |
545 |
> |
|
546 |
> |
sub hasexport() |
547 |
> |
{ |
548 |
> |
my $self=shift; |
549 |
> |
# Check to see if there is a valid export block: |
550 |
> |
my $nkeys = $self->exporteddatatypes(); |
551 |
> |
$nkeys > 0 ? return 1 : return 0; |
552 |
> |
} |
553 |
> |
|
554 |
> |
sub has() |
555 |
> |
{ |
556 |
> |
my $self=shift; |
557 |
> |
my ($datatype)=@_; |
558 |
> |
(exists ($self->{content}->{$datatype})) ? return 1 : return 0; |
559 |
> |
} |
560 |
> |
|
561 |
> |
sub exported() |
562 |
> |
{ |
563 |
> |
my $self=shift; |
564 |
> |
# Return a hash. Keys are type of data provided: |
565 |
> |
return ($self->{content}->{EXPORT}); |
566 |
> |
} |
567 |
> |
|
568 |
> |
sub exporteddatatypes() |
569 |
> |
{ |
570 |
> |
my $self=shift; |
571 |
> |
# Return exported data types: |
572 |
> |
return keys %{$self->{content}->{EXPORT}}; |
573 |
> |
} |
574 |
> |
|
575 |
> |
sub defined_group() |
576 |
> |
{ |
577 |
> |
my $self=shift; |
578 |
> |
|
579 |
> |
if (exists($self->{content}->{DEFINED_GROUP})) |
580 |
> |
{ |
581 |
> |
# Return a list of keys (group names) for defined groups: |
582 |
> |
return [ keys %{$self->{content}->{DEFINED_GROUP}} ]; |
583 |
> |
} |
584 |
> |
else |
585 |
> |
{ |
586 |
> |
return 0; |
587 |
> |
} |
588 |
> |
} |
589 |
> |
|
590 |
> |
sub dataforgroup() |
591 |
> |
{ |
592 |
> |
my $self=shift; |
593 |
> |
my ($groupname)=@_; |
594 |
> |
# Return hash containing data for defined group |
595 |
> |
# $groupname or return undef: |
596 |
> |
return $self->{content}->{DEFINED_GROUP}->{$groupname}; |
597 |
> |
} |
598 |
> |
|
599 |
> |
sub buildproducts() |
600 |
> |
{ |
601 |
> |
my $self=shift; |
602 |
> |
# Returns hash of build products and their data: |
603 |
> |
return $self->{content}->{BUILDPRODUCTS}; |
604 |
> |
} |
605 |
> |
|
606 |
> |
sub values() |
607 |
> |
{ |
608 |
> |
my $self=shift; |
609 |
> |
my ($type)=@_; |
610 |
> |
# Get a list of values from known types |
611 |
> |
return $self->{content}->{BUILDPRODUCTS}->{$type}; |
612 |
> |
} |
613 |
> |
|
614 |
> |
sub basic_tags() |
615 |
> |
{ |
616 |
> |
my $self=shift; |
617 |
> |
my $datatags=[]; |
618 |
> |
my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE PLUGIN BUILDPRODUCTS) ]; |
619 |
> |
my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ]; |
620 |
> |
my $otherskiptags=[ qw( SKIPPEDDIRS ) ]; |
621 |
> |
my @all_skip_tags; |
622 |
> |
|
623 |
> |
push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags); |
624 |
> |
|
625 |
> |
foreach my $t (keys %{$self->{content}}) |
626 |
> |
{ |
627 |
> |
push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags)); |
628 |
> |
} |
629 |
> |
return @{$datatags}; |
630 |
> |
} |
631 |
> |
|
632 |
> |
sub clean() |
633 |
> |
{ |
634 |
> |
my $self=shift; |
635 |
> |
my (@tags) = @_; |
636 |
> |
|
637 |
> |
# Delete some useless entries: |
638 |
> |
delete $self->{makefilecontent}; |
639 |
> |
delete $self->{simpledoc}; |
640 |
> |
delete $self->{id}; |
641 |
> |
delete $self->{tagcontent}; |
642 |
> |
delete $self->{nested}; |
643 |
> |
|
644 |
> |
delete $self->{DEPENDENCIES}; |
645 |
> |
|
646 |
> |
map |
647 |
> |
{ |
648 |
> |
delete $self->{content}->{$_} if (exists($self->{content}->{$_})); |
649 |
> |
} @tags; |
650 |
> |
|
651 |
> |
return $self; |
652 |
> |
} |
653 |
> |
|
654 |
> |
sub AUTOLOAD() |
655 |
> |
{ |
656 |
> |
my ($xmlparser,$name,%attributes)=@_; |
657 |
> |
return if $AUTOLOAD =~ /::DESTROY$/; |
658 |
> |
my $name=$AUTOLOAD; |
659 |
> |
$name =~ s/.*://; |
660 |
> |
} |
661 |
|
|
662 |
< |
# |
1028 |
< |
# Standard lib tag |
1029 |
< |
# |
1030 |
< |
sub lib_start { |
1031 |
< |
my $self=shift; |
1032 |
< |
my $name=shift; |
1033 |
< |
my $hashref=shift; |
1034 |
< |
|
1035 |
< |
$self->{switch}->checktag($name, $hashref, 'name'); |
1036 |
< |
if ( $self->{Arch} ) { |
1037 |
< |
print GNUmakefile "lib+=$$hashref{name}\n"; |
1038 |
< |
} |
1039 |
< |
} |
1040 |
< |
|
1041 |
< |
# |
1042 |
< |
# libtype specification |
1043 |
< |
# |
1044 |
< |
sub LibType_Start { |
1045 |
< |
my $self=shift; |
1046 |
< |
my $name=shift; |
1047 |
< |
my $hashref=shift; |
1048 |
< |
|
1049 |
< |
if ( $self->{Arch} ) { |
1050 |
< |
if ( defined $self->{libtype_conext} ) { |
1051 |
< |
$self->{switch}->parseerror("<$name> tag cannot be specified". |
1052 |
< |
" without a </$name> tag to close previous context"); |
1053 |
< |
} |
1054 |
< |
else { |
1055 |
< |
$self->{libtype_conext}=1; |
1056 |
< |
$self->{switch}->checktag($name, $hashref, 'type'); |
1057 |
< |
|
1058 |
< |
print GNUmakefile "# Specify Library Type\n"; |
1059 |
< |
print GNUmakefile "DefaultLibsOff=yes\n"; |
1060 |
< |
if ( $$hashref{'type'}=~/^archive/i ) { |
1061 |
< |
print GNUmakefile "LibArchive=true\n"; |
1062 |
< |
} |
1063 |
< |
elsif ($$hashref{'type'}=~/debug_archive/i ) { |
1064 |
< |
print GNUmakefile "LibDebugArchive=true\n"; |
1065 |
< |
} |
1066 |
< |
elsif ($$hashref{'type'}=~/debug_shared/i ) { |
1067 |
< |
print GNUmakefile "LibDebugShared=true\n"; |
1068 |
< |
} |
1069 |
< |
elsif ($$hashref{'type'}=~/shared/i ) { |
1070 |
< |
print GNUmakefile 'LibShared=true'."\n"; |
1071 |
< |
} |
1072 |
< |
print GNUmakefile "\n"; |
1073 |
< |
} |
1074 |
< |
} |
1075 |
< |
} |
1076 |
< |
|
1077 |
< |
sub LibType_text { |
1078 |
< |
my $self=shift; |
1079 |
< |
my $name=shift; |
1080 |
< |
my $string=shift; |
1081 |
< |
|
1082 |
< |
if ( $self->{Arch} ) { |
1083 |
< |
$string=~s/\n/ /g; |
1084 |
< |
print GNUmakefile "libmsg::\n\t\@echo Library info: "; |
1085 |
< |
print GNUmakefile $string; |
1086 |
< |
print GNUmakefile "\n"; |
1087 |
< |
} |
1088 |
< |
} |
1089 |
< |
|
1090 |
< |
sub LibType_end { |
1091 |
< |
my $self=shift; |
1092 |
< |
my $name=shift; |
1093 |
< |
|
1094 |
< |
undef $self->{libtype_conext}; |
1095 |
< |
} |
1096 |
< |
|
1097 |
< |
sub Environment_start { |
1098 |
< |
my $self=shift; |
1099 |
< |
my $name=shift; |
1100 |
< |
my $hashref=shift; |
1101 |
< |
|
1102 |
< |
if ( $self->{Arch} ) { |
1103 |
< |
$self->{envnum}++; |
1104 |
< |
|
1105 |
< |
# open a new Environment File |
1106 |
< |
my $envfile="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_". |
1107 |
< |
$self->{envnum}.".mk"; |
1108 |
< |
use FileHandle; |
1109 |
< |
my $fh=FileHandle->new(); |
1110 |
< |
open ($fh,">$envfile") or die "Unable to open file $envfile \n$!\n"; |
1111 |
< |
push @{$self->{filehandlestack}}, $fh; |
1112 |
< |
*GNUmakefile=$fh; |
1113 |
< |
|
1114 |
< |
# include the approprate environment file |
1115 |
< |
if ( $self->{envlevel} == 0 ) { |
1116 |
< |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
1117 |
< |
$self->{path}."/BuildFile.mk\n"; |
1118 |
< |
} |
1119 |
< |
else { |
1120 |
< |
print GNUmakefile "include $self->{localtop}/$ENV{INTwork}/". |
1121 |
< |
$self->{path}."/Env_".$self->{Envlevels}[$self->{envlevel}].".mk\n"; |
1122 |
< |
} |
1123 |
< |
$self->{envlevel}++; |
1124 |
< |
$self->{Envlevels}[$self->{envlevel}]=$self->{envnum}; |
1125 |
< |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/Env_$self->{envnum}.mk"; |
1126 |
< |
} |
1127 |
< |
} |
1128 |
< |
|
1129 |
< |
sub Environment_end { |
1130 |
< |
my $self=shift; |
1131 |
< |
my $fd; |
1132 |
< |
|
1133 |
< |
if ( $self->{Arch} ) { |
1134 |
< |
$self->{envlevel}--; |
1135 |
< |
if ( $self->{envlevel} < 0 ) { |
1136 |
< |
print "Too many </Environent> Tags on $self->{switch}->line()\n"; |
1137 |
< |
exit 1; |
1138 |
< |
} |
1139 |
< |
close GNUmakefile; |
1140 |
< |
# restore the last filehandle |
1141 |
< |
$fd=pop @{$self->{filehandlestack}}; |
1142 |
< |
close $fd; |
1143 |
< |
*GNUmakefile=$self->{filehandlestack}[$#{$self->{filehandlestack}}]; |
1144 |
< |
if ( $self->{envlevel} < 1 ) { |
1145 |
< |
$self->{currentenv}="$self->{localtop}/$ENV{INTwork}/$self->{path}/". |
1146 |
< |
"BuildFile.mk"; |
1147 |
< |
} |
1148 |
< |
else { |
1149 |
< |
$self->{currentenv}= |
1150 |
< |
$self->{localtop}."/$ENV{INTwork}/$self->{path}/Env_". |
1151 |
< |
$self->{Envlevels}[$self->{envlevel}]; |
1152 |
< |
} |
1153 |
< |
} |
1154 |
< |
} |
1155 |
< |
|
1156 |
< |
sub Store_start { |
1157 |
< |
my $self=shift; |
1158 |
< |
my $name=shift; |
1159 |
< |
my $hashref=shift; |
1160 |
< |
|
1161 |
< |
if ( $self->{Arch} ) { |
1162 |
< |
$self->{switch}->checktag( $name, $hashref, 'name' ); |
1163 |
< |
|
1164 |
< |
# -- store creation |
1165 |
< |
my $dir=$$hashref{'name'}; |
1166 |
< |
AddDir::adddir($self->{area}->location()."/".$dir); |
1167 |
< |
if ( exists $$hashref{'type'} ) { |
1168 |
< |
# -- architecture specific store |
1169 |
< |
if ( $$hashref{'type'}=~/^arch/i ) { |
1170 |
< |
$dir=$dir."/".$ENV{SCRAM_ARCH}; |
1171 |
< |
AddDir::adddir($self->{area}->location()."/".$dir); |
1172 |
< |
} |
1173 |
< |
else { |
1174 |
< |
$self->parseerror("Unknown type in <$name> tag"); |
1175 |
< |
} |
1176 |
< |
} |
1177 |
< |
|
1178 |
< |
# -- set make variables for the store |
1179 |
< |
print GNUmakefile "SCRAMSTORENAME_".$$hashref{'name'}.":=".$dir."\n"; |
1180 |
< |
print GNUmakefile "SCRAMSTORE_".$$hashref{'name'}.":=". |
1181 |
< |
$self->{localtop}."/".$dir."\n"; |
1182 |
< |
print GNUmakefile "VPATH+=".$self->{localtop} |
1183 |
< |
."/".$dir.":".$self->{releasetop}."/".$dir."\n"; |
1184 |
< |
} |
1185 |
< |
} |
1186 |
< |
|
1187 |
< |
sub DropDown { |
1188 |
< |
my $self=shift; |
1189 |
< |
my $name=shift; |
1190 |
< |
my $hashref=shift; |
1191 |
< |
|
1192 |
< |
if ( $self->{Arch} ) { |
1193 |
< |
# - default values must always be specified |
1194 |
< |
$self->{switch}->checktag( $name, $hashref, 'defaults' ); |
1195 |
< |
my @blockdirs=split /,/ , $$hashref{'defaults'}; |
1196 |
< |
$self->{block}->defaultblocks(@blockdirs); |
1197 |
< |
} |
1198 |
< |
} |
662 |
> |
1; |