# New Ticket Created by  Kevin Tew 
# Please include the string:  [perl #39808]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=39808 >


example:

perl Configure --step=gen::languages


 Configure.pl                 |   12 +++
 lib/Parrot/Configure.pm      |  135 
+++++++++++++++++++++++++++----------------
 lib/Parrot/Configure/Data.pm |   20 ++++++
 3 files changed, 116 insertions(+), 51 deletions(-)

Index: lib/Parrot/Configure/Data.pm
===================================================================
--- lib/Parrot/Configure/Data.pm        (revision 13269)
+++ lib/Parrot/Configure/Data.pm        (working copy)
@@ -171,6 +171,26 @@
     return keys %{$self->{c}};
 }
 
+=item C<slurp()>
+
+Slurps in Parrot::Config data from previous configure.
+
+Accepts no arguments.
+
+=cut
+
+sub slurp()
+{
+  my $self = shift;
+  
+  my $res = eval {
+    use Parrot::Config;
+    \%PConfig
+  };
+
+  $self->{c} = $res;
+}
+
 =item C<dump()>
 
 Provides a L<Data::Dumper> serialized string of the objects key/value pairs
Index: lib/Parrot/Configure.pm
===================================================================
--- lib/Parrot/Configure.pm     (revision 13269)
+++ lib/Parrot/Configure.pm     (working copy)
@@ -197,74 +197,111 @@
 
     my $n = 0; # step number
     foreach my $task ($self->steps) {
-        my $step_name   = $task->step;
-        my @step_params = @{$task->params};
-
         $n++;
+        $self->_runstep($task, $verbose_step, $ask, $n);
+    }
+    return $self;
+}
 
-        eval "use $step_name;";
-        die $@ if $@;
+=item * C<runstep()>
 
-        my $step = $step_name->new;
+The invoking
+L<Parrot::Configure> object is passed as the first argument to each steps
+C<runstep()> method followed by any parameters that were registered for that
+step.
 
-        # XXX This works. but is probably not a good design.
-        # Using $step->description() would be nicer   
-        my $description = $step->description();
-        $description = "" unless defined $description;
+Accepts no arguments and returns a L<Parrot::Configure> object.
 
-        # set per step verbosity
-        if (defined $verbose_step) {
+=cut
 
-            # by step number
-            if ($verbose_step =~ /^\d+$/ && $n == $verbose_step) {
-                $self->options->set(verbose => 2);
-            }
 
-            # by description
-            elsif ($description =~ /$verbose_step/) {
-                $self->options->set(verbose => 2);
-            }
+sub runstep
+{
+    my $self = shift;
+    my $taskname = shift;
+
+    my ($verbose, $verbose_step, $ask) =
+    $self->options->get(qw(verbose verbose-step ask));
+
+    for my $task ($self->steps()) {
+        if ( $task->{"Parrot::Configure::Task::step"} eq $taskname ) {
+            print "$taskname\n";
+            $self->_runstep($task, $verbose, $verbose_step, $ask, 1);
         }
+    }
+}
 
-        # XXX cc_build uses this verbose setting, why?
-        $self->data->set(verbose => $verbose) if $n > 2;
+sub _runstep
+{
+    my $self = shift;
+    my $task = shift;
 
-        print "\n", $description, '...';
-        print "\n" if $verbose && $verbose == 2;
+    my ($verbose, $verbose_step, $ask, $n) = @_;
 
-        my $ret; # step return value
-        eval {
-            if (@step_params) {
-                $ret = $step->runstep($self, @step_params);
-            } else {
-                $ret = $step->runstep($self);
-            }
-        };
-        if ($@) {
-            carp "\nstep $step_name died during execution: [EMAIL PROTECTED]";
-            return;
+    my $step_name   = $task->step;
+    my @step_params = @{$task->params};
+
+
+    eval "use $step_name;";
+    die $@ if $@;
+
+    my $step = $step_name->new;
+
+    # XXX This works. but is probably not a good design.
+    # Using $step->description() would be nicer   
+    my $description = $step->description();
+    $description = "" unless defined $description;
+
+    # set per step verbosity
+    if (defined $verbose_step) {
+
+        # by step number
+        if ($verbose_step =~ /^\d+$/ && $n == $verbose_step) {
+            $self->options->set(verbose => 2);
         }
 
-        # did the step return itself?
-        eval { $ret->can('result'); };
-        # if not, report the result and return
-        if ($@) {
-            my $result = $step->result || 'no result returned';
-            carp "\nstep $step_name failed: " . $result;
-            return;
+        # by description
+        elsif ($description =~ /$verbose_step/) {
+            $self->options->set(verbose => 2);
         }
+    }
 
-        my $result = $step->result || 'done';
+    # XXX cc_build uses this verbose setting, why?
+    $self->data->set(verbose => $verbose) if $n > 2;
 
-        print "..." if $verbose && $verbose == 2;
-        print "." x (71 - length($description) - length($result));
-        print "$result." unless $step =~ m{^inter/} && $ask;
+    print "\n", $description, '...';
+    print "\n" if $verbose && $verbose == 2;
 
-        # reset verbose value for the next step
-        $self->options->set(verbose => $verbose);
+    my $ret; # step return value
+    eval {
+        if (@step_params) {
+            $ret = $step->runstep($self, @step_params);
+        } else {
+            $ret = $step->runstep($self);
+        }
+    };
+    if ($@) {
+        carp "\nstep $step_name died during execution: [EMAIL PROTECTED]";
+        return;
     }
 
-    return $self;
+    # did the step return itself?
+    eval { $ret->can('result'); };
+    # if not, report the result and return
+    if ($@) {
+        my $result = $step->result || 'no result returned';
+        carp "\nstep $step_name failed: " . $result;
+        return;
+    }
+
+    my $result = $step->result || 'done';
+
+    print "..." if $verbose && $verbose == 2;
+    print "." x (71 - length($description) - length($result));
+    print "$result." unless $step =~ m{^inter/} && $ask;
+
+    # reset verbose value for the next step
+    $self->options->set(verbose => $verbose);
 }
 
 =back
Index: Configure.pl
===================================================================
--- Configure.pl        (revision 13269)
+++ Configure.pl        (working copy)
@@ -440,9 +445,17 @@
 }
 $conf->add_steps(@steps);
 $conf->options->set(%args);
-# Run the actual steps
-$conf->runsteps or exit(1);
 
+if ( exists $args{step} ) {
+  $conf->data()->slurp();
+  $conf->runstep($args{step});
+  exit(0);
+}
+else {
+  # Run the actual steps
+  $conf->runsteps or exit(1);
+}
+
 # tell users what to do next
 my $make = $conf->data->get('make');
 

Reply via email to