3 |
|
#____________________________________________________________________ |
4 |
|
# |
5 |
|
# Author: Shaun Ashby <Shaun.Ashby@cern.ch> |
6 |
– |
# Update: 2003-12-03 19:03:15+0100 |
7 |
– |
# Revision: $Id$ |
8 |
– |
# |
6 |
|
# Copyright: 2003 (C) Shaun Ashby |
7 |
|
# |
8 |
|
#-------------------------------------------------------------------- |
32 |
|
$self->{DEPENDENCIES} = {}; |
33 |
|
$self->{content} = {}; |
34 |
|
$self->{scramdoc}=ActiveDoc::SimpleDoc->new(); |
35 |
< |
$self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs'); |
35 |
> |
$self->{scramdoc}->newparse("builder",__PACKAGE__,'Subs',shift); |
36 |
> |
$self->{archs}=[]; |
37 |
> |
$self->{archflag}=1; |
38 |
|
return $self; |
39 |
|
} |
40 |
|
|
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"); |
48 |
> |
$self->{scramdoc}->parse("builder",$fhead,$ftail); |
49 |
|
# We're done with the SimpleDoc object so delete it: |
50 |
|
delete $self->{scramdoc}; |
51 |
|
} |
58 |
|
{ |
59 |
|
return $self->{content}->{CLASSPATH}; |
60 |
|
} |
61 |
< |
|
61 |
> |
if (!$self->{archflag}){return;} |
62 |
|
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{CLASSPATH}}, $attributes{'path'}) |
63 |
|
: push(@{$self->{content}->{CLASSPATH}}, $attributes{'path'}); |
64 |
|
} |
72 |
|
# Return an array of ProductStore hashes: |
73 |
|
return $self->{content}->{PRODUCTSTORE}; |
74 |
|
} |
75 |
< |
|
75 |
> |
if (!$self->{archflag}){return;} |
76 |
|
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{PRODUCTSTORE}}, \%attributes) |
77 |
|
: push(@{$self->{content}->{PRODUCTSTORE}}, \%attributes) ; |
78 |
|
} |
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 |
|
} |
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'}) |
115 |
|
sub architecture() |
116 |
|
{ |
117 |
|
my ($object,$name,%attributes)=@_; |
118 |
< |
$self->pushlevel(\%attributes); # Set nested to 1; |
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 |
< |
$self->{content}->{ARCH}->{$self->{id}->{'name'}}=$self->{tagcontent}; |
127 |
< |
$self->poplevel(); |
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 |
|
} |
151 |
|
# Return an array of required libs: |
152 |
|
return $self->{content}->{LIB}; |
153 |
|
} |
154 |
< |
|
155 |
< |
my $libname; |
146 |
< |
|
147 |
< |
if (exists($attributes{'position'})) |
148 |
< |
{ |
149 |
< |
if ($attributes{'position'} eq 'first') |
150 |
< |
{ |
151 |
< |
$libname = "F:".$attributes{'name'}; |
152 |
< |
} |
153 |
< |
else |
154 |
< |
{ |
155 |
< |
# There was a position entry but it didn't make sense: |
156 |
< |
$libname = $attributes{'name'}; |
157 |
< |
} |
158 |
< |
} |
159 |
< |
else |
160 |
< |
{ |
161 |
< |
$libname = $attributes{'name'}; |
162 |
< |
} |
154 |
> |
if (!$self->{archflag}){return;} |
155 |
> |
my $libname = $attributes{'name'}; |
156 |
|
# We have a libname, add it to the list: |
157 |
|
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIB}}, $libname) |
158 |
|
: push(@{$self->{content}->{LIB}}, $libname); |
159 |
|
} |
160 |
|
|
168 |
– |
sub libtype() |
169 |
– |
{ |
170 |
– |
my ($object,$name,%attributes)=@_; |
171 |
– |
# The getter part: |
172 |
– |
if (ref($object) eq __PACKAGE__) |
173 |
– |
{ |
174 |
– |
# Return an array of required libs: |
175 |
– |
return $self->{content}->{LIBTYPE}; |
176 |
– |
} |
177 |
– |
|
178 |
– |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{LIBTYPE}}, $attributes{'type'}) |
179 |
– |
: push(@{$self->{content}->{LIBTYPE}}, $attributes{'type'}); |
180 |
– |
} |
181 |
– |
|
182 |
– |
sub skip() |
183 |
– |
{ |
184 |
– |
my ($object,$name,%attributes)=@_; |
185 |
– |
$self->{nested} == 1 ? $self->{tagcontent}->{SKIPPEDDIRS} = [ 1 ] |
186 |
– |
: $self->{content}->{SKIPPEDDIRS} = [ 1 ]; |
187 |
– |
} |
188 |
– |
|
189 |
– |
sub skip_message() |
190 |
– |
{ |
191 |
– |
my ($object,$name,@message) = @_; |
192 |
– |
# Save any message text between <skip> tags: |
193 |
– |
if ($#message > -1) |
194 |
– |
{ |
195 |
– |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{SKIPPEDDIRS}}, [ @message ]) |
196 |
– |
: push(@{$self->{content}->{SKIPPEDDIRS}}, [ @message ]); |
197 |
– |
} |
198 |
– |
} |
199 |
– |
|
200 |
– |
sub skip_() |
201 |
– |
{ |
202 |
– |
my ($object,$name)=@_; |
203 |
– |
} |
204 |
– |
|
161 |
|
sub makefile() |
162 |
|
{ |
163 |
|
my ($object,$name,%attributes)=@_; |
164 |
|
# The getter part: |
165 |
|
if (ref($object) eq __PACKAGE__) |
166 |
|
{ |
211 |
– |
# Return Makefile content: |
167 |
|
return $self->{content}->{MAKEFILE}; |
168 |
|
} |
214 |
– |
|
215 |
– |
# Set our own Char handler so we can collect the content |
216 |
– |
# of the Makefile tag: |
217 |
– |
$object->setHandlers(Char => \&makefile_content); |
218 |
– |
$self->{makefilecontent} = []; |
219 |
– |
} |
220 |
– |
|
221 |
– |
sub makefile_content() |
222 |
– |
{ |
223 |
– |
my ($object, @strings) = @_; |
224 |
– |
push(@{$self->{makefilecontent}},@strings); |
169 |
|
} |
170 |
|
|
171 |
|
sub makefile_() |
172 |
|
{ |
173 |
< |
my ($object,$name)=@_; |
174 |
< |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join('',@{$self->{makefilecontent}})) |
175 |
< |
: push(@{$self->{content}->{MAKEFILE}}, join('',@{$self->{makefilecontent}})); |
176 |
< |
delete $self->{makefilecontent}; |
233 |
< |
# Unset the Char handler to revert to the default behaviour: |
234 |
< |
$object->setHandlers(Char => 0); |
235 |
< |
} |
236 |
< |
|
237 |
< |
sub define_group() |
238 |
< |
{ |
239 |
< |
my ($object,$name,%attributes)=@_; |
240 |
< |
$self->pushlevel(\%attributes); # Set nested to 1; |
241 |
< |
} |
242 |
< |
|
243 |
< |
sub define_group_() |
244 |
< |
{ |
245 |
< |
$self->{content}->{DEFINED_GROUP}->{$self->{id}->{'name'}}=$self->{tagcontent}; |
246 |
< |
$self->poplevel(); |
247 |
< |
} |
248 |
< |
|
249 |
< |
sub group() |
250 |
< |
{ |
251 |
< |
my $object=shift; |
252 |
< |
# The getter part: |
253 |
< |
if (ref($object) eq __PACKAGE__) |
254 |
< |
{ |
255 |
< |
# Add or return groups: |
256 |
< |
@_ ? push(@{$self->{content}->{GROUP}},@_) |
257 |
< |
: @{$self->{content}->{GROUP}}; |
258 |
< |
} |
259 |
< |
else |
260 |
< |
{ |
261 |
< |
my ($name,%attributes)=@_; |
262 |
< |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{GROUP}}, $attributes{'name'}) |
263 |
< |
: push(@{$self->{content}->{GROUP}}, $attributes{'name'}); |
264 |
< |
} |
173 |
> |
my ($object,$name,$cdata)=@_; |
174 |
> |
if (!$self->{archflag}){return;} |
175 |
> |
$self->{nested} == 1 ? push(@{$self->{tagcontent}->{MAKEFILE}}, join("\n",@$cdata)) |
176 |
> |
: push(@{$self->{content}->{MAKEFILE}}, join("\n",@$cdata)); |
177 |
|
} |
178 |
|
|
179 |
|
sub flags() |
185 |
|
# Return an array of ProductStore hashes: |
186 |
|
return $self->{content}->{FLAGS}; |
187 |
|
} |
188 |
< |
|
188 |
> |
if (!$self->{archflag}){return;} |
189 |
|
# Extract the flag name and its value: |
190 |
|
my ($flagname,$flagvaluestring) = each %attributes; |
191 |
|
$flagname =~ tr/[a-z]/[A-Z]/; # Keep flag name uppercase |
192 |
|
chomp($flagvaluestring); |
193 |
< |
# Split the value on whitespace so we can push all |
282 |
< |
# individual flags into an array: |
283 |
< |
my @flagvalues = split(' ',$flagvaluestring); |
193 |
> |
my @flagvalues = ( $flagvaluestring ); |
194 |
|
# Is current tag within another tag block? |
195 |
|
if ($self->{nested} == 1) |
196 |
|
{ |
225 |
|
return $self->{content}->{FLAGS}; |
226 |
|
} |
227 |
|
|
318 |
– |
sub archspecific() |
319 |
– |
{ |
320 |
– |
my $self=shift; |
321 |
– |
|
322 |
– |
# Check to see if there is arch-dependent data. If so, return it: |
323 |
– |
if ((my $nkeys=keys %{$self->{content}->{ARCH}}) > 0) |
324 |
– |
{ |
325 |
– |
while (my ($k,$v) = each %{$self->{content}->{ARCH}}) |
326 |
– |
{ |
327 |
– |
if ( $ENV{SCRAM_ARCH} =~ /$k.*/ ) |
328 |
– |
{ |
329 |
– |
return $self->{content}->{ARCH}->{$k}; |
330 |
– |
} |
331 |
– |
} |
332 |
– |
} |
333 |
– |
return ""; |
334 |
– |
} |
335 |
– |
|
228 |
|
sub bin() |
229 |
|
{ |
230 |
|
my ($object,$name,%attributes) = @_; |
231 |
+ |
if (!$self->{archflag}){return;} |
232 |
|
$self->pushlevel(\%attributes);# Set nested to 1; |
233 |
|
} |
234 |
|
|
235 |
|
sub bin_() |
236 |
|
{ |
237 |
+ |
my ($object,$name,%attributes) = @_; |
238 |
+ |
if (!$self->{archflag}){return;} |
239 |
|
# Need unique name for the binary (always use name of product). Either use "name" |
240 |
|
# given, or use "file" value minus the ending: |
241 |
|
if (exists ($self->{id}->{'name'})) |
252 |
|
$self->poplevel(); |
253 |
|
} |
254 |
|
|
360 |
– |
sub module() |
361 |
– |
{ |
362 |
– |
my ($object,$name,%attributes) = @_; |
363 |
– |
$self->pushlevel(\%attributes);# Set nested to 1; |
364 |
– |
} |
365 |
– |
|
366 |
– |
sub module_() |
367 |
– |
{ |
368 |
– |
# Need unique name for the module (always use name of product). Either use "name" |
369 |
– |
# given, or use "file" value minus the ending: |
370 |
– |
if (exists ($self->{id}->{'name'})) |
371 |
– |
{ |
372 |
– |
$name = $self->{id}->{'name'}; |
373 |
– |
} |
374 |
– |
else |
375 |
– |
{ |
376 |
– |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
377 |
– |
} |
378 |
– |
|
379 |
– |
# Store the data: |
380 |
– |
$self->productcollector($name,'mod','MODULE'); |
381 |
– |
$self->poplevel(); |
382 |
– |
} |
383 |
– |
|
384 |
– |
sub application() |
385 |
– |
{ |
386 |
– |
my ($object,$name,%attributes) = @_; |
387 |
– |
$self->pushlevel(\%attributes);# Set nested to 1; |
388 |
– |
} |
389 |
– |
|
390 |
– |
sub application_() |
391 |
– |
{ |
392 |
– |
# Need unique name for the application (always use name of product). Either use "name" |
393 |
– |
# given, or use "file" value minus the ending: |
394 |
– |
if (exists ($self->{id}->{'name'})) |
395 |
– |
{ |
396 |
– |
$name = $self->{id}->{'name'}; |
397 |
– |
} |
398 |
– |
else |
399 |
– |
{ |
400 |
– |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
401 |
– |
} |
402 |
– |
|
403 |
– |
# Store the data: |
404 |
– |
$self->productcollector($name,'app','APPLICATION'); |
405 |
– |
$self->poplevel(); |
406 |
– |
} |
407 |
– |
|
255 |
|
sub library() |
256 |
|
{ |
257 |
|
my ($object,$name,%attributes) = @_; |
258 |
+ |
if (!$self->{archflag}){return;} |
259 |
|
$self->pushlevel(\%attributes);# Set nested to 1; |
260 |
|
} |
261 |
|
|
262 |
|
sub library_() |
263 |
|
{ |
264 |
+ |
my ($object,$name,%attributes) = @_; |
265 |
+ |
if (!$self->{archflag}){return;} |
266 |
|
# Need unique name for the library (always use name of product). Either use "name" |
267 |
|
# given, or use "file" value minus the ending: |
268 |
|
if (exists ($self->{id}->{'name'})) |
279 |
|
$self->poplevel(); |
280 |
|
} |
281 |
|
|
432 |
– |
sub plugin() |
433 |
– |
{ |
434 |
– |
my ($object,$name,%attributes) = @_; |
435 |
– |
$self->pushlevel(\%attributes);# Set nested to 1; |
436 |
– |
} |
437 |
– |
|
438 |
– |
sub plugin_() |
439 |
– |
{ |
440 |
– |
# Need unique name for the plugin (always use name of product). Either use "name" |
441 |
– |
# given, or use "file" value minus the ending: |
442 |
– |
if (exists ($self->{id}->{'name'})) |
443 |
– |
{ |
444 |
– |
$name = $self->{id}->{'name'}; |
445 |
– |
} |
446 |
– |
else |
447 |
– |
{ |
448 |
– |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
449 |
– |
} |
450 |
– |
|
451 |
– |
# Store the data: |
452 |
– |
$self->productcollector($name,'plugin','PLUGIN'); |
453 |
– |
$self->poplevel(); |
454 |
– |
} |
455 |
– |
|
456 |
– |
sub unittest() |
457 |
– |
{ |
458 |
– |
my ($object,$name,%attributes) = @_; |
459 |
– |
$self->pushlevel(\%attributes);# Set nested to 1; |
460 |
– |
} |
461 |
– |
|
462 |
– |
sub unittest_() |
463 |
– |
{ |
464 |
– |
# Need unique name for the unittest (always use name of product). Either use "name" |
465 |
– |
# given, or use "file" value minus the ending: |
466 |
– |
if (exists ($self->{id}->{'name'})) |
467 |
– |
{ |
468 |
– |
$name = $self->{id}->{'name'}; |
469 |
– |
} |
470 |
– |
else |
471 |
– |
{ |
472 |
– |
($name) = ($self->{id}->{'file'} =~ /(.*)?\..*$/); |
473 |
– |
} |
474 |
– |
|
475 |
– |
# Store the data: |
476 |
– |
$self->productcollector($name,'unittest','unittest'); |
477 |
– |
$self->poplevel(); |
478 |
– |
} |
479 |
– |
|
282 |
|
sub productcollector() |
283 |
|
{ |
284 |
|
my $self=shift; |
371 |
|
return keys %{$self->{content}->{EXPORT}}; |
372 |
|
} |
373 |
|
|
572 |
– |
sub defined_group() |
573 |
– |
{ |
574 |
– |
my $self=shift; |
575 |
– |
|
576 |
– |
if (exists($self->{content}->{DEFINED_GROUP})) |
577 |
– |
{ |
578 |
– |
# Return a list of keys (group names) for defined groups: |
579 |
– |
return [ keys %{$self->{content}->{DEFINED_GROUP}} ]; |
580 |
– |
} |
581 |
– |
else |
582 |
– |
{ |
583 |
– |
return 0; |
584 |
– |
} |
585 |
– |
} |
586 |
– |
|
587 |
– |
sub dataforgroup() |
588 |
– |
{ |
589 |
– |
my $self=shift; |
590 |
– |
my ($groupname)=@_; |
591 |
– |
# Return hash containing data for defined group |
592 |
– |
# $groupname or return undef: |
593 |
– |
return $self->{content}->{DEFINED_GROUP}->{$groupname}; |
594 |
– |
} |
595 |
– |
|
374 |
|
sub buildproducts() |
375 |
|
{ |
376 |
|
my $self=shift; |
390 |
|
{ |
391 |
|
my $self=shift; |
392 |
|
my $datatags=[]; |
393 |
< |
my $buildtags=[ qw(BIN LIBRARY APPLICATION MODULE PLUGIN BUILDPRODUCTS) ]; |
394 |
< |
my $skiptags=[ qw(DEFINED_GROUP ARCH EXPORT GROUP USE CLASSPATH) ]; |
393 |
> |
my $buildtags=[ qw(BIN LIBRARY BUILDPRODUCTS) ]; |
394 |
> |
my $skiptags=[ qw(ARCH EXPORT USE CLASSPATH) ]; |
395 |
|
my $otherskiptags=[ qw( SKIPPEDDIRS ) ]; |
396 |
|
my @all_skip_tags; |
397 |
|
|
410 |
|
my (@tags) = @_; |
411 |
|
|
412 |
|
# Delete some useless entries: |
635 |
– |
delete $self->{makefilecontent}; |
413 |
|
delete $self->{simpledoc}; |
414 |
|
delete $self->{id}; |
415 |
|
delete $self->{tagcontent}; |