Hi Bruno,
On 3/19/24 4:55 PM, Bruno Haible wrote:
> I think this should be 'or', not 'and'? Cf. gnulib-tool.sh line 1667.
Yes...
That is my mistake, sorry. This patch patch should apply cleanly for you.
Collin
From 2536a3973c33cf0e036c0f956daee8939862b280 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 19 Mar 2024 12:09:57 -0700
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 68.
Follow gnulib-tool change
2022-07-31 Akim Demaille <a...@lrde.epita.fr>
gnulib-tool: add support for --automake-subdir-tests
* pygnulib/main.py (main): Add support for --automake-subdir-tests.
* pygnulib/GLInfo.py (GLInfo.usage): Add --automake-subdir-tests to the
help message.
* pygnulib/GLConfig.py (GLConfig.__init__): Add 'automake_subdir_tests'
to the parameter list. Initialize it.
(GLConfig.default): Default --automake-subdir-tests to False.
(GLConfig.resetAutomakeSubdir): Fix misleading docstring.
(GLConfig.getAutomakeSubdirTests, GLConfig.setAutomakeSubdirTests)
(GLConfig.resetAutomakeSubdirTests): New functions to manipulate and
access whether --automake-subdir-tests is in use.
* pygnulib/GLEmiter.py (GLEmiter.shellvars_init)
(GLEmiter.initmacro_end): Use sourcebase when handling tests and
--automake-subdir-tests is given.
* pygnulib/GLError.py (GLError.__repr__): Update error message to
include --automake-subdir-tests.
* pygnulib/GLImport.py (GLImport.__init__): Check for the
'subdir-objects' Automake option when --automake-subdir-tests is in use.
(GLImport.actioncmd): Add --automake-subdir-tests to the actioncmd
printed in generated files.
---
ChangeLog | 26 ++++++++++++++++++++++++++
gnulib-tool.py.TODO | 18 ------------------
pygnulib/GLConfig.py | 31 ++++++++++++++++++++++++++++---
pygnulib/GLEmiter.py | 16 +++++++++++++++-
pygnulib/GLError.py | 5 +++--
pygnulib/GLImport.py | 9 +++++----
pygnulib/GLInfo.py | 2 ++
pygnulib/main.py | 13 +++++++++++--
8 files changed, 90 insertions(+), 30 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 55b9d95af3..5a48bd1474 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2024-03-19 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Follow gnulib-tool changes, part 68.
+ Follow gnulib-tool change
+ 2022-07-31 Akim Demaille <a...@lrde.epita.fr>
+ gnulib-tool: add support for --automake-subdir-tests
+ * pygnulib/main.py (main): Add support for --automake-subdir-tests.
+ * pygnulib/GLInfo.py (GLInfo.usage): Add --automake-subdir-tests to the
+ help message.
+ * pygnulib/GLConfig.py (GLConfig.__init__): Add 'automake_subdir_tests'
+ to the parameter list. Initialize it.
+ (GLConfig.default): Default --automake-subdir-tests to False.
+ (GLConfig.resetAutomakeSubdir): Fix misleading docstring.
+ (GLConfig.getAutomakeSubdirTests, GLConfig.setAutomakeSubdirTests)
+ (GLConfig.resetAutomakeSubdirTests): New functions to manipulate and
+ access whether --automake-subdir-tests is in use.
+ * pygnulib/GLEmiter.py (GLEmiter.shellvars_init)
+ (GLEmiter.initmacro_end): Use sourcebase when handling tests and
+ --automake-subdir-tests is given.
+ * pygnulib/GLError.py (GLError.__repr__): Update error message to
+ include --automake-subdir-tests.
+ * pygnulib/GLImport.py (GLImport.__init__): Check for the
+ 'subdir-objects' Automake option when --automake-subdir-tests is in use.
+ (GLImport.actioncmd): Add --automake-subdir-tests to the actioncmd
+ printed in generated files.
+
2024-03-19 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Fix incorrect assignment operator.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index 75a51fc6b8..b3d83eeeb4 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -16,7 +16,6 @@ The following commits to gnulib-tool have not yet been reflected in
--------------------------------------------------------------------------------
Implement the options:
- --automake-subdir-tests
--help (same output)
Optimize:
@@ -25,23 +24,6 @@ Optimize:
--------------------------------------------------------------------------------
-commit 76c7703cb2e9e0e803d1296618d8ab9e86e13d6c
-Author: Akim Demaille <akim.demai...@gmail.com>
-Date: Mon Jul 4 07:18:07 2022 +0200
-
- gnulib-tool: add support for --automake-subdir-tests
-
- <https://lists.gnu.org/r/bug-gnulib/2022-01/msg00111.html>
-
- * gnulib-tool (main): Handle --automake-subdir-tests.
- (func_emit_shellvars_init, func_emit_lib_Makefile_am): Use
- $sourcebase when handling tests and --automake-subdir-tests is
- given.
- (func_append_actionarg): Support --automake-subdir-tests.
- (func_create_testdir): Add missing argument for func_emit_initmacro_end.
-
---------------------------------------------------------------------------------
-
commit 762bd0aa660b0c1c02597e0d2e5c5fbf9bab1b91
Author: Paul Eggert <egg...@cs.ucla.edu>
Date: Fri Jun 3 17:52:19 2022 -0700
diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py
index ecfbb13353..b95d2dd613 100644
--- a/pygnulib/GLConfig.py
+++ b/pygnulib/GLConfig.py
@@ -58,7 +58,8 @@ class GLConfig(object):
modules=None, avoids=None, files=None,
incl_test_categories=None, excl_test_categories=None, libname=None,
lgpl=None, gnu_make=None, makefile_name=None, tests_makefile_name=None,
- automake_subdir=None, libtool=None, conddeps=None, macro_prefix=None,
+ automake_subdir=None, automake_subdir_tests=None, libtool=None,
+ conddeps=None, macro_prefix=None,
podomain=None, witness_c_macro=None, vc_files=None, copymode=None,
lcopymode=None, configure_ac=None, ac_version=None, libtests=None,
single_configure=None, verbose=None, dryrun=None, errors=None):
@@ -147,6 +148,10 @@ class GLConfig(object):
self.resetAutomakeSubdir()
if automake_subdir != None:
self.setAutomakeSubdir(automake_subdir)
+ # automake_subdir_tests
+ self.resetAutomakeSubdirTests()
+ if automake_subdir_tests != None:
+ self.setAutomakeSubdirTests(automake_subdir_tests)
# libtool
self.resetLibtool()
if libtool != None:
@@ -289,7 +294,8 @@ class GLConfig(object):
elif key in ['localpath', 'modules', 'avoids', 'tests',
'incl_test_categories', 'excl_test_categories']:
return list()
- elif key in ['libtool', 'gnu_make', 'automake_subdir', 'conddeps',
+ elif key in ['libtool', 'gnu_make', 'automake_subdir',
+ 'automake_subdir_tests', 'conddeps',
'libtests', 'dryrun']:
return False
elif key in ['copymode', 'lcopymode']:
@@ -909,10 +915,29 @@ class GLConfig(object):
% type(automake_subdir).__name__)
def resetAutomakeSubdir(self) -> None:
- '''Set the value describing whether --automake-subdir is in use.
+ '''Reset the value describing whether --automake-subdir is in use.
Default is False.'''
self.table['automake_subdir'] = False
+ # Define automake_subdir_tests methods.
+ def getAutomakeSubdirTests(self) -> bool:
+ '''Return a bool describing whether --automake-subdir-tests is in use
+ or not.'''
+ return self.table['automake_subdir_tests']
+
+ def setAutomakeSubdirTests(self, automake_subdir_tests: bool) -> None:
+ '''Set the value describing whether --automake-subdir-tests is in use.'''
+ if type(automake_subdir_tests) is bool:
+ self.table['automake_subdir_tests'] = automake_subdir_tests
+ else: # if type of automake_subdir_tests is not bool
+ raise TypeError('automake_subdir_tests must be a bool, not %s'
+ % type(automake_subdir_tests).__name__)
+
+ def resetAutomakeSubdirTests(self) -> None:
+ '''Reset the value describing whether --automake-subdir-tests is in use.
+ Default is False.'''
+ self.table['automake_subdir_tests'] = False
+
# Define podomain methods.
def getPoDomain(self):
'''Return the prefix of the i18n domain. Usually use the package name.
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 16984e7d99..6b61111374 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -168,11 +168,21 @@ class GLEmiter(object):
raise TypeError(f'gentests must be a bool, not {type(gentests).__name__}')
if type(base) is not str:
raise TypeError(f'base must be a str, not {type(base).__name__}')
+ sourcebase = self.config['sourcebase']
+ testsbase = self.config['testsbase']
automake_subdir = self.config['automake_subdir']
+ automake_subdir_tests = self.config['automake_subdir_tests']
# Define the base directory, relative to the top-level directory.
emit = f' gl_source_base=\'{base}\'\n'
# Define the prefix for the file name of generated files.
- if automake_subdir and not gentests:
+ if gentests and automake_subdir_tests:
+ # When tests share the same Makefile as the whole project, they
+ # share the same base prefix.
+ if base == testsbase:
+ emit += f' gl_source_base_prefix=\'$(top_build_prefix){sourcebase}/\'\n'
+ else:
+ emit += f' gl_source_base_prefix=\'$(top_build_prefix){base}/\'\n'
+ elif not gentests and automake_subdir:
emit += f' gl_source_base_prefix=\'$(top_build_prefix){base}/\'\n'
else:
emit += ' gl_source_base_prefix=\n'
@@ -603,7 +613,9 @@ USE_MSGCTXT = no\n"""
raise TypeError('gentests must be a bool, not %s'
% type(gentests).__name__)
sourcebase = self.config['sourcebase']
+ testsbase = self.config['testsbase']
automake_subdir = self.config['automake_subdir']
+ automake_subdir_tests = self.config['automake_subdir_tests']
libtool = self.config['libtool']
emit = ''
# Check the presence of files that are mentioned as AC_LIBSOURCES
@@ -612,6 +624,8 @@ USE_MSGCTXT = no\n"""
# directory, the check is skipped.
if automake_subdir and not gentests and sourcebase != '' and sourcebase != '.':
subdir = f'{sourcebase}/'
+ elif automake_subdir_tests and gentests and testsbase != '' and testsbase != '.':
+ subdir = f'{testsbase}/'
else:
subdir = ''
if libtool:
diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py
index 4f46fbc994..17b513beb6 100644
--- a/pygnulib/GLError.py
+++ b/pygnulib/GLError.py
@@ -114,7 +114,8 @@ class GLError(Exception):
elif errno == 20:
message = 'could not patch test-driver script'
elif errno == 21:
- message = ('Option --automake-subdir is only supported if the definition of AUTOMAKE_OPTIONS '
- 'in Makefile.am contains \'subdir-objects\'.')
+ message = ('Option --automake-subdir/--automake-subdir-tests are only '
+ 'supported if the definition of AUTOMAKE_OPTIONS in '
+ 'Makefile.am contains \'subdir-objects\'.')
self.message = '[Errno %d] %s' % (errno, message)
return self.message
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index ddd5880d3c..4c7b62a8df 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -260,8 +260,8 @@ class GLImport(object):
self.config.update_key(config, key)
self.config.setModules(modules)
- # Determine whether --automake-subdir is supported.
- if self.config['automake_subdir']:
+ # Determine whether --automake-subdir/--automake-subdir-tests are supported.
+ if self.config['automake_subdir'] or self.config['automake_subdir_tests']:
found_subdir_objects = False
if self.config['destdir']:
with open(self.config['configure_ac'], encoding='utf-8') as file:
@@ -404,6 +404,7 @@ class GLImport(object):
makefile_name = self.config.getMakefileName()
tests_makefile_name = self.config.getTestsMakefileName()
automake_subdir = self.config.getAutomakeSubdir()
+ automake_subdir_tests = self.config.getAutomakeSubdirTests()
libtool = self.config.checkLibtool()
macro_prefix = self.config.getMacroPrefix()
witness_c_macro = self.config.getWitnessCMacro()
@@ -457,8 +458,8 @@ class GLImport(object):
actioncmd += ' \\\n# --tests-makefile-name=%s' % tests_makefile_name
if automake_subdir:
actioncmd += ' \\\n# --automake-subdir'
- # FIXME: Add the following options in this order when implemented.
- # --automake-subdir-tests
+ if automake_subdir_tests:
+ actioncmd += ' \\\n# --automake-subdir-tests'
if conddeps:
actioncmd += ' \\\n# --conditional-dependencies'
else: # if not conddeps
diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py
index 8851341c4d..8e36e3e9bb 100644
--- a/pygnulib/GLInfo.py
+++ b/pygnulib/GLInfo.py
@@ -294,6 +294,8 @@ Options for --import, --add/remove-import:
--automake-subdir Specify that the makefile in the source-base
directory be generated in such a way that it can
be 'include'd from the toplevel Makefile.am.
+ --automake-subdir-tests
+ Likewise, but for the tests directory.
--macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
'gl_INIT'. Default is 'gl'.
--po-domain=NAME Specify the prefix of the i18n domain. Usually use
diff --git a/pygnulib/main.py b/pygnulib/main.py
index b893977f50..a3e7f86387 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -408,6 +408,11 @@ def main():
dest='automake_subdir',
default=None,
action='store_true')
+ # automake-subdir-tests
+ parser.add_argument('--automake-subdir-tests',
+ dest='automake_subdir_tests',
+ default=None,
+ action='store_true')
# macro-prefix
parser.add_argument('--macro-prefix',
dest='macro_prefix',
@@ -660,6 +665,7 @@ def main():
or cmdargs.makefile_name != None
or cmdargs.tests_makefile_name != None
or cmdargs.automake_subdir != None
+ or cmdargs.automake_subdir_tests != None
or cmdargs.macro_prefix != None or cmdargs.podomain != None
or cmdargs.witness_c_macro != None or cmdargs.vc_files != None))):
message = '%s: *** ' % constants.APP['name']
@@ -758,6 +764,7 @@ def main():
if tests_makefile_name != None:
tests_makefile_name = tests_makefile_name[0]
automake_subdir = cmdargs.automake_subdir == True
+ automake_subdir_tests = cmdargs.automake_subdir_tests == True
macro_prefix = cmdargs.macro_prefix
if macro_prefix != None:
macro_prefix = macro_prefix[0]
@@ -798,6 +805,7 @@ def main():
makefile_name=makefile_name,
tests_makefile_name=tests_makefile_name,
automake_subdir=automake_subdir,
+ automake_subdir_tests=automake_subdir_tests,
libtool=libtool,
conddeps=cond_dependencies,
macro_prefix=macro_prefix,
@@ -1396,8 +1404,9 @@ if __name__ == '__main__':
elif errno == 20:
message += 'could not patch test-driver script'
elif errno == 21:
- message = ('Option --automake-subdir is only supported if the definition of AUTOMAKE_OPTIONS '
- 'in Makefile.am contains \'subdir-objects\'.')
+ message += ('Option --automake-subdir/--automake-subdir-tests are only '
+ 'supported if the definition of AUTOMAKE_OPTIONS in '
+ 'Makefile.am contains \'subdir-objects\'.')
message += '\n%s: *** Stop.\n' % constants.APP['name']
sys.stderr.write(message)
sys.exit(1)
--
2.44.0