]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Don't do license replacements in the autoconf snippets.
authorBruno Haible <bruno@clisp.org>
Tue, 9 Aug 2022 21:59:40 +0000 (23:59 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 9 Aug 2022 21:59:40 +0000 (23:59 +0200)
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Remove fileassistant
argument. Don't invoke the 'aux' transformer here. Don't produce Windows
CR-LFs on Windows.
(GLEmiter.autoconfSnippets): Remove fileassistant argument.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Update all callers.
* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.

ChangeLog
pygnulib/GLEmiter.py
pygnulib/GLImport.py
pygnulib/GLTestDir.py

index 50ef82d525f52cfddf345062da90e140e6904790..642a7363e3ad828f02270f09a14449544bcd2b12 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2022-08-09  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Don't do license replacements in the autoconf snippets.
+       * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippet): Remove fileassistant
+       argument. Don't invoke the 'aux' transformer here. Don't produce Windows
+       CR-LFs on Windows.
+       (GLEmiter.autoconfSnippets): Remove fileassistant argument.
+       * pygnulib/GLImport.py (GLImport.gnulib_comp): Update all callers.
+       * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
+
        gnulib-tool.py: Fix some code generation details.
        * pygnulib/GLEmiter.py (GLEmiter.lib_Makefile_am): When removing a
        lib_LDFLAGS line, remove also the newline. Fix regex that matches
index 1a15fc491884bb80bee09b76e3e94204c20542ed..9b54d5009ee7ad667f3bf8a4e01695719d584f2e 100644 (file)
@@ -95,18 +95,15 @@ class GLEmiter(object):
 # Generated by gnulib-tool.\n"""
         return constants.nlconvert(emit)
 
-    def autoconfSnippet(self, module, fileassistant, toplevel,
+    def autoconfSnippet(self, module, toplevel,
                         disable_libtool, disable_gettext, replace_auxdir, indentation):
         '''GLEmiter.autoconfSnippet(module, toplevel,
-          disable_libtool, disable_gettext, replace_auxdir,
-          indentation) -> str
+          disable_libtool, disable_gettext, replace_auxdir, indentation) -> str
 
         Emit the autoconf snippet of a module.
         GLConfig: include_guard_prefix.
 
         module is a GLModule instance, which is processed.
-        fileassistant is a GLFileAssistant instance, which is used to get temporary
-          directories and sed transformer.
         toplevel is a bool variable, False means a subordinate use of pygnulib.
         disable_libtool is a bool variable; it tells whether to disable libtool
           handling even if it has been specified through the GLConfig class.
@@ -115,13 +112,9 @@ class GLEmiter(object):
         replace_auxdir is a bool variable; it tells whether to replace
           'build-aux' directory in AC_CONFIG_FILES.
         indentation is a string which contain spaces to prepend on each line.'''
-        emit = ''
         if type(module) is not GLModule:
             raise TypeError('module must be a GLModule, not %s'
                             % type(module).__name__)
-        if type(fileassistant) is not GLFileAssistant:
-            raise TypeError('fileassistant must be a GLFileAssistant, not %s'
-                            % type(fileassistant).__name__)
         if type(toplevel) is not bool:
             raise TypeError('toplevel must be a bool, not %s'
                             % type(toplevel).__name__)
@@ -139,6 +132,7 @@ class GLEmiter(object):
         auxdir = self.config['auxdir']
         libtool = self.config['libtool']
         include_guard_prefix = self.config['include_guard_prefix']
+        emit = ''
         if str(module) in ['gnumakefile', 'maintainer-makefile']:
             # These modules are meant to be used only in the top-level directory.
             flag = toplevel
@@ -152,18 +146,8 @@ class GLEmiter(object):
                       for line in snippet.split('\n')
                       if line.strip() ]
             snippet = '%s\n' % '\n'.join(lines)
-            transformer = fileassistant.transformers.get('aux', '')
             pattern = re.compile('^(.*)$', re.M)
             snippet = pattern.sub('%s\\1' % indentation, snippet)
