]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 68.
authorCollin Funk <collin.funk1@gmail.com>
Tue, 19 Mar 2024 19:09:57 +0000 (12:09 -0700)
committerBruno Haible <bruno@clisp.org>
Wed, 20 Mar 2024 01:15:53 +0000 (02:15 +0100)
Follow gnulib-tool change
2022-07-31  Akim Demaille  <akim@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
gnulib-tool.py.TODO
pygnulib/GLConfig.py
pygnulib/GLEmiter.py
pygnulib/GLError.py
pygnulib/GLImport.py
pygnulib/GLInfo.py
pygnulib/main.py

index 55b9d95af35a6faeeb77c1ae47b88be2c460ff61..5a48bd1474c1d314077714da17a32d2cea1028f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2024-03-19  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 68.
+       Follow gnulib-tool change
+       2022-07-31  Akim Demaille  <akim@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.funk1@gmail.com>
 
        gnulib-tool.py: Fix incorrect assignment operator.
index 75a51fc6b863e3b2a01dde03779160338569ee7e..b3d83eeeb4cbfeb20132d471b4b2f8cfec08dadb 100644 (file)
@@ -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.demaille@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 <eggert@cs.ucla.edu>
 Date:   Fri Jun 3 17:52:19 2022 -0700
index ecfbb13353f49959fe5e100e29f8d7580deae4c6..b95d2dd61398f3a05c6acbda5e644d6c1ffc72be 100644 (file)
@@ -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.
index 16984e7d99151d054b0ade104a0c9b39ebaf7b63..6b6111137458f076beaae3c8cc338fbac892ffd0 100644 (file)
@@ -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:
index 4f46fbc9948a2abd41b4e62561e7ce639355581e..17b513beb65811afa3060c486f8224abc3913282 100644 (file)
@@ -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
index ddd5880d3c927cc025be8d0a4b688d6b79b923c0..4c7b62a8df79f9c936f9eaa8de4a933ccc83eb45 100644 (file)
@@ -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
index 8851341c4deb96c6074b0b3e5a8e2f2c12434863..8e36e3e9bb89ecb75992db3d4e5a46d519d34670 100644 (file)
@@ -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
index b893977f50ef2f492c506904a9e750b77b6ef2c1..a3e7f86387747c395af642b0aa62cd5f3a207896 100644 (file)
@@ -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)