18 |
|
# addfeature(name,@value) : add value(s) to the named feature |
19 |
|
# setfeature(name,@value) : set value(s) for the named feature |
20 |
|
# getfeature(name) : return a list of elements belonging to the named feature |
21 |
+ |
# (with embedded dependencies) |
22 |
+ |
# type(name[,type]) : get/set the type associated with a feature |
23 |
|
# addrequirement() : add a requirement at the current parse position |
24 |
|
# dependencies() : return a list of dependency objects |
25 |
+ |
# nonembeddeddependencies() : return a list of dependency objects that |
26 |
+ |
# are not embedded into the parameters |
27 |
+ |
# save(location) : Save object to given file |
28 |
+ |
# restore(location) : Restore object from specified file |
29 |
|
|
30 |
|
package BuildSystem::Tool; |
31 |
|
require 5.004; |
58 |
|
:$self->{url}; |
59 |
|
} |
60 |
|
|
61 |
+ |
sub type { |
62 |
+ |
my $self=shift; |
63 |
+ |
my $name=shift; |
64 |
+ |
|
65 |
+ |
if ( @_ ) { |
66 |
+ |
$self->{featuretypes}{$name}=shift; |
67 |
+ |
} |
68 |
+ |
return ((defined $self->{featuretypes}{$name})? |
69 |
+ |
$self->{featuretypes}{$name}:""); |
70 |
+ |
} |
71 |
|
|
72 |
|
sub addfeature { |
73 |
|
my $self=shift; |
153 |
|
return @{$self->{recobjs}} |
154 |
|
} |
155 |
|
|
156 |
+ |
sub save { |
157 |
+ |
my $self=shift; |
158 |
+ |
my $location=shift; |
159 |
+ |
|
160 |
+ |
my $fh=FileHandle->new(); |
161 |
+ |
$fh->open(">".$location) or die "Unable to open $location for output". |
162 |
+ |
$!."\n"; |
163 |
+ |
print $fh "_sys:name:".$self->name()."\n"; |
164 |
+ |
print $fh "_sys:version:".$self->version()."\n"; |
165 |
+ |
foreach $f ( $self->features()) { |
166 |
+ |
foreach $val ( $self->getfeature($f) ) { |
167 |
+ |
print $fh $self->type($f).":".$f.":".$val."\n"; |
168 |
+ |
} |
169 |
+ |
} |
170 |
+ |
undef $fh; |
171 |
+ |
} |
172 |
+ |
|
173 |
+ |
sub restore { |
174 |
+ |
my $self=shift; |
175 |
+ |
my $location=shift; |
176 |
+ |
|
177 |
+ |
my $fh=FileHandle->new(); |
178 |
+ |
$fh->open("<".$location) or die "Unable to open $location for output". |
179 |
+ |
$!."\n"; |
180 |
+ |
my ($tool,$type,$variable,$value); |
181 |
+ |
while ( <$fh> ) { |
182 |
+ |
chomp; |
183 |
+ |
next if /^#/; |
184 |
+ |
next if /^\s*$/; |
185 |
+ |
($type, $variable, $value)=split /:/; |
186 |
+ |
next if ( $variable=~/\&/ ); |
187 |
+ |
$product=~tr[A-Z][a-z]; |
188 |
+ |
if ( $type eq "_sys" ) { |
189 |
+ |
if ( can($variable)) { |
190 |
+ |
$self->$variable($value); |
191 |
+ |
} |
192 |
+ |
} |
193 |
+ |
else { |
194 |
+ |
$self->addfeature($variable,$value); |
195 |
+ |
} |
196 |
+ |
} |
197 |
+ |
undef $fh; |
198 |
+ |
} |
199 |
+ |
|
200 |
|
sub _recordpos { |
201 |
|
my $self=shift; |
202 |
|
my $name=shift; |
220 |
|
} |
221 |
|
return @rv; |
222 |
|
} |
223 |
+ |
|
224 |
+ |
|