automake-ng
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Automake-NG] [FYI 1/6] fixup: interaction between verbatim lines and li


From: Stefano Lattarini
Subject: [Automake-NG] [FYI 1/6] fixup: interaction between verbatim lines and line continuation
Date: Fri, 25 May 2012 02:16:21 +0200

When line continuations were involved, our hack to pass lines verbatim
to the output Makefile didn't work as expected; for example, the input

    !$(call foo,=, \
    !   long continued line still in the call)

produced in the generated Makefile an output like

    $(call foo,=, \
    !   long continued line still in the call)

rather than as the expected

    $(call foo,=, \
       long continued line still in the call)

That bug severely limited the usefulness of our hack.  Luckily, it's
pretty easy to fix.

* automake.in (file_contents_internal): Handling of !-escaped
lines moved ...
(make_paragraphs): ... here, and adjusted to cope with line
continuations.
* lib/am/parallel-tests.am: Break overly long !-escaped lines,
now that we can.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 automake.in              |   32 +++++++++++++++++++++-----------
 lib/am/parallel-tests.am |    8 ++++----
 2 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/automake.in b/automake.in
index d2d1551..6d5b220 100644
--- a/automake.in
+++ b/automake.in
@@ -6571,9 +6571,27 @@ sub make_paragraphs ($%)
   $transform{FIRST} = !$transformed_files{$file};
   $transformed_files{$file} = 1;
 
-  my @lines = split /(?<!\\)\n/, preprocess_file ($file, %transform);
-  my @res;
+  my @lines = split /\n/, preprocess_file ($file, %transform);
+
+  # A line starting with '!' must be passed verbatim to the output
+  # Makefile, placed after the variables' definitions and before the
+  # Makefile targets.  This is an hack to allow us to use tricky GNU
+  # make constructs (on which the dumb Automake parser would choke).
+  # It is not perfect, but seems good enough for the moment.
+  my @verbatim_lines = grep /^!/, @lines;
+  foreach (@verbatim_lines)
+    {
+      s/^!//;
+      $output_verbatim .= "$_\n";
+    }
+  @lines = grep !/^!/, @lines;
+
+  # Handle line continuations.
+  # FIXME: this could probably be done more efficiently, but I'd rather
+  # FIXME: not change working (and trickish) code for the moment.
+  @lines = split /(?<!\\)\n/, join ("\n", @lines);
 
+  my @res;
   while (defined ($_ = shift @lines))
     {
       my $paragraph = $_;
@@ -6639,16 +6657,8 @@ sub file_contents_internal ($$$%)
        # FIXME: no line number available.
        $where->set ($file);
 
-        # A line starting with '!' must be passed verbatim to the output
-        # Makefile, placed after the variables' definitions and before the
-        # Makefile targets.
-        if (s/^!//)
-          {
-            $output_verbatim .= "$_\n";
-          }
-
        # Sanity checks.
-       elsif (/\\$/)
+       if (/\\$/)
           {
            error $where, "blank line following trailing backslash:\n$_"
           }
diff --git a/lib/am/parallel-tests.am b/lib/am/parallel-tests.am
index 4f2e003..0c3e9ff 100644
--- a/lib/am/parallel-tests.am
+++ b/lib/am/parallel-tests.am
@@ -91,10 +91,10 @@ am__tpfx = \
 ## FIXME: this will pick up the default from the environment; are we sure
 ## FIXME: we want that?
 !TEST_EXTENSIONS ?= .test
-!$(call am__maybe_invalid_test_extensions,$(filter-out .%,$(TEST_EXTENSIONS)))
-## FIXME: it would be nice to break these on multiple lines.  Unfortunately,
-## FIXME: our '!' is not yet smart enough to handle that :-(
-!$(foreach am__e,$(TEST_EXTENSIONS), $(eval $(call 
am__handle_per_suffix_test,$(am__e))))
+!$(call am__maybe_invalid_test_extensions,\
+!  $(filter-out .%,$(TEST_EXTENSIONS)))
+!$(foreach am__e,$(TEST_EXTENSIONS), \
+!  $(eval $(call am__handle_per_suffix_test,$(am__e))))
 ## It is *imperative* that the "empty" suffix goes last.  Otherwise, a
 ## declaration like "TESTS = all.test" would cause GNU make to mistakenly
 ## try to build the 'all.log' and 'all.trs' files from a non-existent
-- 
1.7.9.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]