]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 43.
authorCollin Funk <collin.funk1@gmail.com>
Wed, 6 Mar 2024 07:47:08 +0000 (23:47 -0800)
committerBruno Haible <bruno@clisp.org>
Wed, 6 Mar 2024 10:56:58 +0000 (11:56 +0100)
Follow gnulib-tool change
2021-06-10  Bruno Haible  <bruno@clisp.org>
Clarify that compiler warnings in the Gnulib tests can be ignored.

* pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
be required.
(GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
Emit a dependency of 'all' on 'all-notice' that prints a warning that
compiler warnings can be ignored for tests.
* pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
tell whether a tests Makefile.am is being emitted. Update calls to
GLEmiter.initmacro_start.
(GLImport.execute): Update calls to GLEmiter.initmacro_start.
* pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLEmiter.py
pygnulib/GLImport.py
pygnulib/GLTestDir.py

index a73ab29e9dc234da668f6fc55df388c25be1fa2d..2b4839a8d2e676d45496b5079a9adb213004ab78 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2024-03-06  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 43.
+       Follow gnulib-tool change
+       2021-06-10  Bruno Haible  <bruno@clisp.org>
+       Clarify that compiler warnings in the Gnulib tests can be ignored.
+       * pygnulib/GLEmiter.py (GLEmiter.initmacro_start): Add boolean argument
+       to control whether gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS should
+       be required.
+       (GLEmiter.tests_Makefile_am): Emit overrides for CFLAGS and CXXFLAGS.
+       Emit a dependency of 'all' on 'all-notice' that prints a warning that
+       compiler warnings can be ignored for tests.
+       * pygnulib/GLImport.py (GLImport.gnulib_comp): Add boolean argument to
+       tell whether a tests Makefile.am is being emitted. Update calls to
+       GLEmiter.initmacro_start.
+       (GLImport.execute): Update calls to GLEmiter.initmacro_start.
+       * pygnulib/GLTestDir.py (GLTestDir.execute): Likewise.
+
 2024-03-06  Collin Funk  <collin.funk1@gmail.com>
 
        gnulib-tool.py: Fix gnulib-cache.m4 output.
index 42728ed60df5167f359d79c966e0329324d7ab26..a15bfc948a0b0b6ba21f433a47507ca38198a32c 100644 (file)
@@ -551,23 +551,6 @@ Date:   Thu Jun 10 21:43:59 2021 +0200
 
 --------------------------------------------------------------------------------
 
-commit 16c3e1868a15a5946c0f0f7df6e107e9b3c6389d
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Thu Jun 10 21:26:53 2021 +0200
-
-    Clarify that compiler warnings in the Gnulib tests can be ignored.
-
-    * gnulib-tool (func_emit_tests_Makefile_am): Emit overrides for CFLAGS
-    and CXXFLAGS. Emit a dependency of 'all' on 'all-notice' that prints a
-    notice.
-    (func_emit_initmacro_start): Add a second argument. If it is true, emit
-    code to require gl_CC_ALLOW_WARNINGS and gl_CXX_ALLOW_WARNINGS.
-    (func_import, func_create_testdir): All callers updated.
-    * m4/gnulib-common.m4 (gl_CC_ALLOW_WARNINGS, gl_CXX_ALLOW_WARNINGS): New
-    macros.
-
---------------------------------------------------------------------------------
-
 commit 4b071c115309079528db7b60e8d2ffb22b129088
 Author: Paul Eggert <eggert@cs.ucla.edu>
 Date:   Mon Apr 26 23:31:29 2021 -0700
index ee963e69d78164ee9fc4bfffe12ced7bba647a82..1d1463851bf120dc01edb3ef7b2d99467378bf8f 100644 (file)
@@ -457,13 +457,20 @@ USE_MSGCTXT = no\n"""
                 emit += '%s\n' % constants.substart('lib/', sourcebase, file)
         return emit
 
-    def initmacro_start(self, macro_prefix_arg):
-        '''GLEmiter.initmacro_start(macro_prefix_arg) -> str
+    def initmacro_start(self, macro_prefix_arg, gentests):
+        '''GLEmiter.initmacro_start(macro_prefix_arg, gentests) -> str
 
-        Emit the first few statements of the gl_INIT macro.'''
+        Emit the first few statements of the gl_INIT macro.
+
+        macro_prefix_arg is the prefix of gl_EARLY and gl_INIT macros to use.
+        gentests is True if a tests Makefile.am is being generated, False
+          otherwise.'''
         if type(macro_prefix_arg) is not str:
             raise TypeError('macro_prefix_arg must be a string, not %s'
                             % type(macro_prefix_arg).__name__)
+        if type(gentests) is not bool:
+            raise TypeError('gentests must be a bool, not %s'
+                            % type(gentests).__name__)
         module_indicator_prefix = self.config.getModuleIndicatorPrefix()
         emit = ''
         # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
@@ -495,6 +502,9 @@ USE_MSGCTXT = no\n"""
         # Scope the GNULIB_<modulename> variables.
         emit += "  m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [%s])\n" % module_indicator_prefix
         emit += "  gl_COMMON\n"
+        if gentests:
+            emit += '  AC_REQUIRE([gl_CC_ALLOW_WARNINGS])\n'
+            emit += '  AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])\n'
         return emit
 
     def initmacro_end(self, macro_prefix_arg):
@@ -1112,7 +1122,27 @@ AC_DEFUN([%V1%_LIBSOURCES], [
                     emit += '%s += %s\n' % (dictionary['var'], val)
                     dictionary.pop('var')
 
-        emit += '\nAM_CPPFLAGS = \\\n'
+        # Insert a '-Wno-error' option in the compilation commands emitted by
+        # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
+        # Why?
+        # 1) Because parts of the Gnulib tests exercise corner cases (invalid
+        #    arguments, endless recursions, etc.) that a compiler may warn about,
+        #    even with just the normal '-Wall' option.
+        # 2) Because every package maintainer has their preferred set of warnings
+        #    that they may want to enforce in the main source code of their package.
+        #    But Gnulib tests are maintained in Gnulib and don't end up in binaries
+        #    that that package installs; therefore it does not make sense for
+        #    package maintainers to enforce the absence of warnings on these tests.
+        # Why before @CFLAGS@?
+        # - Because "the user is always right": If a user adds '-Werror' to their
+        #   CFLAGS, they have asked for errors, they will get errors. But they have
+        #   no right to complain about these errors, because Gnulib does not support
+        #   '-Werror'.
+        emit += '\n'
+        emit += 'CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@ @CFLAGS@\n'
+        emit += 'CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@\n'
+        emit += '\n'
+        emit += 'AM_CPPFLAGS = \\\n'
         if for_test:
             emit += '  -DGNULIB_STRICT_CHECKING=1 \\\n'
         if witness_c_macro:
@@ -1160,6 +1190,14 @@ AC_DEFUN([%V1%_LIBSOURCES], [
         all_snippets = all_snippets.replace('$(top_srcdir)/build-aux/',
                                             '$(top_srcdir)/%s/' % auxdir)
         emit += all_snippets
+        # Arrange to print a message before compiling the files in this directory.
+        emit += 'all: all-notice\n'
+        emit += 'all-notice:\n'
+        emit += '\t@echo \'## ---------------------------------------------------- ##\'\n'
+        emit += '\t@echo \'## ------------------- Gnulib tests ------------------- ##\'\n'
+        emit += '\t@echo \'## You can ignore compiler warnings in this directory.  ##\'\n'
+        emit += '\t@echo \'## ---------------------------------------------------- ##\'\n'
+        emit += '\n'
         emit += '# Clean up after Solaris cc.\n'
         emit += 'clean-local:\n'
         emit += '\trm -rf SunWS_cache\n\n'
index a3623a9da10b10f6d305b34cccf069c5650d9bb3..5ffeaf26dc97dc06f2edf083c362607670fe4e48 100644 (file)
@@ -555,12 +555,16 @@ class GLImport(object):
             emit += 'gl_VC_FILES([%s])\n' % vc_files
         return constants.nlconvert(emit)
 
-    def gnulib_comp(self, files):
+    def gnulib_comp(self, files, gentests):
         '''GLImport.gnulib_comp(files) -> str
 
         Emit the contents of generated $m4base/gnulib-comp.m4 file.
         GLConfig: destdir, localpath, tests, sourcebase, m4base, pobase, docbase,
-        testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.'''
+        testsbase, conddeps, libtool, macro_prefix, podomain, vc_files.
+
+        files is the list of files to use.
+        gentests is True if a tests Makefile.am is being generated, False
+          otherwise.'''
         emit = ''
         assistant = self.assistant
         moduletable = self.moduletable
@@ -641,7 +645,7 @@ AC_DEFUN([%s_INIT],
         if auxdir != 'build-aux':
             replace_auxdir = True
         emit += '  gl_m4_base=\'%s\'\n' % m4base
-        emit += self.emitter.initmacro_start(macro_prefix)
+        emit += self.emitter.initmacro_start(macro_prefix, False)
         emit += '  gl_source_base=\'%s\'\n' % sourcebase
         if witness_c_macro:
             emit += '  m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % witness_c_macro
@@ -654,7 +658,7 @@ AC_DEFUN([%s_INIT],
         emit += self.emitter.initmacro_end(macro_prefix)
         emit += '  gltests_libdeps=\n'
         emit += '  gltests_ltlibdeps=\n'
-        emit += self.emitter.initmacro_start('%stests' % macro_prefix)
+        emit += self.emitter.initmacro_start('%stests' % macro_prefix, gentests)
         emit += '  gl_source_base=\'%s\'\n' % testsbase
         # Define a tests witness macro that depends on the package.
         # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by
@@ -1260,7 +1264,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Create m4/gnulib-comp.m4.
         basename = joinpath(m4base, 'gnulib-comp.m4')
         tmpfile = self.assistant.tmpfilename(basename)
-        emit = self.gnulib_comp(filetable['all'])
+        emit = self.gnulib_comp(filetable['all'], gentests)
         with codecs.open(tmpfile, 'wb', 'UTF-8') as file:
             file.write(emit)
         filename, backup, flag = self.assistant.super_update(basename, tmpfile)
index 5f290c30c3d528891c93a0f717e102b80eb6398a..296356bd9196d882b69562951c69cc102c74e7b4 100644 (file)
@@ -465,7 +465,7 @@ class GLTestDir(object):
                 emit += 'AC_DEFUN([gl_INIT], [\n'
                 replace_auxdir = True
                 emit += "gl_m4_base='../%s'\n" % m4base
-                emit += self.emitter.initmacro_start(macro_prefix)
+                emit += self.emitter.initmacro_start(macro_prefix, True)
                 # We don't have explicit ordering constraints between the various
                 # autoconf snippets. It's cleanest to put those of the library before
                 # those of the tests.
@@ -585,7 +585,7 @@ class GLTestDir(object):
         else:  # auxdir == 'build-aux'
             replace_auxdir = False
         emit += 'gl_m4_base=\'%s\'\n' % m4base
-        emit += self.emitter.initmacro_start(macro_prefix)
+        emit += self.emitter.initmacro_start(macro_prefix, False)
         emit += 'gl_source_base=\'%s\'\n' % sourcebase
         if single_configure:
             emit += self.emitter.autoconfSnippets(main_modules, main_modules, moduletable,
@@ -597,7 +597,7 @@ class GLTestDir(object):
         if single_configure:
             emit += '  gltests_libdeps=\n'
             emit += '  gltests_ltlibdeps=\n'
-            emit += self.emitter.initmacro_start('%stests' % macro_prefix)
+            emit += self.emitter.initmacro_start('%stests' % macro_prefix, True)
             emit += '  gl_source_base=\'%s\'\n' % testsbase
             # Define a tests witness macro.
             emit += '  %stests_WITNESS=IN_GNULIB_TESTS\n' % macro_prefix