Hi Bruno,

I've attached two patches. The first one fixes an item in the
gnulib-tool.py.TODO file. Previously the "Generated by gnulib-tool"
comment at the top of the Makefile would be on one line. This splits
it into multiple lines so that it can be used with git send-email and
versions of AWK with line length limits. I again used the Emacs
merge-gnulib script and diffed the two Makefiles until they were the
same. This required reordering a few of the options and such. The
regular gnulib-tool prints a few more options that are not yet
implemented by gnulib-tool.py. I've left a comment with a FIXME tag
with them ordered properly.

On 2/23/24 3:51 PM, Bruno Haible wrote:
> I.e. you meant to write
>   mode != None
> not
>   modules != None
> ?

The second fixes this typo. Thanks for noticing it. Who knows how
long it would have taken to cause an exception otherwise... I made
sure to give you credit in the ChangeLog entry.

Thanks,
Collin
From 52abea086e7c33723e255202a121d555a41b652d Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Fri, 23 Feb 2024 20:52:15 -0800
Subject: [PATCH 1/2] gnulib-tool.py: Follow gnulib-tool changes, part 28.

Follow gnulib-tool change
2018-07-17  Paul Eggert  <egg...@cs.ucla.edu>
gnulib-tool: limit line length for git send-email

* pygnulib/GLImport.py (GLImport.actioncmd): Break actioncmd into
multiple lines. Reorder emitting of arguments to match gnulib-tool. Emit
"--witness-c-macro" instead of "--witness_c_macro". Emit "--po-domain"
instead of "--podomain". Document ordering of unimplemented options. Add
updated comments documenting line length limitations of git send-email
and some implementations of AWK.
* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Remove comment which
was moved to pygnulib/GLImport.py. Remove length limitation on actioncmd
since it now spans multiple lines.
---
 ChangeLog            | 16 +++++++++
 gnulib-tool.py.TODO  | 11 ------
 pygnulib/GLEmiter.py |  8 +----
 pygnulib/GLImport.py | 82 +++++++++++++++++++++++++-------------------
 4 files changed, 63 insertions(+), 54 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1900d90186..e439ce6389 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2024-02-23  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Follow gnulib-tool changes, part 28.
+	Follow gnulib-tool change
+	2018-07-17  Paul Eggert  <egg...@cs.ucla.edu>
+	gnulib-tool: limit line length for git send-email
+	* pygnulib/GLImport.py (GLImport.actioncmd): Break actioncmd into
+	multiple lines. Reorder emitting of arguments to match gnulib-tool. Emit
+	"--witness-c-macro" instead of "--witness_c_macro". Emit "--po-domain"
+	instead of "--podomain". Document ordering of unimplemented options. Add
+	updated comments documenting line length limitations of git send-email
+	and some implementations of AWK.
+	* pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): Remove comment which
+	was moved to pygnulib/GLImport.py. Remove length limitation on actioncmd
+	since it now spans multiple lines.
+
 2024-02-23  Bruno Haible  <br...@clisp.org>
 
 	DEPENDENCIES: Update entry about gperf.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 3313839a32..c72746941e 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -779,17 +779,6 @@ Date:   Mon Sep 3 21:19:16 2018 +0200
 
 --------------------------------------------------------------------------------
 
