1 |
< |
# BuildFile |
1 |
> |
#____________________________________________________________________ |
2 |
> |
# File: BuildFile.pm |
3 |
> |
#____________________________________________________________________ |
4 |
> |
# |
5 |
> |
# Author: Shaun Ashby <Shaun.Ashby@cern.ch> |
6 |
> |
# Copyright: 2003 (C) Shaun Ashby |
7 |
|
# |
8 |
< |
# Interface |
4 |
< |
# --------- |
5 |
< |
# new(ConfigArea) |
6 |
< |
# ParseBuildFile($base,$path,$file) |
7 |
< |
# ParseBuildFileExport(filename) |
8 |
< |
# BlockParse(Block) : perform a parse to modify the block |
9 |
< |
# BlockClassPath() : Return the class path |
10 |
< |
# ignore() : return 1 if directory should be ignored 0 otherwise |
11 |
< |
# classname() : get/set the associated class |
12 |
< |
# buildfile() : get/set BuildFile location |
13 |
< |
# makefile() : get the generated makefile |
14 |
< |
|
8 |
> |
#-------------------------------------------------------------------- |
9 |
|
package BuildSystem::BuildFile; |
16 |
– |
use ActiveDoc::SimpleDoc; |
17 |
– |
use BuildSystem::ToolBox; |
10 |
|
require 5.004; |
11 |
+ |
use Exporter; |
12 |
+ |
use ActiveDoc::SimpleDoc; |
13 |
|
|
14 |
< |
BEGIN { |
15 |
< |
$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 |
< |
|
340 |
< |
# |
341 |
< |
# Parameter collection |
342 |
< |
# |
343 |
< |
sub BuildBlock_start { |
344 |
< |
my $self=shift; |
345 |
< |
my $name=shift; |
346 |
< |
my $hashref=shift; |
347 |
< |
|
348 |
< |
|
349 |
< |
my $blockobjid=$self->__blockobjid($hashref); |
350 |
< |
|
351 |
< |
if ( $self->{Arch} ) { |
352 |
< |
|
353 |
< |
|
354 |
< |
# -- get any objects that match |
355 |
< |
my $inheritobj=$self->{block}->getobj($blockobjid); |
356 |
< |
|
357 |
< |
# -- create an object with inherited properties |
358 |
< |
my $obj; |
359 |
< |
if ( ! defined $inheritobj ) { |
360 |
< |
# -- check we have a lookup for the class type |
361 |
< |
my $mapper=$self->_toolmapper(); |
362 |
< |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
363 |
< |
$self->{switch}->parseerror("Unknown class : ". |
364 |
< |
$$hashref{'class'}); |
365 |
< |
} |
366 |
< |
$obj=BuildSystem::BuildClass->new(); |
367 |
< |
} |
368 |
< |
else { |
369 |
< |
# -- inherit the properties from class with the same id class |
370 |
< |
$obj=$inheritobj->child(); |
371 |
< |
} |
372 |
< |
|
373 |
< |
# -- add changes from our tag |
374 |
< |
$obj->paramupdate($hashref); |
375 |
< |
|
376 |
< |
# -- store the new object in the block |
377 |
< |
$self->{block}->setobj($obj,$blockobjid); |
378 |
< |
} |
379 |
< |
} |
380 |
< |
|
381 |
< |
sub BuilderClass_buildmakefile { |
382 |
< |
my $self=shift; |
383 |
< |
my $name=shift; |
384 |
< |
my $hashref=shift; |
385 |
< |
|
386 |
< |
my $blockobjid=$self->__blockobjid($hashref); |
387 |
< |
|
388 |
< |
if ( $self->{Arch} ) { |
389 |
< |
# -- get the matching block object |
390 |
< |
my $blockobj=$self->{buildblock}->getobj($blockobjid); |
391 |
< |
|
392 |
< |
# -- top level buildfile |
393 |
< |
my $fh=$self->{filehandlestack}[0]; |
394 |
< |
|
395 |
< |
# -- var initialisation |
396 |
< |
my @deftypes=(); |
397 |
< |
my $buildname=""; |
398 |
< |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
399 |
< |
|
400 |
< |
# -- error checking |
401 |
< |
if ( ! defined $blockobj->param("default") ) { |
402 |
< |
$self->error("No default build parameter defined for ". |
403 |
< |
$$hashref{'class'}." ".$$hashref{'id'}); |
404 |
< |
} |
405 |
< |
if ( ! defined $blockobj->param("name") ) { |
406 |
< |
$self->error("\"name\" parameter defined for ". |
407 |
< |
$$hashref{'class'}." ".$$hashref{'id'}); |
408 |
< |
} |
409 |
< |
|
410 |
< |
|
411 |
< |
foreach $param ( $blockobj->paramlist() ) { |
412 |
< |
# -- check for params that need special handling |
413 |
< |
if ( $param eq "default" ) { |
414 |
< |
@deftypes=split /,/, $param; |
415 |
< |
} |
416 |
< |
elsif ( $param eq "name" ) { |
417 |
< |
$buildname=$blockobj->param($param); |
418 |
< |
} |
419 |
< |
else { |
420 |
< |
# -- simple transfer of block object parameters to makefile |
421 |
< |
print $fh $param.":=".$blockobj->param($param)."\n"; |
422 |
< |
} |
423 |
< |
} |
424 |
< |
|
425 |
< |
# -- construct the targets in the top makefile |
426 |
< |
$self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes); |
427 |
< |
$self->_generatetypetargets($fh,$$hashref{'class'},$buildname,@types); |
428 |
< |
|
429 |
< |
} |
430 |
< |
} |
431 |
< |
|
432 |
< |
sub _blockobjid { |
433 |
< |
my $self=shift; |
434 |
< |
my $hashref=shift; |
435 |
< |
|
436 |
< |
$self->{switch}->checktag($name,$hashref,'class'); |
437 |
< |
$self->{switch}->checktag($name,$hashref,'id'); |
438 |
< |
my $blockobjid="bc_".$$hashref{'class'},"_".$$hashref{'id'}; |
439 |
< |
|
440 |
< |
return $blockobjid; |
441 |
< |
} |
442 |
< |
|
443 |
< |
sub _generatedefaulttargets { |
444 |
< |
my $self=shift; |
445 |
< |
my $fh=shift; |
446 |
< |
my $class=shift; |
447 |
< |
|
448 |
< |
my @deftypes=shift; |
449 |
< |
|
450 |
< |
print $fh "# -- Default type targets\n"; |
451 |
< |
foreach $dtype ( @deftypes ) { |
452 |
< |
print $fh $class."::".$class."_".$dtype."\n"; |
453 |
< |
} |
454 |
< |
print $fh "\n"; |
455 |
< |
} |
456 |
< |
|
457 |
< |
sub _generatetypetargets { |
458 |
< |
my $self=shift; |
459 |
< |
my $fh=shift; |
460 |
< |
my $class=shift; |
461 |
< |
my $name=shift; |
462 |
< |
|
463 |
< |
my @types=shift; |
464 |
< |
|
465 |
< |
print $fh "# -- Generic type targets\n"; |
466 |
< |
foreach $type ( @types ) { |
467 |
< |
my $pattern=$class."_".$type; |
468 |
< |
my $dirname=$class."_".$type."_".$name; |
469 |
< |
my $makefile=$here."/BuildFile.mk"; |
470 |
< |
|
471 |
< |
# -- map to generic name for each type |
472 |
< |
print $fh "# ------ $pattern rules ---------------\n"; |
473 |
< |
print $fh $class."_".$type."::".$class. |
474 |
< |
"_".$type."_$name\n\n"; |
475 |
< |
|
476 |
< |
print $fh "# -- Link Targets to $type directories\n"; |
477 |
< |
print $fh "$dirname: make_$dirname\n"; |
478 |
< |
print $fh "\t\@cd $here; \\\n"; |
479 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1". |
480 |
< |
" workdir=$here ". |
481 |
< |
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n"; |
482 |
< |
|
483 |
< |
# -- write target to make makefile for each directory |
484 |
< |
print $fh "# -- Build target directories\n"; |
485 |
< |
print $fh "make_$dirname:\n"; |
486 |
< |
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n"; |
487 |
< |
print $fh "\t if [ ! -d \"$here\" ]; then \\\n"; |
488 |
< |
print $fh "\t mkdir $here; \\\n"; |
489 |
< |
print $fh "\t fi;\\\n"; |
490 |
< |
print $fh "\t cd $dirname; \\\n"; |
491 |
< |
print $fh "\t echo include ".$self->{currentenv}." > ". |
492 |
< |
"$makefile; \\\n"; |
493 |
< |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
494 |
< |
" >> $makefile; \\\n"; |
495 |
< |
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
496 |
< |
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
497 |
< |
if ( defined (my @file=$mapper->rulesfile($class)) ) { |
498 |
< |
foreach $f ( @file ) { |
499 |
< |
print $fh "\t echo -include $f >> $makefile; \\\n"; |
500 |
< |
} |
501 |
< |
} |
502 |
< |
print $fh "\tfi\n"; |
503 |
< |
print $fh "\n"; |
504 |
< |
|
505 |
< |
# -- cleaning targets |
506 |
< |
push @targets, "clean_$dirname"; |
507 |
< |
print $fh "# -- cleaning targets\n"; |
508 |
< |
print $fh "clean::clean_$dirname\n"; |
509 |
< |
print $fh "clean_".$dirname."::\n"; |
510 |
< |
print $fh "\t\@echo cleaning $dirname\n"; |
511 |
< |
print $fh "\t\@if [ -d $here ]; then \\\n"; |
512 |
< |
print $fh "\tcd $here; \\\n"; |
513 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=". |
514 |
< |
$here." _BuildLink_=1 -f ". |
515 |
< |
"\$(TOOL_HOME)/basics.mk clean; \\\n"; |
516 |
< |
print $fh "\tfi\n\n"; |
517 |
< |
|
518 |
< |
} |
519 |
< |
print $fh "\n"; |
520 |
< |
} |
521 |
< |
|
14 |
> |
@ISA=qw(Exporter); |
15 |
> |
@EXPORT_OK=qw( ); |
16 |
|
# |
17 |
< |
# generic build tag |
18 |
< |
# |
19 |
< |
sub Build_start { |
20 |
< |
my $self=shift; |
21 |
< |
my $name=shift; |
22 |
< |
my $hashref=shift; |
23 |
< |
|
24 |
< |
$self->{switch}->checktag($name,$hashref,'class'); |
25 |
< |
$self->{switch}->checktag($name,$hashref,'id'); |
26 |
< |
if ( $self->{Arch} ) { |
27 |
< |
|
28 |
< |
# -- determine the build products name |
29 |
< |
my $name; |
30 |
< |
if ( exists $$hashref{'name'} ) { |
31 |
< |
$name=$$hashref{'name'}; |
32 |
< |
} |
33 |
< |
else { |
34 |
< |
$self->{switch}->parseerror("No name specified for build product"); |
35 |
< |
#$name="\$(buildname)"; |
36 |
< |
} |
37 |
< |
|
38 |
< |
# -- check we have a lookup for the class type |
39 |
< |
my $mapper=$self->_toolmapper(); |
40 |
< |
if ( ! $mapper->exists($$hashref{'class'}) ) { |
41 |
< |
$self->{switch}->parseerror("Unknown class : ".$$hashref{'class'}); |
42 |
< |
} |
43 |
< |
else { |
44 |
< |
my @types=$self->_toolmapper()->types($$hashref{'class'}); |
45 |
< |
my @deftypes=$self->_toolmapper()->defaulttypes($$hashref{'class'}); |
46 |
< |
|
47 |
< |
my $fh=$self->{filehandlestack}[0]; |
48 |
< |
my @targets=(); |
49 |
< |
|
50 |
< |
# -- generate generic targets |
51 |
< |
print $fh "ifndef _BuildLink_\n"; |
52 |
< |
$self->_generatedefaulttargets($fh,$$hashref{'class'},@deftypes); |
53 |
< |
|
54 |
< |
push @targets, $$hashref{'class'}; |
55 |
< |
|
56 |
< |
# -- generate targets for each type |
57 |
< |
foreach $type ( @types ) { |
58 |
< |
|
59 |
< |
# -- generic name for each type |
60 |
< |
my $pattern=$$hashref{'class'}."_".$type; |
61 |
< |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
62 |
< |
print $fh "# ------ $pattern rules ---------------\n"; |
63 |
< |
print $fh $$hashref{'class'}."_".$type."::".$$hashref{'class'}. |
64 |
< |
"_".$type."_$name\n\n"; |
65 |
< |
|
66 |
< |
# -- create a new directory for each type |
67 |
< |
push @targets, $pattern; |
68 |
< |
my $dirname=$$hashref{'class'}."_".$type."_".$name; |
69 |
< |
my $here="$self->{localtop}/$ENV{INTwork}/".$self->{path}. |
70 |
< |
"/".$dirname; |
71 |
< |
my $makefile=$here."/BuildFile.mk"; |
72 |
< |
# AddDir::adddir($here); |
73 |
< |
|
74 |
< |
# -- create link targets to the directory |
75 |
< |
push @targets, $dirname; |
76 |
< |
print $fh "# -- Link Targets to $type directories\n"; |
77 |
< |
print $fh "$dirname: make_$dirname\n"; |
78 |
< |
print $fh "\t\@cd $here; \\\n"; |
79 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile _BuildLink_=1". |
80 |
< |
" workdir=$here ". |
81 |
< |
" -f \$(TOOL_HOME)/basics.mk datestamp \$\@; \n\n"; |
82 |
< |
|
83 |
< |
# -- write target to make makefile for each directory |
84 |
< |
print $fh "# -- Build target directories\n"; |
85 |
< |
print $fh "make_$dirname:\n"; |
86 |
< |
print $fh "\tif [ ! -e \"$makefile\" ]; then \\\n"; |
87 |
< |
print $fh "\t if [ ! -d \"$here\" ]; then \\\n"; |
88 |
< |
print $fh "\t mkdir $here; \\\n"; |
89 |
< |
print $fh "\t fi;\\\n"; |
90 |
< |
print $fh "\t cd $dirname; \\\n"; |
91 |
< |
print $fh "\t echo include ".$self->{currentenv}." > ". |
92 |
< |
"$makefile; \\\n"; |
93 |
< |
print $fh "\t echo VPATH+=$self->{localtop}/".$self->{path}. |
94 |
< |
" >> $makefile; \\\n"; |
95 |
< |
print $fh "\t echo buildname=$name >> $makefile;\\\n"; |
96 |
< |
print $fh "\t echo ".$dirname.":".$pattern." >> $makefile;\\\n"; |
97 |
< |
if ( defined (my @file=$mapper->rulesfile($$hashref{'class'})) ) { |
98 |
< |
foreach $f ( @file ) { |
99 |
< |
print $fh "\t echo -include $f >> $makefile; \\\n"; |
100 |
< |
} |
101 |
< |
} |
102 |
< |
print $fh "\tfi\n"; |
103 |
< |
print $fh "\n"; |
104 |
< |
# print $typefile "$name :\n"; |
105 |
< |
# print $typefile "\t\$(_quietbuild_)"; |
106 |
< |
# print $typefile $mapper->template($$hashref{'class'},$type)."\n"; |
107 |
< |
# print $typefile "\t\$(_quietstamp_)"; |
108 |
< |
# print $typefile "\$(SCRAMPERL) \$(SCRAM_HOME)/src/scramdatestamp \$@.ds \$@ \$^\n"; |
109 |
< |
|
110 |
< |
# -- cleaning targets |
111 |
< |
push @targets, "clean_$dirname"; |
112 |
< |
print $fh "# -- cleaning targets\n"; |
113 |
< |
print $fh "clean::clean_$dirname\n"; |
114 |
< |
print $fh "clean_".$dirname."::\n"; |
115 |
< |
print $fh "\t\@echo cleaning $dirname\n"; |
116 |
< |
print $fh "\t\@if [ -d $here ]; then \\\n"; |
117 |
< |
print $fh "\tcd $here; \\\n"; |
118 |
< |
print $fh "\t\$(MAKE) LatestBuildFile=$makefile workdir=". |
119 |
< |
$here." _BuildLink_=1 -f ". |
120 |
< |
"\$(TOOL_HOME)/basics.mk clean; \\\n"; |
121 |
< |
print $fh "\tfi\n\n"; |
122 |
< |
|
123 |
< |
|
124 |
< |
} |
125 |
< |
# -- help targets |
126 |
< |
print $fh "helpheader::\n"; |
127 |
< |
print $fh "\t\@echo Targets available:\n"; |
128 |
< |
print $fh "\t\@echo ------------------\n\n"; |
129 |
< |
print $fh "help::helpheader\n"; |
130 |
< |
foreach $target ( @targets ) { |
131 |
< |
print $fh "help::\n"; |
132 |
< |
print $fh "\t\@echo $target\n" |
133 |
< |
} |
134 |
< |
print $fh "endif\n"; |
135 |
< |
} # end else |
136 |
< |
} |
137 |
< |
} |
138 |
< |
|
139 |
< |
sub Bin_start { |
140 |
< |
my $self=shift; |
141 |
< |
my $name=shift; |
142 |
< |
my $hashref=shift; |
143 |
< |
|
144 |
< |
my $fileclass; |
145 |
< |
my @tools; |
146 |
< |
my $tool; |
147 |
< |
my $filename; |
148 |
< |
my $objectname; |
149 |
< |
|
150 |
< |
$self->{switch}->checktag($name,$hashref,'file'); |
151 |
< |
if ( $self->{Arch} ) { |
152 |
< |
if ( ! defined $$hashref{name} ) { |
153 |
< |
($$hashref{name}=$$hashref{file})=~s/\..*//; |
154 |
< |
} |
155 |
< |
($filename=$$hashref{file})=~s/\..*//; |
156 |
< |
|
157 |
< |
# Create a new directory for each binary target |
158 |
< |
my $dirname="bin_".$$hashref{name}; |
159 |
< |
AddDir::adddir("$self->{localtop}/$ENV{INTwork}/".$self->{path}."/$dirname"); |
160 |
< |
open (binGNUmakefile, |
161 |
< |
">$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(); |
17 |
> |
sub new() |
18 |
> |
############################################################### |
19 |
> |
# new # |
20 |
> |
############################################################### |
21 |
> |
# modified : Wed Dec 3 19:03:22 2003 / SFA # |
22 |
> |
# params : # |
23 |
> |
# : # |
24 |
> |
# function : # |
25 |
> |
# : # |
26 |
> |
############################################################### |
27 |
> |
{ |
28 |
> |
my $proto=shift; |
29 |
> |
my $class=ref($proto) || $proto; |
30 |
> |
$self={}; |
31 |
> |
bless $self,$class; |
32 |
> |
$self->{DEPENDENCIES} = {}; |
33 |
> |
$self->{content} = {}; |
34 |
> |
$self->{scramdoc}=ActiveDoc::SimpleDoc->new(); |
35 |
> |
$self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs',shift); |
36 |
> |
$self->{archs}=[]; |
37 |
> |
$self->{archflag}=1; |
38 |
> |
return $self; |
39 |
> |
} |
40 |
> |
|
41 |
> |
sub parse() |
42 |
> |
{ |
43 |
> |
my $self=shift; |
44 |
> |
my ($filename)=@_; |
45 |
> |
my $fhead='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><doc type="BuildSystem::BuildFile" version="1.0">'; |
46 |
> |
my $ftail='</doc>'; |
47 |
> |
$self->{scramdoc}->filetoparse($filename); |
48 |
> |
$self->{scramdoc}->parse("builder",$fhead,$ftail); |
49 |
> |
# We're done with the SimpleDoc object so delete it: |
50 |
> |
delete $self->{scramdoc}; |
51 |
> |
} |
52 |
> |
|
53 |
> |
sub classpath() |
54 |
> |
{ |
55 |
> |
my ($object,$name,%attributes)=@_; |
56 |
> |
# The getter part: |
57 |
> |
if (ref($object) eq __PACKAGE__) |
58 |
> |
{ |
59 |
> |
return $self->{content}->{CLASSPATH}; |
60 |
> |
} |
61 |
> |
if (!$self->{archflag}){return;} |
62 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'}) |
63 |
> |
: push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'}); |
64 |
> |
} |
65 |
> |
|
66 |
> |
sub productstore() |
67 |
> |
{ |
68 |
> |
my ($object,$name,%attributes)=@_; |
69 |
> |
# The getter part: |
70 |
> |
if (ref($object) eq __PACKAGE__) |
71 |
> |
{ |
72 |
> |
# Return an array of ProductStore hashes: |
73 |
> |
return $self->{content}->{PRODUCTSTORE}; |
74 |
> |
} |
75 |
> |
if (!$self->{archflag}){return;} |
76 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes) |
77 |
> |
: push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ; |
78 |
> |
} |
79 |
> |
|
80 |
> |
sub include() |
81 |
> |
{ |
82 |
> |
my $self=shift; |
83 |
> |
# Return an array of required includes: |
84 |
> |
return $self->{content}->{INCLUDE}; |
85 |
> |
} |
86 |
> |
|
87 |
> |
sub include_path() |
88 |
> |
{ |
89 |
> |
my ($object,$name,%attributes)=@_; |
90 |
> |
if (!$self->{archflag}){return;} |
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 |
> |
if (!$self->{archflag}){return;} |
108 |
> |
my ($name,%attributes)=@_; |
109 |
> |
$self->{DEPENDENCIES}->{$attributes{'name'}} = 1; |
110 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{USE}}, $attributes{'name'}) |
111 |
> |
: push(@{$self->{content}->{USE}}, $attributes{'name'}); |
112 |
> |
} |
113 |
> |
} |
114 |
> |
|
115 |
> |
sub architecture() |
116 |
> |
{ |
117 |
> |
my ($object,$name,%attributes)=@_; |
118 |
> |
my $flag=$self->{archflag}; |
119 |
> |
push @{$self->{archs}},$flag; |
120 |
> |
my $arch=$attributes{name}; |
121 |
> |
if (($flag) && ($ENV{SCRAM_ARCH}!~/$arch/)){$self->{archflag}=0;} |
122 |
> |
} |
123 |
> |
|
124 |
> |
sub architecture_() |
125 |
> |
{ |
126 |
> |
my ($object,$name,%attributes)=@_; |
127 |
> |
$self->{archflag}=pop @{$self->{archs}}; |
128 |
> |
} |
129 |
> |
|
130 |
> |
sub export() |
131 |
> |
{ |
132 |
> |
my ($object,$name,%attributes)=@_; |
133 |
> |
if (!$self->{archflag}){return;} |
134 |
> |
$self->pushlevel(); # Set nested to 1; |
135 |
> |
} |
136 |
> |
|
137 |
> |
sub export_() |
138 |
> |
{ |
139 |
> |
my ($object,$name,%attributes)=@_; |
140 |
> |
if (!$self->{archflag}){return;} |
141 |
> |
$self->{content}->{EXPORT} = $self->{tagcontent}; |
142 |
> |
$self->poplevel(); |
143 |
> |
} |
144 |
> |
|
145 |
> |
sub lib() |
146 |
> |
{ |
147 |
> |
my ($object,$name,%attributes)=@_; |
148 |
> |
# The getter part: |
149 |
> |
if (ref($object) eq __PACKAGE__) |
150 |
> |
{ |
151 |
> |
# Return an array of required libs: |
152 |
> |
return $self->{content}->{LIB}; |
153 |
> |
} |
154 |
> |
if (!$self->{archflag}){return;} |
155 |
> |
my $libname; |
156 |
> |
|
157 |
> |
if (exists($attributes{'position'})) |
158 |
> |
{ |
159 |
> |
if ($attributes{'position'} eq 'first') |
160 |
> |
{ |
161 |
> |
$libname = "F:".$attributes{'name'}; |
162 |
|
} |
163 |
< |
} |
164 |
< |
} |
165 |
< |
|
166 |
< |
sub Group_start { |
167 |
< |
my $self=shift; |
168 |
< |
my $name=shift; |
169 |
< |
my $hashref=shift; |
170 |
< |
|
171 |
< |
$self->{switch}->checktag($name, $hashref, 'name'); |
172 |
< |
if ( $self->{Arch} ) { |
173 |
< |
print GNUmakefile "GROUP_".$$hashref{'name'}; |
174 |
< |
if ( defined $$hashref{'version'} ) { |
175 |
< |
print GNUmakefile "_V_".$$hashref{'version'}; |
176 |
< |
} |
177 |
< |
print GNUmakefile "=true\n"; |
178 |
< |
} |
179 |
< |
} |
180 |
< |
|
181 |
< |
sub Use_start { |
182 |
< |
my $self=shift; |
183 |
< |
my $name=shift; |
184 |
< |
my $hashref=shift; |
185 |
< |
my $filename; |
186 |
< |
use Utilities::SCRAMUtils; |
187 |
< |
|
188 |
< |
$self->{switch}->checktag($name, $hashref, "name"); |
189 |
< |
if ( $self->{Arch} ) { |
190 |
< |
if ( exists $$hashref{'group'} ) { |
191 |
< |
print GNUmakefile "GROUP_".$$hashref{'group'}."=true\n"; |
192 |
< |
} |
193 |
< |
if ( ! defined $self->{remoteproject} ) { |
194 |
< |
$filename=SCRAMUtils::checkfile( |
195 |
< |
"/$ENV{INTsrc}/$$hashref{name}/BuildFile"); |
196 |
< |
} |
197 |
< |
else { |
198 |
< |
$filename=$self->{remoteproject}."/$$hashref{name}/BuildFile"; |
199 |
< |
print "trying $filename\n"; |
200 |
< |
if ( ! -f $filename ) { $filename=""; }; |
201 |
< |
} |
202 |
< |
if ( $filename ne "" ) { |
203 |
< |
$self->ParseBuildFile_Export( $filename ); |
204 |
< |
} |
205 |
< |
else { |
206 |
< |
$self->{switch}->parseerror("Unable to detect Appropriate ". |
207 |
< |
"decription file for <$name name=".$$hashref{name}.">"); |
208 |
< |
} |
209 |
< |
} |
210 |
< |
} |
211 |
< |
|
212 |
< |
# List association groups between <AssociateGroup> tags |
213 |
< |
# seperated by newlines or spaces |
214 |
< |
sub AssociateGroup { |
215 |
< |
my $self=shift; |
216 |
< |
my $name=shift; |
217 |
< |
my $string=shift; |
218 |
< |
my $word; |
219 |
< |
|
220 |
< |
if ( $self->{Arch} ) { |
221 |
< |
foreach $word ( (split /\s/, $string) ){ |
222 |
< |
chomp $word; |
223 |
< |
next if /^#/; |
224 |
< |
if ( $word=~/none/ ) { |
225 |
< |
$self->{ignore}=1; |
226 |
< |
} |
227 |
< |
} |
228 |
< |
} |
229 |
< |
} |
230 |
< |
|
231 |
< |
sub Arch_Start { |
232 |
< |
my $self=shift; |
233 |
< |
my $name=shift; |
234 |
< |
my $hashref=shift; |
235 |
< |
|
236 |
< |
$self->{switch}->checktag($name, $hashref,'name'); |
936 |
< |
( ($ENV{SCRAM_ARCH}=~/$$hashref{name}.*/) )? ($self->{Arch}=1) |
937 |
< |
: ($self->{Arch}=0); |
938 |
< |
push @{$self->{ARCHBLOCK}}, $self->{Arch}; |
939 |
< |
} |
940 |
< |
|
941 |
< |
sub Arch_End { |
942 |
< |
my $self=shift; |
943 |
< |
my $name=shift; |
944 |
< |
|
945 |
< |
pop @{$self->{ARCHBLOCK}}; |
946 |
< |
$self->{Arch}=$self->{ARCHBLOCK}[$#{$self->{ARCHBLOCK}}]; |
947 |
< |
} |
948 |
< |
|
949 |
< |
# Split up the Class Block String into a useable array |
950 |
< |
sub _CutBlock { |
951 |
< |
my $self=shift; |
952 |
< |
my $string= shift @_; |
953 |
< |
@BlockClassA = split /\//, $string; |
954 |
< |
} |
955 |
< |
|
956 |
< |
sub OutToMakefile { |
957 |
< |
my $self=shift; |
958 |
< |
my $name=shift; |
959 |
< |
my @vars=@_; |
960 |
< |
|
961 |
< |
if ( $self->{Arch} ) { |
962 |
< |
print GNUmakefile @vars; |
963 |
< |
} |
964 |
< |
} |
965 |
< |
|
966 |
< |
sub OutToScreen { |
967 |
< |
my $name=shift; |
968 |
< |
my @vars=@_; |
969 |
< |
|
970 |
< |
if ( $self->{Arch} ) { |
971 |
< |
print @vars; |
972 |
< |
} |
973 |
< |
} |
974 |
< |
sub setBlockClassPath { |
975 |
< |
my $self=shift; |
976 |
< |
my $name=shift; |
977 |
< |
my $hashref=shift; |
978 |
< |
|
979 |
< |
$self->{switch}->checktag($name, $hashref, 'path'); |
980 |
< |
$self->{BlockClassPath}=$self->{BlockClassPath}.":".$$hashref{path}; |
981 |
< |
$self->_CutBlock($$hashref{path}); |
982 |
< |
} |
983 |
< |
|
984 |
< |
sub BlockClassPath { |
985 |
< |
my $self=shift; |
986 |
< |
return $self->{BlockClassPath}; |
987 |
< |
} |
988 |
< |
|
989 |
< |
sub export_start_export { |
990 |
< |
my $self=shift; |
991 |
< |
my $name=shift; |
992 |
< |
my $hashref=shift; |
993 |
< |
|
994 |
< |
$self->{switch}->opengroup("__export"); |
995 |
< |
} |
996 |
< |
|
997 |
< |
sub export_start { |
998 |
< |
my $self=shift; |
999 |
< |
my $name=shift; |
1000 |
< |
my $hashref=shift; |
1001 |
< |
|
1002 |
< |
$self->{switch}->opengroup("__export"); |
1003 |
< |
if ( exists $$hashref{autoexport} ) { |
1004 |
< |
print GNUmakefile "scram_autoexport=".$$hashref{autoexport}."\n"; |
1005 |
< |
if ( $$hashref{autoexport}=~/true/ ) { |
1006 |
< |
$self->{switch}->allowgroup("__export","makebuild"); |
1007 |
< |
} |
1008 |
< |
else { |
1009 |
< |
$self->{switch}->disallowgroup("__export","makebuild"); |
1010 |
< |
} |
1011 |
< |
} |
1012 |
< |
# -- allow default setting from other makefiles |
1013 |
< |
print GNUmakefile "ifeq (\$(scram_autoexport),true)\n"; |
1014 |
< |
} |
1015 |
< |
|
1016 |
< |
sub export_end_export { |
1017 |
< |
my $self=shift; |
1018 |
< |
$self->{switch}->closegroup("__export"); |
1019 |
< |
} |
1020 |
< |
|
1021 |
< |
sub export_end { |
1022 |
< |
my $self=shift; |
1023 |
< |
$self->{switch}->closegroup("__export"); |
1024 |
< |
print GNUmakefile "endif\n"; |
1025 |
< |
} |
163 |
> |
else |
164 |
> |
{ |
165 |
> |
# There was a position entry but it didn't make sense: |
166 |
> |
$libname = $attributes{'name'}; |
167 |
> |
} |
168 |
> |
} |
169 |
> |
else |
170 |
> |
{ |
171 |
> |
$libname = $attributes{'name'}; |
172 |
> |
} |
173 |
> |
# We have a libname, add it to the list: |
174 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname) |
175 |
> |
: push(@{$self->{content}->{LIB}}, $libname); |
176 |
> |
} |
177 |
> |
|
178 |
> |
sub makefile() |
179 |
> |
{ |
180 |
> |
my ($object,$name,%attributes)=@_; |
181 |
> |
# The getter part: |
182 |
> |
if (ref($object) eq __PACKAGE__) |
183 |
> |
{ |
184 |
> |
return $self->{content}->{MAKEFILE}; |
185 |
> |
} |
186 |
> |
} |
187 |
> |
|
188 |
> |
sub makefile_() |
189 |
> |
{ |
190 |
> |
my ($object,$name,$cdata)=@_; |
191 |
> |
if (!$self->{archflag}){return;} |
192 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@$cdata)) |
193 |
> |
: push(@{$self->{content}->{MAKEFILE}}, join("\n",@$cdata)); |
194 |
> |
} |
195 |
> |
|
196 |
> |
sub flags() |
197 |
> |
{ |
198 |
> |
my ($object,$name,%attributes)=@_; |
199 |
> |
# The getter part: |
200 |
> |
if (ref($object) eq __PACKAGE__) |
201 |
> |
{ |
202 |
> |
# Return an array of ProductStore hashes: |
203 |
> |
return $self->{content}->{FLAGS}; |
204 |
> |
} |
205 |
> |
if (!$self->{archflag}){return;} |
206 |
> |
# Extract the flag name and its value: |
207 |
> |
my ($flagname,$flagvaluestring) = each %attributes; |
208 |
> |
$flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase |
209 |
> |
chomp($flagvaluestring); |
210 |
> |
my @flagvalues = ( $flagvaluestring ); |
211 |
> |
# Is current tag within another tag block? |
212 |
> |
if ($self->{nested} == 1) |
213 |
> |
{ |
214 |
> |
# Check to see if the current flag name is already stored in the hash. If so, |
215 |
> |
# just add the new values to the array of flag values: |
216 |
> |
if (exists ($self->{tagcontent}->{FLAGS}->{$flagname})) |
217 |
> |
{ |
218 |
> |
push(@{$self->{tagcontent}->{FLAGS}->{$flagname}},@flagvalues); |
219 |
> |
} |
220 |
> |
else |
221 |
> |
{ |
222 |
> |
$self->{tagcontent}->{FLAGS}->{$flagname} = [ @flagvalues ]; |
223 |
> |
} |
224 |
> |
} |
225 |
> |
else |
226 |
> |
{ |
227 |
> |
if (exists ($self->{content}->{FLAGS}->{$flagname})) |
228 |
> |
{ |
229 |
> |
push(@{$self->{content}->{FLAGS}->{$flagname}},@flagvalues); |
230 |
> |
} |
231 |
> |
else |
232 |
> |
{ |
233 |
> |
$self->{content}->{FLAGS}->{$flagname} = [ @flagvalues ]; |
234 |
> |
} |
235 |
> |
} |
236 |
> |
} |
237 |
|
|
238 |
< |
# |
239 |
< |
# Standard lib tag |
240 |
< |
# |
241 |
< |
sub lib_start { |
242 |
< |
my $self=shift; |
243 |
< |
my $name=shift; |
244 |
< |
my $hashref=shift; |
245 |
< |
|
246 |
< |
$self->{switch}->checktag($name, $hashref, 'name'); |
247 |
< |
if ( $self->{Arch} ) { |
248 |
< |
print GNUmakefile "lib+=$$hashref{name}\n"; |
249 |
< |
} |
250 |
< |
} |
238 |
> |
sub allflags() |
239 |
> |
{ |
240 |
> |
my $self=shift; |
241 |
> |
# Return hash data for flags: |
242 |
> |
return $self->{content}->{FLAGS}; |
243 |
> |
} |
244 |
> |
|
245 |
> |
sub bin() |
246 |
> |
{ |
247 |
> |
my ($object,$name,%attributes) = @_; |
248 |
> |
if (!$self->{archflag}){return;} |
249 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
250 |
> |
} |
251 |
> |
|
252 |
> |
sub bin_() |
253 |
> |
{ |
254 |
> |
my ($object,$name,%attributes) = @_; |
255 |
> |
if (!$self->{archflag}){return;} |
256 |
> |
# Need unique name for the binary (always use name of product). Either use "name" |
257 |
> |
# given, or use "file" value minus the ending: |
258 |
> |
if (exists ($self->{id}->{'name'})) |
259 |
> |
{ |
260 |
> |
$name = $self->{id}->{'name'}; |
261 |
> |
} |
262 |
> |
else |
263 |
> |
{ |
264 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
265 |
> |
} |
266 |
> |
|
267 |
> |
# Store the data: |
268 |
> |
$self->productcollector($name,'bin','BIN'); |
269 |
> |
$self->poplevel(); |
270 |
> |
} |
271 |
> |
|
272 |
> |
sub library() |
273 |
> |
{ |
274 |
> |
my ($object,$name,%attributes) = @_; |
275 |
> |
if (!$self->{archflag}){return;} |
276 |
> |
$self->pushlevel(\%attributes);# Set nested to 1; |
277 |
> |
} |
278 |
> |
|
279 |
> |
sub library_() |
280 |
> |
{ |
281 |
> |
my ($object,$name,%attributes) = @_; |
282 |
> |
if (!$self->{archflag}){return;} |
283 |
> |
# Need unique name for the library (always use name of product). Either use "name" |
284 |
> |
# given, or use "file" value minus the ending: |
285 |
> |
if (exists ($self->{id}->{'name'})) |
286 |
> |
{ |
287 |
> |
$name = $self->{id}->{'name'}; |
288 |
> |
} |
289 |
> |
else |
290 |
> |
{ |
291 |
> |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
292 |
> |
} |
293 |
> |
|
294 |
> |
# Store the data: |
295 |
> |
$self->productcollector($name,'lib','LIBRARY'); |
296 |
> |
$self->poplevel(); |
297 |
> |
} |
298 |
> |
|
299 |
> |
sub productcollector() |
300 |
> |
{ |
301 |
> |
my $self=shift; |
302 |
> |
my ($name,$typeshort,$typefull)=@_; |
303 |
> |
# Create a new Product object for storage of data: |
304 |
> |
use BuildSystem::Product; |
305 |
> |
my $product = BuildSystem::Product->new(); |
306 |
> |
# Store the name: |
307 |
> |
$product->name($name); |
308 |
> |
$product->type($typeshort); |
309 |
> |
# Store the files. Take the BuildFile path as the initial path for |
310 |
> |
# expanding source file globs: |
311 |
> |
$product->_files($self->{id}->{'file'},[ $self->{scramdoc}->filetoparse() ]); |
312 |
> |
# Store the data content: |
313 |
> |
$product->_data($self->{tagcontent}); |
314 |
> |
# And store in a hash (all build products in same place): |
315 |
> |
$self->{content}->{BUILDPRODUCTS}->{$typefull}->{$name} = $product; |
316 |
> |
} |
317 |
> |
|
318 |
> |
sub pushlevel |
319 |
> |
{ |
320 |
> |
my $self = shift; |
321 |
> |
my ($info)=@_; |
322 |
> |
|
323 |
> |
$self->{id} = $info if (defined $info); |
324 |
> |
$self->{nested} = 1; |
325 |
> |
$self->{tagcontent}={}; |
326 |
> |
} |
327 |
> |
|
328 |
> |
sub poplevel |
329 |
> |
{ |
330 |
> |
my $self = shift; |
331 |
> |
delete $self->{id}; |
332 |
> |
delete $self->{nested}; |
333 |
> |
delete $self->{tagcontent}; |
334 |
> |
} |
335 |
> |
|
336 |
> |
sub dependencies() |
337 |
> |
{ |
338 |
> |
my $self=shift; |
339 |
> |
# Make a copy of the variable so that |
340 |
> |
# we don't have a DEPENDENCIES entry in RAWDATA: |
341 |
> |
my %DEPS=%{$self->{DEPENDENCIES}}; |
342 |
> |
delete $self->{DEPENDENCIES}; |
343 |
> |
return \%DEPS; |
344 |
> |
} |
345 |
> |
|
346 |
> |
sub skippeddirs() |
347 |
> |
{ |
348 |
> |
my $self=shift; |
349 |
> |
my ($here)=@_; |
350 |
> |
my $skipped; |
351 |
> |
|
352 |
> |
if ($self->{content}->{SKIPPEDDIRS}->[0] == 1) |
353 |
> |
{ |
354 |
> |
$skipped = [ @{$self->{content}->{SKIPPEDDIRS}} ]; |
355 |
> |
delete $self->{content}->{SKIPPEDDIRS}; |
356 |
> |
} |
357 |
> |
|
358 |
> |
delete $self->{content}->{SKIPPEDDIRS}; |
359 |
> |
return $skipped; |
360 |
> |
} |
361 |
> |
|
362 |
> |
sub hasexport() |
363 |
> |
{ |
364 |
> |
my $self=shift; |
365 |
> |
# Check to see if there is a valid export block: |
366 |
> |
my $nkeys = $self->exporteddatatypes(); |
367 |
> |
$nkeys > 0 ? return 1 : return 0; |
368 |
> |
} |
369 |
> |
|
370 |
> |
sub has() |
371 |
> |
{ |
372 |
> |
my $self=shift; |
373 |
> |
my ($datatype)=@_; |
374 |
> |
(exists ($self->{content}->{$datatype})) ? return 1 : return 0; |
375 |
> |
} |
376 |
> |
|
377 |
> |
sub exported() |
378 |
> |
{ |
379 |
> |
my $self=shift; |
380 |
> |
# Return a hash. Keys are type of data provided: |
381 |
> |
return ($self->{content}->{EXPORT}); |
382 |
> |
} |
383 |
> |
|
384 |
> |
sub exporteddatatypes() |
385 |
> |
{ |
386 |
> |
my $self=shift; |
387 |
> |
# Return exported data types: |
388 |
> |
return keys %{$self->{content}->{EXPORT}}; |
389 |
> |
} |
390 |
> |
|
391 |
> |
sub buildproducts() |
392 |
> |
{ |
393 |
> |
my $self=shift; |
394 |
> |
# Returns hash of build products and their data: |
395 |
> |
return $self->{content}->{BUILDPRODUCTS}; |
396 |
> |
} |
397 |
> |
|
398 |
> |
sub values() |
399 |
> |
{ |
400 |
> |
my $self=shift; |
401 |
> |
my ($type)=@_; |
402 |
> |
# Get a list of values from known types |
403 |
> |
return $self->{content}->{BUILDPRODUCTS}->{$type}; |
404 |
> |
} |
405 |
> |
|
406 |
> |
sub basic_tags() |
407 |
> |
{ |
408 |
> |
my $self=shift; |
409 |
> |
my $datatags=[]; |
410 |
> |
my $buildtags=[ qw(BIN LIBRARY BUILDPRODUCTS) ]; |
411 |
> |
my $skiptags=[ qw(ARCH EXPORT USE CLASSPATH) ]; |
412 |
> |
my $otherskiptags=[ qw( SKIPPEDDIRS ) ]; |
413 |
> |
my @all_skip_tags; |
414 |
> |
|
415 |
> |
push(@all_skip_tags,@$skiptags,@$buildtags,@$otherskiptags); |
416 |
> |
|
417 |
> |
foreach my $t (keys %{$self->{content}}) |
418 |
> |
{ |
419 |
> |
push(@$datatags,$t),if (! grep($t eq $_, @all_skip_tags)); |
420 |
> |
} |
421 |
> |
return @{$datatags}; |
422 |
> |
} |
423 |
> |
|
424 |
> |
sub clean() |
425 |
> |
{ |
426 |
> |
my $self=shift; |
427 |
> |
my (@tags) = @_; |
428 |
> |
|
429 |
> |
# Delete some useless entries: |
430 |
> |
delete $self->{simpledoc}; |
431 |
> |
delete $self->{id}; |
432 |
> |
delete $self->{tagcontent}; |
433 |
> |
delete $self->{nested}; |
434 |
> |
|
435 |
> |
delete $self->{DEPENDENCIES}; |
436 |
> |
|
437 |
> |
map |
438 |
> |
{ |
439 |
> |
delete $self->{content}->{$_} if (exists($self->{content}->{$_})); |
440 |
> |
} @tags; |
441 |
> |
|
442 |
> |
return $self; |
443 |
> |
} |
444 |
> |
|
445 |
> |
sub AUTOLOAD() |
446 |
> |
{ |
447 |
> |
my ($xmlparser,$name,%attributes)=@_; |
448 |
> |
return if $AUTOLOAD =~ /::DESTROY$/; |
449 |
> |
my $name=$AUTOLOAD; |
450 |
> |
$name =~ s/.*://; |
451 |
> |
} |
452 |
|
|
453 |
< |
# |
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 |
< |
} |
453 |
> |
1; |