[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] {master} automake: refactor pre-processing of makefile fragments
From: |
Stefano Lattarini |
Subject: |
[PATCH] {master} automake: refactor pre-processing of makefile fragments |
Date: |
Thu, 19 Apr 2012 22:14:30 +0200 |
This change will provide the automake script with a new function that
reads in a Makefile fragment *without* performing Automake ad-hoc parsing,
but only the pre-processing step, i.e., removal of '##' comments and
substitution of tokens like '%SUBDIRS%', '%?LIBTOOL%' or '?GENENRIC?'.
This will very likely be useful for the work on Automake-NG.
This is a pure refactoring, with no intended functional or semantic
changes.
* automake.in (preprocess_file): New function, extracted ...
(make_paragraphs): ... from here.
Signed-off-by: Stefano Lattarini <address@hidden>
---
The testsuite still passes. I plan to push this change by tomorrow if
there are no objections.
Regards,
Stefano
automake.in | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/automake.in b/automake.in
index 38e09dc..43a7ba6 100644
--- a/automake.in
+++ b/automake.in
@@ -6938,13 +6938,13 @@ sub transform ($$)
}
}
-
-# @PARAGRAPHS
-# &make_paragraphs ($MAKEFILE, [%TRANSFORM])
-# ------------------------------------------
-# Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
-# paragraphs.
-sub make_paragraphs ($%)
+# $TEXT
+# preprocess_file ($MAKEFILE, [%TRANSFORM])
+# -----------------------------------------
+# Load a $MAKEFILE, apply the %TRANSFORM, and return the result.
+# No extra parsing of post-processing is done (i.e., recognition of
+# rules declaration or of make variables definitions).
+sub preprocess_file ($%)
{
my ($file, %transform) = @_;
@@ -6977,13 +6977,9 @@ sub make_paragraphs ($%)
'LIBTOOL' => !! var ('LIBTOOL'),
'NONLIBTOOL' => 1,
- 'FIRST' => ! $transformed_files{$file},
%transform);
- $transformed_files{$file} = 1;
- $_ = $am_file_cache{$file};
-
- if (! defined $_)
+ if (! defined ($_ = $am_file_cache{$file}))
{
verb "reading $file";
# Swallow the whole file.
@@ -6993,11 +6989,10 @@ sub make_paragraphs ($%)
$_ = $fc_file->getline;
$/ = $saved_dollar_slash;
$fc_file->close;
-
# Remove ##-comments.
# Besides we don't need more than two consecutive new-lines.
s/(?:$IGNORE_PATTERN|(?<=\n\n)\n+)//gom;
-
+ # Remember the contents of the just-read file.
$am_file_cache{$file} = $_;
}
@@ -7011,8 +7006,22 @@ sub make_paragraphs ($%)
# ####### and do not remove the latter.)
s/^[ \t]*(?:##%)+.*\n//gm;
- # Split at unescaped new lines.
- my @lines = split (/(?<!\\)\n/, $_);
+ return $_;
+}
+
+
+# @PARAGRAPHS
+# &make_paragraphs ($MAKEFILE, [%TRANSFORM])
+# ------------------------------------------
+# Load a $MAKEFILE, apply the %TRANSFORM, and return it as a list of
+# paragraphs.
+sub make_paragraphs ($%)
+{
+ my ($file, %transform) = @_;
+ $transform{FIRST} = !$transformed_files{$file};
+ $transformed_files{$file} = 1;
+
+ my @lines = split /(?<!\\)\n/, preprocess_file ($file, %transform);
my @res;
while (defined ($_ = shift @lines))
--
1.7.9.5
- [PATCH] {master} automake: refactor pre-processing of makefile fragments,
Stefano Lattarini <=