-            if transformer:
-                args = ['sed', '-e', transformer]
-                path = fileassistant.tmpfilename('snippet')
-                with codecs.open(path, 'wb', 'UTF-8') as file:
-                    file.write(snippet)
-                stdin = codecs.open(path, 'rb', 'UTF-8')
-                snippet = sp.check_output(args, stdin=stdin, shell=False)
-                snippet = snippet.decode("UTF-8")
-                os.remove(path)
             if disable_libtool:
                 snippet = snippet.replace('$gl_cond_libtool', 'false')
                 snippet = snippet.replace('gl_libdeps', 'gltests_libdeps')
@@ -181,23 +165,21 @@ class GLEmiter(object):
                 emit += "LTALLOCA=`echo \"$ALLOCA\" | sed -e 's/\\.[^.]* /.lo /g;s/\\.[^.]*$/.lo/'`\n"
                 emit += 'changequote([, ])dnl\n'
                 emit += 'AC_SUBST([LTALLOCA])'
-        if replace_auxdir:
-            regex = 'AC_CONFIG_FILES\\(\\[(.*)\\:build-aux/(.*)\\]\\)'
-            repl = 'AC_CONFIG_FILES([\\1:%s/\\2])' % auxdir
-            pattern = re.compile(regex, re.M)
-            emit = pattern.sub(repl, emit)
+            if replace_auxdir:
+                regex = 'AC_CONFIG_FILES\\(\\[(.*)\\:build-aux/(.*)\\]\\)'
+                repl = 'AC_CONFIG_FILES([\\1:%s/\\2])' % auxdir
+                pattern = re.compile(regex, re.M)
+                emit = pattern.sub(repl, emit)
         lines = [ line
                   for line in emit.split('\n')
                   if line.strip() ]
         emit = '%s\n' % '\n'.join(lines)
-        emit = constants.nlconvert(emit)
         return emit
 
