From 1ec490bdc80f64d63ce7177114fcecfc50d460db Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Tue, 5 Mar 2024 23:47:08 -0800 Subject: [PATCH 3/4] gnulib-tool.py: Follow gnulib-tool changes, part 43. Follow gnulib-tool change 2021-06-10 Bruno Haible 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 | 18 +++++++++++++++++ gnulib-tool.py.TODO | 17 ---------------- pygnulib/GLEmiter.py | 46 +++++++++++++++++++++++++++++++++++++++---- pygnulib/GLImport.py | 14 ++++++++----- pygnulib/GLTestDir.py | 6 +++--- 5 files changed, 72 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index cfba30ce3e..53234e7de6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,21 @@ +2024-03-05 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 43. + Follow gnulib-tool change + 2021-06-10 Bruno Haible + 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-05 Collin Funk gnulib-tool.py: Fix gnulib-cache.m4 output. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 42728ed60d..a15bfc948a 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -551,23 +551,6 @@ Date: Thu Jun 10 21:43:59 2021 +0200 -------------------------------------------------------------------------------- -commit 16c3e1868a15a5946c0f0f7df6e107e9b3c6389d -Author: Bruno Haible -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 Date: Mon Apr 26 23:31:29 2021 -0700 diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py index ee963e69d7..1d1463851b 100644 --- a/pygnulib/GLEmiter.py +++ b/pygnulib/GLEmiter.py @@ -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_ 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' diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index a3623a9da1..5ffeaf26dc 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -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) diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py index 5f290c30c3..296356bd91 100644 --- a/pygnulib/GLTestDir.py +++ b/pygnulib/GLTestDir.py @@ -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 -- 2.44.0