+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.
--------------------------------------------------------------------------------
-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
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
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(' ')