]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 63.
authorCollin Funk <collin.funk1@gmail.com>
Sun, 17 Mar 2024 21:51:18 +0000 (14:51 -0700)
committerBruno Haible <bruno@clisp.org>
Sun, 17 Mar 2024 22:34:52 +0000 (23:34 +0100)
Follow gnulib-tool change
2020-12-28  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Fix logic whether to add a dummy.c.

* pygnulib/GLModuleSystem.py (GLModuleTable.remove_if_blocks): New
function.
(GLModuleTable.add_dummy): Use it to eliminate all conditional
statements from the automake snippet.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLModuleSystem.py

index b1f7a3d1d319fea038fb7d3b9113b1419e9915fa..9471f25a6e53d1fde408db72b0d8d1e326f5871b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-03-17  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 63.
+       Follow gnulib-tool change
+       2020-12-28  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Fix logic whether to add a dummy.c.
+       * pygnulib/GLModuleSystem.py (GLModuleTable.remove_if_blocks): New
+       function.
+       (GLModuleTable.add_dummy): Use it to eliminate all conditional
+       statements from the automake snippet.
+
 2024-03-17  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Don't print extra newlines.
index 9a22e0ee7780081cd18b9ae6ced49acf4e9510f3..8178b2fbfd95f99d4d475fe3f9c00d67ef91d812 100644 (file)
@@ -116,18 +116,6 @@ Date:   Sun Dec 19 12:49:16 2021 +0100
 
 --------------------------------------------------------------------------------
 
-commit 0be855ee827bf7e9043eeb626c4fd847704be2e6
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Tue Dec 29 02:48:31 2020 +0100
-
-    gnulib-tool: Fix logic whether to add a dummy.c.
-
-    * gnulib-tool (func_remove_if_blocks): New function.
-    (func_modules_add_dummy): Use it to eliminate all conditional statements
-    from the automake snippet.
-
---------------------------------------------------------------------------------
-
 commit 30459fe101541698ec704acb224946d73676750e
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Thu Jun 8 15:09:31 2017 +0200
index 37433a42db3feeb81cfe4f3e22fb14e07189368e..55b479e096ea3b25df863d8465ed8716aaf40993 100644 (file)
@@ -1049,6 +1049,26 @@ class GLModuleTable(object):
         result = tuple([main_modules, tests_modules])
         return result
 
+    def remove_if_blocks(self, snippet: str) -> str:
+        '''Removes if...endif blocks from an automake snippet.'''
+        lines = snippet.splitlines()
+        cleansed = []
+        depth = 0
+        for line in lines:
+            if line.startswith('if '):
+                depth += 1
+            elif line.startswith('endif'):
+                depth -= 1
+                # Make sure gnulib-tool.py and gnulib-tool.sh produce the same
+                # output.
+                cleansed.append(line[5:])
+            elif depth == 0:
+                cleansed.append(line)
+        if len(cleansed) > 0:
+            return '\n'.join(cleansed)
+        else:
+            return ''
+
     def add_dummy(self, modules):
         '''GLModuleTable.add_dummy(modules) -> list
 
@@ -1071,8 +1091,9 @@ class GLModuleTable(object):
                     pass
                 else:
                     snippet = module.getAutomakeSnippet()
-                    # Extract the value of "lib_SOURCES += ...".
+                    # Extract the value of unconditional "lib_SOURCES += ..." augmentations.
                     snippet = constants.remove_backslash_newline(snippet)
+                    snippet = self.remove_if_blocks(snippet)
                     pattern = re.compile('^lib_SOURCES[\t ]*\\+=([^#]*).*$', re.M)
                     for matching_rhs in pattern.findall(snippet):
                         files = matching_rhs.split(' ')