[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Automake-NG] [PATCH 08/15] [ng] vars: simplify logic for appending cond
From: |
Stefano Lattarini |
Subject: |
[Automake-NG] [PATCH 08/15] [ng] vars: simplify logic for appending conditionally |
Date: |
Fri, 25 May 2012 13:38:30 +0200 |
This will make the generated Makefiles more bloated, but that's OK,
since further refactorings will change the format used to output
conditional variables extending, and the resulting Makefiles will
once again be smaller (and quite cleaner).
* lib/Automake/Variable.pm (define): When appending to an existing
variable, don't bother to avoid the creation of intermediate
internal variables when that's not really needed; just create them
unconditionally.
(_new): Don't reset $self->{'last-append'} anymore, it has been
removed (it was only used in the 'define' function).
Signed-off-by: Stefano Lattarini <address@hidden>
---
lib/Automake/Variable.pm | 63 ++++++++--------------------------------------
t/cond38.sh | 3 ---
2 files changed, 10 insertions(+), 56 deletions(-)
diff --git a/lib/Automake/Variable.pm b/lib/Automake/Variable.pm
index 1e227c3..0c83b66 100644
--- a/lib/Automake/Variable.pm
+++ b/lib/Automake/Variable.pm
@@ -423,7 +423,6 @@ sub _new ($$)
my ($class, $name) = @_;
my $self = Automake::Item::new ($class, $name);
$self->{'scanned'} = 0;
- $self->{'last-append'} = []; # helper variable for last conditional append.
$_variable_dict{$name} = $self;
if ($name =~ /_([[:alnum:]]+)$/)
{
@@ -799,8 +798,6 @@ sub define ($$$$$$$$)
if ($type eq '+' && ! $new_var)
{
$def->append ($value, $comment);
- $self->{'last-append'} = [];
-
# Only increase owners. A VAR_CONFIGURE variable augmented in a
# Makefile.am becomes a VAR_MAKEFILE variable.
$def->set_owner ($owner, $where->clone)
@@ -809,63 +806,24 @@ sub define ($$$$$$$$)
# 2. append (+=) to a variable defined for *another* condition
elsif ($type eq '+' && ! $self->conditions->false)
{
- # * Generally, $cond is not TRUE. For instance:
+ # * If we have an input like:
# FOO = foo
# if COND
# FOO += bar
# endif
- # In this case, we declare an helper variable conditionally,
- # and append it to FOO:
+ # we declare an helper variable conditionally, and append
+ # it to FOO:
# FOO = foo $(am__append_1)
# @address@hidden = bar
# Of course if FOO is defined under several conditions, we add
# $(am__append_1) to each definitions.
- #
- # * If $cond is TRUE, we don't need the helper variable. E.g., in
- # if COND1
- # FOO = foo1
- # else
- # FOO = foo2
- # endif
- # FOO += bar
- # we can add bar directly to all definition of FOO, and output
- # @address@hidden = foo1 bar
- # @address@hidden = foo2 bar
-
- my $lastappend = [];
- # Do we need an helper variable?
- if ($cond != TRUE)
- {
- # Can we reuse the helper variable created for the previous
- # append? (We cannot reuse older helper variables because
- # we must preserve the order of items appended to the
- # variable.)
- my $condstr = $cond->string;
- my $key = "$var:$condstr";
- my ($appendvar, $appendvarcond) = @{$self->{'last-append'}};
- if ($appendvar && $condstr eq $appendvarcond)
- {
- # Yes, let's simply append to it.
- $var = $appendvar;
- $owner = VAR_AUTOMAKE;
- $self = var ($var);
- $def = $self->rdef ($cond);
- $new_var = 0;
- }
- else
- {
- # No, create it.
- my $num = ++$_appendvar;
- my $hvar = "am__append_$num";
- $lastappend = [$hvar, $condstr];
- &define ($hvar, VAR_AUTOMAKE, '+',
- $cond, $value, $comment, $where, $pretty);
-
- # Now HVAR is to be added to VAR.
- $comment = '';
- $value = "\$($hvar)";
- }
- }
+ my $num = ++$_appendvar;
+ my $hvar = "am__append_$num";
+ &define ($hvar, VAR_AUTOMAKE, '+',
+ $cond, $value, $comment, $where, $pretty);
+ # Now HVAR is to be added to VAR.
+ $comment = '';
+ $value = "\$($hvar)";
# Add VALUE to all definitions of SELF.
foreach my $vcond ($self->conditions->conds)
@@ -895,7 +853,6 @@ sub define ($$$$$$$$)
$where, $pretty);
}
}
- $self->{'last-append'} = $lastappend;
}
# 3. first assignment (=, :=, or +=)
else
diff --git a/t/cond38.sh b/t/cond38.sh
index 71ae69a..e63d8d1 100755
--- a/t/cond38.sh
+++ b/t/cond38.sh
@@ -59,9 +59,6 @@ $AUTOCONF
$AUTOMAKE
./configure
-# Make sure no extra variable was created for the last 3 items.
-grep 'append.*=.* h iXYZ jZYX' Makefile
-# Check good ordering.
$MAKE test
:
--
1.7.9.5
- Re: [Automake-NG] [PATCH 02/15] [ng] vars: get rid of VAR_SORTED type, (continued)
[Automake-NG] [PATCH 07/15] [ng] VarDef: store comments and values as a perl array, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 03/15] [ng] vars: get rid of VAR_SILENT type, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 08/15] [ng] vars: simplify logic for appending conditionally,
Stefano Lattarini <=
[Automake-NG] [PATCH 06/15] [ng] refactor: support comments only for VarDef, not for ItemDef too, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 09/15] [ng] vars: keep track of conditionals in appended values and comments, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 11/15] [ng] refactor: change signature of 'define_variable()', Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 13/15] [ng] rename: define_pretty_variable -> define_cond_variable(), Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 10/15] [ng] vars: get rid of VAR_ASIS / VAR_PRETTY distinction, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 15/15] [ng] vars: remove some safety checks in Automake::Variable::define, Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 12/15] [ng] cleanup: prefer 'define_variable' over 'define_pretty_variable', Stefano Lattarini, 2012/05/25
[Automake-NG] [PATCH 14/15] [ng] cosmetics: avoid redundant use of '&' in subroutine calls, Stefano Lattarini, 2012/05/25