-commit a1276e5bf2286afec7b0445040be05cad858cdd1
-Author: Paul Eggert <egg...@cs.ucla.edu>
-Date:   Tue Jul 17 15:20:39 2018 -0700
-
-    gnulib-tool: limit line length for git send-email
-
-    * gnulib-tool (func_import): Break actioncmd log line
-    into multiple lines.
-
---------------------------------------------------------------------------------
-
 commit 589e96475f8f2d21a83405ab0672ce95091b80e5
 Author: Bruno Haible <br...@clisp.org>
 Date:   Fri Dec 29 00:29:23 2017 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 6de9aba68a..56e8156761 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -668,13 +668,7 @@ AC_DEFUN([%V1%_LIBSOURCES], [
             emit += "## Process this file with automake to produce Makefile.in.\n"
         emit += self.copyright_notice()
         if actioncmd:
-            # The maximum line length (excluding the terminating newline) of
-            # any file that is to be preprocessed by config.status is 3070.
-            # config.status uses awk, and the HP-UX 11.00 awk fails if a line
-            # has length >= 3071; similarly, the IRIX 6.5 awk fails if a line
-            # has length >= 3072.
-            if len(actioncmd) <= 3000:
-                emit += "# Reproduce by: %s\n" % actioncmd
+            emit += "# Reproduce by:\n%s\n" % actioncmd
         emit += '\n'
         uses_subdirs = False
 
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index e01cb9f63e..c69a33deb7 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -374,63 +374,73 @@ class GLImport(object):
         vc_files = self.config.checkVCFiles()
         verbose = self.config.getVerbosity()
 
-        # Create command-line invocation comment.
-        actioncmd = 'gnulib-tool --import'
-        actioncmd += ' --dir=%s' % destdir
-        for localdir in localpath:
-            actioncmd += ' --local-dir=%s' % localdir
-        actioncmd += ' --lib=%s' % libname
-        actioncmd += ' --source-base=%s' % sourcebase
-        actioncmd += ' --m4-base=%s' % m4base
+        # Command-line invocation printed in a comment in generated gnulib-cache.m4.
+        actioncmd = '# gnulib-tool --import'
+
+        # Break the action command log into multiple lines.
+        # Emacs puts some gnulib-tool log lines in its source repository, and
+        # git send-email rejects patch lines longer than 998 characters.
+        # Also, config.status uses awk, and the HP-UX 11.00 awk fails if a
+        # line has length >= 3071; similarly, the IRIX 6.5 awk fails if a
+        # line has length >= 3072.
+        if len(localpath) > 0:
+            actioncmd += ''.join([f" \\\n#  --local-dir={x}" for x in localpath])
+        actioncmd += ' \\\n#  --lib=%s' % libname
+        actioncmd += ' \\\n#  --source-base=%s' % sourcebase
+        actioncmd += ' \\\n#  --m4-base=%s' % m4base
         if pobase:
-            actioncmd += ' --po-base=%s' % pobase
-        actioncmd += ' --doc-base=%s' % docbase
-        actioncmd += ' --tests-base=%s' % testsbase
-        actioncmd += ' --aux-dir=%s' % auxdir
+            actioncmd += ' \\\n#  --po-base=%s' % pobase
+        actioncmd += ' \\\n#  --doc-base=%s' % docbase
+        actioncmd += ' \\\n#  --tests-base=%s' % testsbase
+        actioncmd += ' \\\n#  --aux-dir=%s' % auxdir
         if self.config.checkInclTestCategory(TESTS['tests']):
-            actioncmd += ' --with-tests'
+            actioncmd += ' \\\n#  --with-tests'
         if self.config.checkInclTestCategory(TESTS['obsolete']):
-            actioncmd += ' --with-obsolete'
+            actioncmd += ' \\\n#  --with-obsolete'
         if self.config.checkInclTestCategory(TESTS['c++-test']):
-            actioncmd += ' --with-c++-tests'
+            actioncmd += ' \\\n#  --with-c++-tests'
         if self.config.checkInclTestCategory(TESTS['longrunning-test']):
-            actioncmd += ' --with-longrunning-tests'
+            actioncmd += ' \\\n#  --with-longrunning-tests'
         if self.config.checkInclTestCategory(TESTS['privileged-test']):
-            actioncmd += ' --with-privileged-test'
+            actioncmd += ' \\\n#  --with-privileged-test'
         if self.config.checkInclTestCategory(TESTS['unportable-test']):
-            actioncmd += ' --with-unportable-tests'
+            actioncmd += ' \\\n#  --with-unportable-tests'
         if self.config.checkInclTestCategory(TESTS['all-test']):
-            actioncmd += ' --with-all-tests'
-        for module in avoids:
-            actioncmd += ' --avoid=%s' % module
+            actioncmd += ' \\\n#  --with-all-tests'
         if lgpl:
             if lgpl == True:
-                actioncmd += ' --lgpl'
+                actioncmd += ' \\\n#  --lgpl'
             else:  # if lgpl != True
-                actioncmd += ' --lgpl=%s' % lgpl
+                actioncmd += ' \\\n#  --lgpl=%s' % lgpl
         if gnu_make:
-            actioncmd += ' --gnu-make'
+            actioncmd += ' \\\n#  --gnu-make'
         if makefile_name:
-            actioncmd += ' --makefile-name=%s' % makefile_name
+            actioncmd += ' \\\n#  --makefile-name=%s' % makefile_name
+        # FIXME: Add the following options in this order when implemented.
+        # --tests-makefile-name
+        # --automake-subdir
+        # --automake-subdir-tests
         if conddeps:
-            actioncmd += ' --conditional-dependencies'
+            actioncmd += ' \\\n#  --conditional-dependencies'
         else:  # if not conddeps
-            actioncmd += ' --no-conditional-dependencies'
+            actioncmd += ' \\\n#  --no-conditional-dependencies'
         if libtool:
-            actioncmd += ' --libtool'
+            actioncmd += ' \\\n#  --libtool'
         else:  # if not libtool
-            actioncmd += ' --no-libtool'
-        actioncmd += ' --macro-prefix=%s' % macro_prefix
+            actioncmd += ' \\\n#  --no-libtool'
+        actioncmd += ' \\\n#  --macro-prefix=%s' % macro_prefix
         if podomain:
-            actioncmd = ' --podomain=%s' % podomain
+            actioncmd = ' \\\n#  --po-domain=%s' % podomain
         if witness_c_macro:
-            actioncmd += ' --witness_c_macro=%s' % witness_c_macro
+            actioncmd += ' \\\n#  --witness-c-macro=%s' % witness_c_macro
         if vc_files == True:
-            actioncmd += ' --vc-files'
+            actioncmd += ' \\\n#  --vc-files'
         elif vc_files == False:
-            actioncmd += ' --no-vc-files'
-        actioncmd += ' '  # Add a space
-        actioncmd += ' '.join(modules)
+            actioncmd += ' \\\n#  --no-vc-files'
+        if len(avoids) > 0:
+            actioncmd += ''.join([f" \\\n#  --avoid={x}" for x in sorted(avoids)])
+        if len(modules) > 0:
+            actioncmd += ''.join([f" \\\n#  {x}" for x in sorted(modules)])
         return actioncmd
 
     def relative_to_destdir(self, dir):
-- 
2.39.2

From da6528cec124976659bac165a4b817337eccb9d2 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Fri, 23 Feb 2024 21:12:39 -0800
Subject: [PATCH 2/2] gnulib-tool.py: Fix conditional checking the incorrect
 variable.

Reported by Bruno Haible <br...@clisp.org> in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00207.html>.

* gnulib-tool.py (main): Fix incorrect conditional. Check that mode, not
modules, is not None before treating it as a string.
---
 ChangeLog      | 8 ++++++++
 gnulib-tool.py | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index e439ce6389..468020ed5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-02-23  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix conditional checking the incorrect variable.
+	Reported by Bruno Haible <br...@clisp.org> in
+	<https://lists.gnu.org/archive/html/bug-gnulib/2024-02/msg00207.html>.
+	* gnulib-tool.py (main): Fix incorrect conditional. Check that mode, not
+	modules, is not None before treating it as a string.
+
 2024-02-23  Collin Funk  <collin.fu...@gmail.com>
 
 	gnulib-tool.py: Follow gnulib-tool changes, part 28.
diff --git a/gnulib-tool.py b/gnulib-tool.py
index 599dbe0984..e168e8fc91 100755
--- a/gnulib-tool.py
+++ b/gnulib-tool.py
@@ -607,7 +607,7 @@ def main():
     if cmdargs.pobase == None and cmdargs.podomain != None:
         message = '%s: warning: --po-domain has no effect without a --po-base option\n' % constants.APP['name']
         sys.stderr.write(message)
-    if modules != None and "tests" in mode and gnu_make:
+    if  mode != None and "tests" in mode and gnu_make:
         message = '%s: --gnu-make not supported when including tests\n' % constants.APP['name']
         sys.stderr.write(message)
         sys.exit(1)
-- 
2.39.2

Reply via email to