+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.
--------------------------------------------------------------------------------
-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
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
# 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):
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:
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'
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
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
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
# 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)
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.
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,
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