Author: jkeenan Date: Sun Aug 3 19:17:41 2008 New Revision: 29984 Added: branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/File.pm - copied, changed from r29980, /branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm Modified: branches/scriptconfigure/Configure.pl branches/scriptconfigure/MANIFEST branches/scriptconfigure/lib/Parrot/Configure/Options.pm branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm branches/scriptconfigure/lib/Parrot/Configure/Options/Test.pm
Log: [configure] First pass at file-based configuration. Code to handle that approach placed in Parrot::Configure::Options::Conf::File. 'perl Configure.pl --script=foobar' succeeds, but plays havoc with configuration and step tests for reasons still to be explored. Modified: branches/scriptconfigure/Configure.pl ============================================================================== --- branches/scriptconfigure/Configure.pl (original) +++ branches/scriptconfigure/Configure.pl Sun Aug 3 19:17:41 2008 @@ -7,6 +7,7 @@ use strict; use warnings; use lib 'lib'; +use Data::Dumper;$Data::Dumper::Indent = 1; use Parrot::Configure; use Parrot::Configure::Options qw( process_options ); @@ -34,12 +35,17 @@ # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # from Parrot::Configure::Options -my $args = process_options( +my ($args, $steps_list_ref); +($args, $steps_list_ref) = process_options( { - mode => 'configure', + mode => ($ARGV[0] =~ /^--script=/) + ? 'script' + : 'configure', argv => [EMAIL PROTECTED], } ); +print STDERR Dumper ($args, $steps_list_ref); + exit(1) unless defined $args; my $opttest = Parrot::Configure::Options::Test->new($args); @@ -58,8 +64,14 @@ my $conf = Parrot::Configure->new(); -# from Parrot::Configure::Step::List -$conf->add_steps( get_steps_list() ); +if ($args->{script}) { + delete $args->{script}; + $conf->add_steps( @{ $steps_list_ref } ); +} +else { + # from Parrot::Configure::Step::List + $conf->add_steps( get_steps_list() ); +} # from Parrot::Configure::Data $conf->options->set( %{$args} ); Modified: branches/scriptconfigure/MANIFEST ============================================================================== --- branches/scriptconfigure/MANIFEST (original) +++ branches/scriptconfigure/MANIFEST Sun Aug 3 19:17:41 2008 @@ -1,7 +1,7 @@ # ex: set ro: # $Id$ # -# generated by tools/dev/mk_manifest_and_skip.pl Fri Aug 1 22:58:18 2008 UT +# generated by tools/dev/mk_manifest_and_skip.pl Mon Aug 4 00:45:21 2008 UT # # See tools/dev/install_files.pl for documentation on the # format of this file. @@ -2691,6 +2691,8 @@ lib/Parrot/Configure/Messages.pm [devel] lib/Parrot/Configure/Options.pm [devel] lib/Parrot/Configure/Options/Conf.pm [devel] +lib/Parrot/Configure/Options/Conf/CLI.pm [devel] +lib/Parrot/Configure/Options/Conf/File.pm [devel] lib/Parrot/Configure/Options/Reconf.pm [devel] lib/Parrot/Configure/Options/Test.pm [devel] lib/Parrot/Configure/Options/Test/Prepare.pm [devel] Modified: branches/scriptconfigure/lib/Parrot/Configure/Options.pm ============================================================================== --- branches/scriptconfigure/lib/Parrot/Configure/Options.pm (original) +++ branches/scriptconfigure/lib/Parrot/Configure/Options.pm Sun Aug 3 19:17:41 2008 @@ -12,6 +12,7 @@ use Carp; use lib qw( lib ); use Parrot::Configure::Options::Conf::CLI (); +use Parrot::Configure::Options::Conf::File (); use Parrot::Configure::Options::Reconf (); sub process_options { @@ -23,6 +24,9 @@ if ( $argsref->{mode} =~ m/^reconfigure$/i ) { %options_components = %Parrot::Configure::Options::Reconf::options_components; } + elsif ( $argsref->{mode} =~ m/^script$/i ) { + %options_components = %Parrot::Configure::Options::Conf::File::options_components; + } elsif ( $argsref->{mode} =~ m/^configure$/i ) { %options_components = %Parrot::Configure::Options::Conf::CLI::options_components; } @@ -64,10 +68,13 @@ return; } else { - $data = &{ $options_components{conditionals} }($data); - return $data; + my $steps_list_ref; + ($data, $steps_list_ref) = + &{ $options_components{conditionals} }($data); + return ($data, $steps_list_ref); } } + 1; #################### DOCUMENTATION #################### Modified: branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm ============================================================================== --- branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm (original) +++ branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm Sun Aug 3 19:17:41 2008 @@ -13,7 +13,6 @@ $svnid ); use lib qw( lib ); -#use Parrot::BuildUtil (); use Parrot::Configure::Options::Conf qw( $script $parrot_version Copied: branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/File.pm (from r29980, /branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm) ============================================================================== --- /branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/CLI.pm (original) +++ branches/scriptconfigure/lib/Parrot/Configure/Options/Conf/File.pm Sun Aug 3 19:17:41 2008 @@ -1,9 +1,10 @@ # Copyright (C) 2007-2008, The Perl Foundation. # $Id$ -package Parrot::Configure::Options::Conf::CLI; +package Parrot::Configure::Options::Conf::File; use strict; use warnings; +use Data::Dumper;$Data::Dumper::Indent = 1; use base qw( Exporter ); our @EXPORT_OK = qw( @valid_options @@ -13,7 +14,6 @@ $svnid ); use lib qw( lib ); -#use Parrot::BuildUtil (); use Parrot::Configure::Options::Conf qw( $script $parrot_version @@ -23,73 +23,10 @@ ); our @valid_options = qw{ - ask - bindir - cage - cc - ccflags - ccwarn - cgoto - configure_trace - cxx - datadir - debugging - define - exec-prefix - execcapable - fatal - fatal-step - floatval - gc help - icu-config - icuheaders - icushared - includedir - infodir - inline - intval - jitcapable - languages - ld - ldflags - lex - libdir - libexecdir - libs - link - linkflags - localstatedir - m - make - maintainer - mandir - miniparrot - nomanicheck - oldincludedir - opcode - ops - optimize - parrot_is_shared - pmc - prefix - profile - sbindir - sharedstatedir - silent - sysconfdir + script test - verbose - verbose-step version - without-gdbm - without-opengl - without-pcre - without-crypto - without-gettext - without-gmp - without-icu - yacc }; my %short_circuits = ( @@ -105,15 +42,65 @@ ); sub conditional_assignments { - my $argsref = shift; - $argsref->{debugging} = 1 - unless ( ( exists $argsref->{debugging} ) && !$argsref->{debugging} ); - $argsref->{maintainer} = 1 - if defined $argsref->{lex} - or defined $argsref->{yacc}; - return $argsref; + my $data = shift; + $data->{debugging} = 1; + $data->{maintainer} = undef; +#print STDERR $data->{script}, "\n"; + open my $IN, '<', $data->{script} + or die "Unable to open configuration data file $data->{script} for reading: $!"; + my @steps_list = (); + LINE: while ( my $line = <$IN> ) { + chomp $line; + next if $line =~ /^(\s*$|#)/o; + if ($line =~ /^(\w+::\w+)(?:\s+(\S+\s+)*(\S+))?$/) { +#print STDERR "$line\n"; + my $step = $1; + push @steps_list, $step; + next LINE unless $3; + my $opts_string = $2 ? qq{$2$3} : $3; +#print STDERR "$opts_string\n"; + my @opts = split /\s+/, $opts_string; +#print STDERR Dumper [EMAIL PROTECTED]; + foreach my $el (@opts) { + my ( $key, $value ); + if ($el =~ m/([-\w]+)(?:=(.*))?/) { + ( $key, $value ) = ($1, $2); + } + if (! defined $key) { + die "Unable to process key $key in step $step in configuration data file $data->{script}: $!" + } + # We'll have to check here for valid options, which now more + # closely resemble those in Conf::CLI. +# unless ( $valid_opts{$key} ) { +# die qq/Invalid option "$key". See "perl $script --help" for valid options\n/; +# } + $value = 1 unless defined $value; + $data->{$key} = $value; + } + } + } + close $IN + or die "Unable to close configuration data file $data->{script} after reading: $!"; + return ($data, [EMAIL PROTECTED]);; } +# for my $el ( @{ $argsref->{argv} } ) { +# my ( $key, $value ); +# if ($el =~ m/--([-\w]+)(?:=(.*))?/) { +# ( $key, $value ) = ($1, $2); +# } +# $key = 'help' unless defined $key; +# $value = 1 unless defined $value; +# +# unless ( $valid_opts{$key} ) { +# die qq/Invalid option "$key". See "perl $script --help" for valid options\n/; +# } +# if ( $options_components{short_circuits}{$key} ) { +# push @short_circuits_seen, $key; +# } +# $data->{$key} = $value; +# } + 1; # Local Variables: Modified: branches/scriptconfigure/lib/Parrot/Configure/Options/Test.pm ============================================================================== --- branches/scriptconfigure/lib/Parrot/Configure/Options/Test.pm (original) +++ branches/scriptconfigure/lib/Parrot/Configure/Options/Test.pm Sun Aug 3 19:17:41 2008 @@ -35,6 +35,7 @@ fatal fatal-step help + script silent verbose verbose-step