Permalink
Browse files

more config system add ons and docs

git-svn-id: https://svn.parrot.org/parrot/trunk@5924 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent 567c2b1 commit c9264be3e754f7e6386c98a8d1b55077b2490d28 Leopold Toetsch committed Apr 26, 2004
Showing with 83 additions and 32 deletions.
  1. +6 −1 Configure.pl
  2. +4 −12 config/gen/cpu/i386/auto.pl
  3. +63 −16 config/init/data.pl
  4. +10 −3 docs/configuration.pod
View
@@ -213,7 +213,7 @@ =head2 Command-line Options
=back
-Other Options (may not be implemented)
+Other Options
=over
@@ -233,6 +233,11 @@ =head2 Command-line Options
=back
+=head1 SEE ALSO
+
+F<config/init/data.pl>, F<lib/Parrot/Configure/RunSteps.pm>,
+F<lib/Parrot/Configure/Step.pm>, F<docs/configuration.pod>
+
=cut
use 5.005_02;
@@ -4,7 +4,7 @@
=head1 NAME
-config/gen/cpu/i386/auto-pl
+config/gen/cpu/i386/auto.pl
=head1 DESCRIPTION
@@ -31,17 +31,9 @@ sub run_cpu {
if (cc_run() =~ /ok/) {
Configure::Data->set('i386_has_mmx' => '1');
print " (MMX) " if ($verbose);
- my $old = Configure::Data->get("TEMP_generated");
- if (defined $old) {
- Configure::Data->set(
- "TEMP_generated" => "$old $f"
- );
- }
- else {
- Configure::Data->set(
- "TEMP_generated" => "$f"
- );
- }
+ Configure::Data->add(',',
+ "TEMP_generated" => $f
+ );
}
}
cc_clean();
View
@@ -10,6 +10,10 @@ =head1 DESCRIPTION
Sets up the configuration system's default values and data structures.
+=head1 METHODS
+
+=over 4
+
=cut
package Configure::Step;
@@ -126,47 +130,90 @@ sub runstep {
$c{ld_debug} .= " -pg ";
}
+=item Configure::Data->get($key,...)
+
+Return value or hash slice for key.
+
+=cut
*get=sub {
shift;
@c{@_};
};
- *set=defined($verbose) && $verbose == 2
- ? sub {
+=item Configure::Data->set($key,$val, ...)
+
+Set config values
+
+=cut
+
+ *set = sub {
shift;
+ my $verbose = $c{verbose} && $c{verbose} == 2;
return unless (defined ($_[0]));
- print "Setting Configuration Data:\n(\n";
+ print "Setting Configuration Data:\n(\n" if ($verbose);
while (my ($key, $val) = splice @_, 0, 2) {
- print "\t$key => ", defined($val) ? "'$val'" : 'undef', ",\n";
+ print "\t$key => ", defined($val) ? "'$val'" : 'undef', ",\n"
+ if ($verbose);
$c{$key}=$val;
}
- print ");\n"
- }
- : sub {
- shift;
- %c=(%c, @_);
+ print ");\n" if ($verbose);
};
+=item Configure::Data->add($delim, $key,$val, ...)
+
+Append values delimited by C<$delim> to existing keys or set values.
+
+=cut
+
+ *add = sub {
+ my ($self, $delim) = (shift, shift);
+ while (my ($key, $val) = splice @_, 0, 2) {
+ my ($old) = $c{$key};
+ if (defined $old) {
+ $self->set($key, "$old$delim$val");
+ }
+ else {
+ $self->set($key, $val);
+ }
+ }
+ };
+
+=item Configure::Data->keys()
+
+Return config keys.
+
+=cut
+
*keys=sub {
return keys %c;
};
+=item Configure::Data->dump()
+
+Dump config keys.
+
+=cut
+
*dump=sub {
Data::Dumper->Dump([\%c], ['*PConfig']);
};
-
- *clean=sub {
- delete $c{$_} for grep { /^TEMP_/ } keys %c;
- };
-}
-
-1;
+=item Configure::Data->clean()
+Delete keys matching /^TEMP_/ from config. These are used only temporarly
+e.g. as file lists for Makefile generation.
+=cut
+ *clean=sub {
+ delete $c{$_} for grep { /^TEMP_/ } keys %c;
+ };
+}
+=back
+=cut
+1;
@@ -13,7 +13,7 @@ be mostly of a single type, though some overlap is allowed (for example,
allowing a probe to ask the user what to do in an exceptional
situation).
-The directory F<config> contains subdirectories for each type of step.
+The directory F<config> contains subdirectories for each type of step.
Each step should consist of I<exactly one> .pl file and any number of
supporting .c, .in, etc. files. Any supporting files should be in a
folder whose name is the same as the basename of the step's .pl file;
@@ -169,7 +169,7 @@ A template for a new step might look like this:
=head2 Command-line Arguments
-Command-line arguments look like C</--\w+(=.*)?/>; the equals sign
+Command-line arguments look like C</--[-\w]+(=.*)?/>; the equals sign
separates the name and the value. If the value is omitted, it's assumed
to be 1. The options C<--help> and C<--version> are built in to
Configure; any others are defined by steps.
@@ -192,10 +192,15 @@ by calling methods on this package. The methods are listed below.
Returns the values for the given keys.
-=item C<< Configure::Data->set(key, value, key, value, ...) >>
+=item C<< Configure::Data->set(key, value, [key, value, ...]) >>
Sets the given keys to the given values.
+=item C<< Configure::Data->add(delim, key, value, [key, value, ...]) >>
+
+Sets the given keys to the given values or appends values delimited by
+I<delim> to existing keys.
+
=item C<< Configure::Data->keys() >>
Returns a list of all keys.
@@ -215,6 +220,8 @@ the configuration system's data.
=item L<Parrot::Configure::Step>
+=item F<config/init/data.pl>
+
=back
=head1 HISTORY

0 comments on commit c9264be

Please sign in to comment.