-    def autoconfSnippets(self, modules, moduletable, fileassistant,
+    def autoconfSnippets(self, modules, moduletable,
                          verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir):
-        '''GLEmiter.autoconfSnippets(modules, fileassistant,
-          verifier, toplevel, disable_libtool, disable_gettext,
-          replace_auxdir) -> str
+        '''GLEmiter.autoconfSnippets(modules,
+          verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir) -> str
 
         Collect and emit the autoconf snippets of a set of modules.
         GLConfig: conddeps.
@@ -209,8 +191,6 @@ class GLEmiter(object):
           be a GLModule instance.
         moduletable is a GLModuleTable instance, which contains necessary
           information about dependencies of the modules.
-        fileassistant is a GLFileAssistant instance, which is used to get temporary
-          directories and sed transformers.
         verifier is an integer, which can be 0, 1 or 2.
           if verifier == 0, then process every module;
           if verifier == 1, then process only non-tests modules;
@@ -229,9 +209,6 @@ class GLEmiter(object):
         if type(moduletable) is not GLModuleTable:
             raise TypeError('moduletable must be a GLFileAssistant, not %s'
                             % type(moduletable).__name__)
-        if type(fileassistant) is not GLFileAssistant:
-            raise TypeError('fileassistant must be a GLFileAssistant, not %s'
-                            % type(fileassistant).__name__)
         if type(verifier) is not int:
             raise TypeError('verifier must be an int, not %s'
                             % type(verifier).__name__)
@@ -262,7 +239,7 @@ class GLEmiter(object):
                 elif verifier == 2:
                     solution = module.isTests()
                 if solution:
-                    emit += self.autoconfSnippet(module, fileassistant, toplevel,
+                    emit += self.autoconfSnippet(module, toplevel,
                                                  disable_libtool, disable_gettext, replace_auxdir, '  ')
         else:  # if conddeps
             # Emit the autoconf code for the unconditional modules.
@@ -275,7 +252,7 @@ class GLEmiter(object):
                     solution = module.isTests()
                 if solution:
                     if not moduletable.isConditional(module):
-                        emit += self.autoconfSnippet(module, fileassistant, toplevel,
+                        emit += self.autoconfSnippet(module, toplevel,
                                                      disable_libtool, disable_gettext, replace_auxdir, '  ')
             # Initialize the shell variables indicating that the modules are enabled.
             for module in modules:
@@ -306,7 +283,7 @@ class GLEmiter(object):
                         emit += '  %s ()\n' % shellfunc
                         emit += '  {\n'
                         emit += '    if ! $%s; then\n' % shellvar
-                        emit += self.autoconfSnippet(module, fileassistant, toplevel,
+                        emit += self.autoconfSnippet(module, toplevel,
                                                      disable_libtool, disable_gettext, replace_auxdir, '      ')
                         emit += '      %s=true\n' % shellvar
                         depmodules = module.getDependenciesWithoutConditions()
index 0197e0671dac4a5372e2ae4008d25154863c6000..114605dd8a1409080860bde7904545e9cedc0fca 100644 (file)
@@ -636,7 +636,7 @@ AC_DEFUN([%s_INIT],
             emit += '  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % witness_c_macro
         # Emit main autoconf snippets.
         emit += self.emiter.autoconfSnippets(moduletable['main'],
-                                             moduletable, assistant, 0, True, False, True, replace_auxdir)
+                                             moduletable, 0, True, False, True, replace_auxdir)
         if witness_c_macro:
             emit += '  m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
         emit += '  # End of code from modules\n'
@@ -659,7 +659,7 @@ AC_DEFUN([%s_INIT],
         emit += '[$gl_module_indicator_condition])\n'
         # Emit tests autoconf snippets.
         emit += self.emiter.autoconfSnippets(moduletable['tests'],
-                                             moduletable, assistant, 0, True, True, True, replace_auxdir)
+                                             moduletable, 0, True, True, True, replace_auxdir)
         emit += '  m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
         emit += self.emiter.initmacro_end('%stests' % macro_prefix)
         # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
index 746b815b493797170d598df9265eebc1911801fd..3c4ad0b9dc19965c950987c158659dd7bc35539f 100644 (file)
@@ -496,11 +496,11 @@ class GLTestDir(object):
                 # those of the tests.
                 emit += "gl_source_base='../%s'\n" % sourcebase
                 emit += self.emiter.autoconfSnippets(modules,
-                                                     moduletable, self.assistant, 1, False, False, False,
+                                                     moduletable, 1, False, False, False,
                                                      replace_auxdir)
                 emit += "gl_source_base='.'"
                 emit += self.emiter.autoconfSnippets(modules,
-                                                     moduletable, self.assistant, 2, False, False, False,
+                                                     moduletable, 2, False, False, False,
                                                      replace_auxdir)
                 emit += self.emiter.initmacro_end(macro_prefix)
                 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
@@ -614,10 +614,10 @@ class GLTestDir(object):
         emit += 'gl_source_base=\'%s\'\n' % sourcebase
         if single_configure:
             emit += self.emiter.autoconfSnippets(main_modules, moduletable,
-                                                 self.assistant, 0, False, False, False, replace_auxdir)
+                                                 0, False, False, False, replace_auxdir)
         else:  # if not single_configure
             emit += self.emiter.autoconfSnippets(modules, moduletable,
-                                                 self.assistant, 1, False, False, False, replace_auxdir)
+                                                 1, False, False, False, replace_auxdir)
         emit += self.emiter.initmacro_end(macro_prefix)
         if single_configure:
             emit += '  gltests_libdeps=\n'
@@ -631,7 +631,7 @@ class GLTestDir(object):
             emit += '  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], '
             emit += '[$gl_module_indicator_condition])\n'
             snippets = self.emiter.autoconfSnippets(tests_modules, moduletable,
-                                                    self.assistant, 1, True, False, False, replace_auxdir)
+                                                    1, True, False, False, replace_auxdir)
             emit += snippets.strip()
             emit += '  m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
             emit += self.emiter.initmacro_end('%stests' % macro_prefix)