Skip to content

Commit

Permalink
Implement flex and bison version tests in a way that doesn't break the
Browse files Browse the repository at this point in the history
symmetry with other config modules.  Also, allow user to override the
required versions, in case he wishes to experiment.


git-svn-id: https://svn.parrot.org/parrot/trunk@14318 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
Chip Salzenberg committed Aug 22, 2006
1 parent 75b4faa commit 72c5788
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 33 deletions.
15 changes: 10 additions & 5 deletions Configure.pl
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,18 @@ =head2 Command-line Options
Specify which lexer to use.
=item C<--flex_required=X.Y.Z>
Override the minimum acceptable flex version.
=item C<--yacc=(parser)>
Specify which parser to use.
=item C<--bison_required=X.Y>
Override the minimum acceptable bison version.
=item C<--define=val1[,val2]>
Generate "#define PARROT_DEF_VAL1 1" ... entries in has_header.h. Currently
Expand Down Expand Up @@ -430,8 +438,8 @@ END
init::headers
inter::progs
inter::make
);
my @steps2 = qw(
inter::lex
inter::yacc
auto::gcc
auto::msvc
init::optimize
Expand Down Expand Up @@ -488,9 +496,6 @@ END
$Parrot::Configure::Step::conf = $conf;
}
$conf->add_steps(@steps);
$conf->add_step('inter::lex', require => '2.5.33');
$conf->add_step('inter::yacc', require => '2.1');
$conf->add_steps(@steps2);
$conf->options->set(%args);
# Run the actual steps
$conf->runsteps or exit(1);
Expand Down
38 changes: 21 additions & 17 deletions config/inter/lex.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ config/auto/lex.pm - lexical analyzer generator
=head1 DESCRIPTION
Determines whether C<lex> is installed and if it's actually C<flex>.
Determines whether C<lex> is installed and if it's actually C<flex> of
least the user-specified minimum version, defaulting to 2.5.33.
=cut

Expand All @@ -26,9 +27,11 @@ $description = "Determining whether $util is installed";
$prompt = "Do you have a lexical analyzer generator like flex or lex?";
@args = qw( lex ask maintainer );

my $default_required = '2.5.33';

sub runstep
{
my ($self, $conf, %p) = @_;
my ($self, $conf) = @_;

my $verbose = $conf->options->get('verbose');

Expand Down Expand Up @@ -87,33 +90,34 @@ sub runstep
my $prog_version = "$1.$2.$3";

# is there a version requirement?
if (exists $p{require}) {
my ($rmajor, $rminor, $rpatch) =
$p{require} =~ /(\d+) \. (\d+) \. (\d+)/x;
unless ((defined $rmajor)
and (defined $rminor)
and (defined $rpatch)) {
$self->set_result("could not understand version requirement");
my $req = $conf->options->get('flex_required');
unless (defined $req) {
$req = $default_required;
}
if ($req) {
my ($rmajor, $rminor, $rpatch) = ($req =~ / ^ (\d+) \. (\d+) \. (\d+) $ /x);
unless (defined $rmajor) {
$self->set_result("could not understand flex version requirement");
return;
}

unless (
$prog_major >= $rmajor
$prog_major >= $rmajor

or ( $prog_major == $rmajor
and $prog_minor >= $rminor )
or ( $prog_major == $rmajor
and $prog_minor >= $rminor )

or ( $prog_major == $rmajor
and $prog_minor == $rminor
and $prog_patch >= $rpatch )
) {
or ( $prog_major == $rmajor
and $prog_minor == $rminor
and $prog_patch >= $rpatch )
) {
$self->set_result("found flex version $prog_version"
. " but at least $rmajor.$rminor.$rpatch is required");
return;
}
}

$conf->data->set(prog_version => $prog_version);
$conf->data->set(flex_version => $prog_version);
$self->set_result("flex $prog_version");
$conf->data->set($util => $prog);
} else {
Expand Down
29 changes: 18 additions & 11 deletions config/inter/yacc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ config/auto/yacc.pm - parser generator
=head1 DESCRIPTION
Determines whether C<yacc> is installed and if it's actually C<bison>.
Determines whether C<yacc> is installed and if it's actually C<bison> of at
least the user-specified minimum version, defaulting to 2.1.
=cut

Expand All @@ -26,10 +27,12 @@ $description = "Determining whether $util is installed";
$prompt = "Do you have a parser generator, like bison or yacc?";
@args = qw( yacc ask maintainer );

my $default_required = '2.1';

sub runstep
{
my ($self, $conf, %p) = @_;
my ($self, $conf) = @_;

my $verbose = $conf->options->get('verbose');

# undef means we don't have bison... default to not having bison
Expand Down Expand Up @@ -87,19 +90,23 @@ sub runstep
my $prog_version = "$1.$2$3";

# is there a version requirement?
if (exists $p{require}) {
my ($rmajor, $rminor) = $p{require} =~ /(\d+) \. (\d+) (\w)?/x;
unless ((defined $rmajor) and (defined $rminor)) {
$self->set_result("could not understand version requirement");
my $req = $conf->options->get('bison_required');
unless (defined $req) {
$req = $default_required;
}
if ($req) {
my ($rmajor, $rminor) = ($req =~ / ^ (\d+) \. (\d+) (\w)? $ /x);
unless (defined $rmajor) {
$self->set_result("could not understand bison version requirement");
return;
}

unless (
$prog_major >= $rmajor
$prog_major >= $rmajor

or ( $prog_major == $rmajor
and $prog_minor >= $rminor )
) {
or ( $prog_major == $rmajor
and $prog_minor >= $rminor )
) {
$self->set_result("found bison version $prog_version"
. " but at least $rmajor.$rminor is required");
return;
Expand Down

0 comments on commit 72c5788

Please sign in to comment.