]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Follow gnulib-tool changes, part 45.
authorCollin Funk <collin.funk1@gmail.com>
Thu, 7 Mar 2024 05:49:21 +0000 (21:49 -0800)
committerBruno Haible <bruno@clisp.org>
Thu, 7 Mar 2024 11:43:56 +0000 (12:43 +0100)
Follow gnulib-tool changes
2021-12-12  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Support different basenames for the lib/,tests/ Makefiles.
2022-01-08  Bruno Haible  <bruno@clisp.org>
gnulib-tool: Fix "Don't forget" messages (regression 2021-12-12).

* pygnulib/GLConfig.py (GLConfig.__init__): Add 'tests_makefile_name'
argument.
(GLConfig.getMakefileName, GLConfig.setMakefileName)
(GLConfig.resetMakefileName): Remove references to tests Makefile.am in
doc strings.
(GLConfig.getTestsMakefileNamem, GLConfig.setTestsMakefileName)
(GLConfig.resetTestsMakefileName): New methods used to access value
passed with the '--tests-makefile-name' option.
* pygnulib/GLImport.py (GLImport.__init__): Check for
'gl_TESTS_MAKEFILE_NAME' in cache.
(GLImport.actioncmd): Output --tests-makefile-name when describing
gnulib-tool invocation.
(GLImport.gnulib_cache): Output 'gl_TESTS_MAKEFILE_NAME' to cache.
(GLImport.execute): Use two local variables, source_makefile_am and
tests_makefile_am, which are passed to gnulib-tool.py or given default
values.
* pygnulib/GLInfo.py (GLInfo.usage): Add '--tests-makefile-name' to
usage message.
* pygnulib/GLMakefileTable.py (GLMakefileTable.parent): Reduce code
duplication by expecting Makefile names passed as arguments.
* pygnulib/main.py (main): Add support for '--tests-makefile-name'.

ChangeLog
gnulib-tool.py.TODO
pygnulib/GLConfig.py
pygnulib/GLImport.py
pygnulib/GLInfo.py
pygnulib/GLMakefileTable.py
pygnulib/main.py

index 9666d65ba293b4302ef8e2738d14111dbb368a77..cd8fa303bb760f2ce6f45ad36abbeb818651549a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,33 @@
+2024-03-07  Collin Funk  <collin.funk1@gmail.com>
+
+       gnulib-tool.py: Follow gnulib-tool changes, part 45.
+       Follow gnulib-tool changes
+       2021-12-12  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Support different basenames for the lib/,tests/ Makefiles.
+       2022-01-08  Bruno Haible  <bruno@clisp.org>
+       gnulib-tool: Fix "Don't forget" messages (regression 2021-12-12).
+       * pygnulib/GLConfig.py (GLConfig.__init__): Add 'tests_makefile_name'
+       argument.
+       (GLConfig.getMakefileName, GLConfig.setMakefileName)
+       (GLConfig.resetMakefileName): Remove references to tests Makefile.am in
+       doc strings.
+       (GLConfig.getTestsMakefileNamem, GLConfig.setTestsMakefileName)
+       (GLConfig.resetTestsMakefileName): New methods used to access value
+       passed with the '--tests-makefile-name' option.
+       * pygnulib/GLImport.py (GLImport.__init__): Check for
+       'gl_TESTS_MAKEFILE_NAME' in cache.
+       (GLImport.actioncmd): Output --tests-makefile-name when describing
+       gnulib-tool invocation.
+       (GLImport.gnulib_cache): Output 'gl_TESTS_MAKEFILE_NAME' to cache.
+       (GLImport.execute): Use two local variables, source_makefile_am and
+       tests_makefile_am, which are passed to gnulib-tool.py or given default
+       values.
+       * pygnulib/GLInfo.py (GLInfo.usage): Add '--tests-makefile-name' to
+       usage message.
+       * pygnulib/GLMakefileTable.py (GLMakefileTable.parent): Reduce code
+       duplication by expecting Makefile names passed as arguments.
+       * pygnulib/main.py (main): Add support for '--tests-makefile-name'.
+
 2024-03-06  Bruno Haible  <bruno@clisp.org>
 
        gnulib-tool: Search for a working 'join' program.
index 85480130059d1e5e9d559d9d2c45133846659e6d..a78335e6fd37f23c24293124fbf690205c9b6c7d 100644 (file)
@@ -18,7 +18,6 @@ The following commits to gnulib-tool have not yet been reflected in
 Implement the options:
   --extract-recursive-dependencies
   --extract-recursive-link-directive
-  --tests-makefile-name
   --automake-subdir
   -h | --hardlink
   --local-hardlink
@@ -490,29 +489,6 @@ Date:   Mon Dec 13 02:43:21 2021 +0100
 
 --------------------------------------------------------------------------------
 
-commit 1cc82c4280bb76f677f3604bdef7116922d77511
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Sat Jan 8 23:28:29 2022 +0100
-
-    gnulib-tool: Fix "Don't forget" messages (regression 2021-12-12).
-
-    * gnulib-tool (func_import): Fix variable references in "Don't forget"
-    messages.
-
-commit 9e8aac033ffe63761ca6ddc8a3f672d1b7104cb5
-Author: Bruno Haible <bruno@clisp.org>
-Date:   Sun Dec 12 21:13:54 2021 +0100
-
-    gnulib-tool: Support different basenames for the lib/,tests/ Makefiles.
-
-    * gnulib-tool: New option --tests-makefile-name.
-    (tests_makefile_name): New variable.
-    (func_import): Add support for --tests-makefile-name. Replace local
-    variable makefile_am with two local variables source_makefile_am,
-    tests_makefile_am.
-
---------------------------------------------------------------------------------
-
 commit 6ccfbd6495f2849b1aeea84f73327f6ced0080a7
 Author: Bruno Haible <bruno@clisp.org>
 Date:   Sun Aug 8 03:52:01 2021 +0200
index 1689e867b0c18acea576b1ff664d9ccb944cfa16..b0b59624b95fcb9f6c143e740c5a4237358f3f8a 100644 (file)
@@ -56,8 +56,8 @@ class GLConfig(object):
                  sourcebase=None, m4base=None, pobase=None, docbase=None, testsbase=None,
                  modules=None, avoids=None, files=None,
                  incl_test_categories=None, excl_test_categories=None, libname=None,
-                 lgpl=None, gnu_make=None, makefile_name=None, libtool=None,
-                 conddeps=None, macro_prefix=None,
+                 lgpl=None, gnu_make=None, makefile_name=None, tests_makefile_name=None,
+                 libtool=None, conddeps=None, macro_prefix=None,
                  podomain=None, witness_c_macro=None, vc_files=None, symbolic=None,
                  lsymbolic=None, configure_ac=None, ac_version=None,
                  libtests=None, single_configure=None, verbose=None, dryrun=None,
@@ -139,6 +139,10 @@ class GLConfig(object):
         self.resetMakefileName()
         if makefile_name != None:
             self.setMakefileName(makefile_name)
+        # tests_makefile_name
+        self.resetTestsMakefileName()
+        if tests_makefile_name != None:
+            self.setTestsMakefileName(tests_makefile_name)
         # libtool
         self.resetLibtool()
         if libtool != None:
@@ -839,13 +843,13 @@ class GLConfig(object):
 
     # Define makefile_name methods.
     def getMakefileName(self):
-        '''Return the name of makefile in automake syntax in the source-base and
-        tests-base directories. Default is 'Makefile.am'.'''
+        '''Return the name of makefile in automake syntax in the sourcebase directory.
+        Default is 'Makefile.am'.'''
         return self.table['makefile_name']
 
     def setMakefileName(self, makefile_name):
-        '''Specify the name of makefile in automake syntax in the source-base and
-        tests-base directories. Default is 'Makefile.am'.'''
+        '''Specify the name of makefile in automake syntax in the sourcebase directory.
+        Default is 'Makefile.am'.'''
         if type(makefile_name) is str:
             if makefile_name:
                 self.table['makefile_name'] = makefile_name
@@ -854,10 +858,31 @@ class GLConfig(object):
                             % type(makefile_name).__name__)
 
     def resetMakefileName(self):
-        '''Reset the name of makefile in automake syntax in the source-base and
-        tests-base directories. Default is 'Makefile.am'.'''
+        '''Reset the name of makefile in automake syntax in the sourcebase directory.
+        Default is 'Makefile.am'.'''
         self.table['makefile_name'] = ''
 
+    # Define tests_makefile_name methods.
+    def getTestsMakefileName(self):
+        '''Return the name of makefile in automake syntax in the testsbase directory.
+        Default is the the value of 'makefile_name'.'''
+        return self.table['tests_makefile_name']
+
+    def setTestsMakefileName(self, tests_makefile_name):
+        '''Specify the name of makefile in automake syntax in the testsbase directory.
+        Default is the value of 'makefile_name'.'''
+        if type(tests_makefile_name) is str:
+            if tests_makefile_name:
+                self.table['tests_makefile_name'] = tests_makefile_name
+        else:  # if type of tests_makefile_name is not str
+            raise TypeError('tests_makefile_name must be a string, not %s'
+                            % type(tests_makefile_name).__name__)
+
+    def resetTestsMakefileName(self):
+        '''Reset the name of makefile in automake syntax in the testsbase directory.
+        Default is the value of 'makefile_name'.'''
+        self.table['tests_makefile_name'] = ''
+
     # Define podomain methods.
     def getPoDomain(self):
         '''Return the prefix of the i18n domain. Usually use the package name.
index 5ffeaf26dc97dc06f2edf083c362607670fe4e48..24c6623293b19afd8430285ae67f6852183df6ce 100644 (file)
@@ -127,8 +127,8 @@ class GLImport(object):
                 [
                     'gl_LOCAL_DIR', 'gl_MODULES', 'gl_AVOID', 'gl_SOURCE_BASE',
                     'gl_M4_BASE', 'gl_PO_BASE', 'gl_DOC_BASE', 'gl_TESTS_BASE',
-                    'gl_MAKEFILE_NAME', 'gl_MACRO_PREFIX', 'gl_PO_DOMAIN',
-                    'gl_WITNESS_C_MACRO', 'gl_VC_FILES', 'gl_LIB',
+                    'gl_MAKEFILE_NAME', 'gl_TESTS_MAKEFILE_NAME', 'gl_MACRO_PREFIX',
+                    'gl_PO_DOMAIN', 'gl_WITNESS_C_MACRO', 'gl_VC_FILES', 'gl_LIB',
                 ]
 
             # Find bool values.
@@ -193,6 +193,8 @@ class GLImport(object):
                 self.cache.setTestsBase(cleaner(tempdict['gl_TESTS_BASE']))
             if tempdict['gl_MAKEFILE_NAME']:
                 self.cache.setMakefileName(cleaner(tempdict['gl_MAKEFILE_NAME']))
+            if tempdict['gl_TESTS_MAKEFILE_NAME']:
+                self.cache.setTestsMakefileName(cleaner(tempdict['gl_TESTS_MAKEFILE_NAME']))
             if tempdict['gl_MACRO_PREFIX']:
                 self.cache.setMacroPrefix(cleaner(tempdict['gl_MACRO_PREFIX']))
             if tempdict['gl_PO_DOMAIN']:
@@ -364,6 +366,7 @@ class GLImport(object):
         lgpl = self.config.getLGPL()
         gnu_make = self.config.getGnuMake()
         makefile_name = self.config.getMakefileName()
+        tests_makefile_name = self.config.getTestsMakefileName()
         libtool = self.config.checkLibtool()
         macro_prefix = self.config.getMacroPrefix()
         witness_c_macro = self.config.getWitnessCMacro()
@@ -413,8 +416,9 @@ class GLImport(object):
             actioncmd += ' \\\n#  --gnu-make'
         if makefile_name:
             actioncmd += ' \\\n#  --makefile-name=%s' % makefile_name
+        if tests_makefile_name:
+            actioncmd += ' \\\n#  --tests-makefile-name=%s' % tests_makefile_name
         # FIXME: Add the following options in this order when implemented.
-        # --tests-makefile-name
         # --automake-subdir
         # --automake-subdir-tests
         if conddeps:
@@ -491,6 +495,7 @@ class GLImport(object):
         lgpl = self.config['lgpl']
         libname = self.config['libname']
         makefile_name = self.config['makefile_name']
+        tests_makefile_name = self.config['tests_makefile_name']
         conddeps = self.config['conddeps']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
@@ -544,6 +549,8 @@ class GLImport(object):
             else:  # if lgpl != True
                 emit += 'gl_LGPL([%s])\n' % lgpl
         emit += 'gl_MAKEFILE_NAME([%s])\n' % makefile_name
+        if tests_makefile_name:
+            emit += 'gl_TESTS_MAKEFILE_NAME([%s])\n' % tests_makefile_name
         if conddeps:
             emit += 'gl_CONDITIONAL_DEPENDENCIES\n'
         if libtool:
@@ -976,6 +983,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         lgpl = self.config['lgpl']
         libname = self.config['libname']
         makefile_name = self.config['makefile_name']
+        tests_makefile_name = self.config['tests_makefile_name']
         conddeps = self.config['conddeps']
         libtool = self.config['libtool']
         macro_prefix = self.config['macro_prefix']
@@ -1080,11 +1088,16 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Determine include_guard_prefix.
         include_guard_prefix = self.config['include_guard_prefix']
 
-        # Determine makefile name.
-        if not makefile_name:
-            makefile_am = 'Makefile.am'
-        else:  # if makefile_name
-            makefile_am = makefile_name
+        # Default the source makefile name to Makefile.am.
+        if makefile_name:
+            source_makefile_am = makefile_name
+        else:
+            source_makefile_am = 'Makefile.am'
+        # Default the tests makefile name to the source makefile name.
+        if tests_makefile_name:
+            tests_makefile_am = tests_makefile_name
+        else:
+            tests_makefile_am = source_makefile_am
 
         # Create normal Makefile.ams.
         for_test = False
@@ -1093,7 +1106,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         # Some of these edits apply to files that we will generate; others are
         # under the responsibility of the developer.
         makefile_am_edits = dict()
-        if makefile_am == 'Makefile.am':
+        if source_makefile_am == 'Makefile.am':
             sourcebase_dir = os.path.dirname(sourcebase)
             sourcebase_base = os.path.basename(sourcebase)
             self.makefiletable.editor(sourcebase_dir, 'SUBDIRS', sourcebase_base)
@@ -1102,15 +1115,15 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
             pobase_base = os.path.basename(pobase)
             self.makefiletable.editor(pobase_dir, 'SUBDIRS', pobase_base)
         if self.config.checkInclTestCategory(TESTS['tests']):
-            if makefile_am == 'Makefile.am':
+            if tests_makefile_am == 'Makefile.am':
                 testsbase_dir = os.path.dirname(testsbase)
                 testsbase_base = os.path.basename(testsbase)
                 self.makefiletable.editor(testsbase_dir, 'SUBDIRS', testsbase_base, True)
         self.makefiletable.editor('', 'ACLOCAL_AMFLAGS', '-I %s' % m4base)
-        self.makefiletable.parent(gentests)
+        self.makefiletable.parent(gentests, source_makefile_am, tests_makefile_am)
 
         # Create library makefile.
-        basename = joinpath(sourcebase, makefile_am)
+        basename = joinpath(sourcebase, source_makefile_am)
         tmpfile = self.assistant.tmpfilename(basename)
         emit, uses_subdirs = self.emitter.lib_Makefile_am(basename,
                                                           self.moduletable['main'], self.moduletable, self.makefiletable,
@@ -1288,7 +1301,7 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
 
         # Create tests Makefile.
         if gentests:
-            basename = joinpath(testsbase, makefile_am)
+            basename = joinpath(testsbase, tests_makefile_am)
             tmpfile = self.assistant.tmpfilename(basename)
             emit, uses_subdirs = self.emitter.tests_Makefile_am(basename,
                                                                 self.moduletable['tests'], self.moduletable, self.makefiletable,
@@ -1391,17 +1404,17 @@ in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library.''')
         # Print reminders.
         print('')
         print('Don\'t forget to')
-        if makefile_am == 'Makefile.am':
+        if source_makefile_am == 'Makefile.am':
             print('  - add "%s/Makefile" to AC_CONFIG_FILES in %s,' % (sourcebase, configure_ac))
         else:  # if makefile_am != 'Makefile.am'
-            print('  - "include %s" from within "%s/Makefile.am",' % (makefile_name, sourcebase))
+            print('  - "include %s" from within "%s/Makefile.am",' % (source_makefile_am, sourcebase))
         if pobase:
             print('  - add "%s/Makefile.in to AC_CONFIG_FILES in %s,' % (pobase, configure_ac))
         if gentests:
-            if makefile_am == 'Makefile.am':
+            if tests_makefile_am == 'Makefile.am':
                 print('  - add "%s/Makefile" to AC_CONFIG_FILES in %s,' % (testsbase, configure_ac))
             else:  # if makefile_am != 'Makefile.am'
-                print('  - "include %s" from within "%s/Makefile.am",' % (makefile_name, testsbase))
+                print('  - "include %s" from within "%s/Makefile.am",' % (tests_makefile_am, testsbase))
         # Print makefile edits.
         current_edit = int()
         makefile_am_edits = self.makefiletable.count()
index 08edb9b38330d659834b24aab2f8f45c1b6b5b4c..4d5d621e917e96b6c8c54f8599343438dffb9ad4 100644 (file)
@@ -280,6 +280,9 @@ Options for --import, --add/remove-import:
       --makefile-name=NAME  Name of makefile in the source-base and tests-base
                             directories (default \"Makefile.am\", or
                             \"Makefile.in\" if --gnu-make).
+      --tests-makefile-name=NAME
+                            Name of makefile in the tests-base directory
+                            (default as specified through --makefile-name)
       --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 35f32685b54d213f5e1775d93f00ccfa75bc9a3c..fe2c8e3360df91d68988a82227fc9b29c1adbf4d 100644 (file)
@@ -80,32 +80,31 @@ class GLMakefileTable(object):
         dictionary = {'dir': dir, 'var': var, 'val': val, 'dotfirst': dotfirst}
         self.table += [dictionary]
 
-    def parent(self, gentests):
+    def parent(self, gentests, source_makefile_am, tests_makefile_am):
         '''GLMakefileTable.parent(gentests)
 
         Add a special row to Makefile.am table with the first parent directory
         which contains or will contain Makefile.am file.
         GLConfig: sourcebase, m4base, testsbase, incl_test_categories,
         excl_test_categories, makefile_name.
-        gentests is a bool that is True if any files are to be placed in $testsbase.'''
+        gentests is a bool that is True if any files are to be placed in $testsbase.
+        source_makefile_am is the name of the source Makefile.am.
+        tests_makefile_am is the name of the tests Makefile.am.'''
         if type(gentests) is not bool:
             raise TypeError('gentests must be a bool, not %s' % (type(gentests).__name__))
+        if type(source_makefile_am) is not str:
+            raise TypeError('source_makefile_am must be a str, not %s' % (type(source_makefile_am).__name__))
+        if type(tests_makefile_am) is not str:
+            raise TypeError('tests_makefile_am must be a str, not %s' % (type(tests_makefile_am).__name__))
         m4base = self.config['m4base']
         sourcebase = self.config['sourcebase']
         testsbase = self.config['testsbase']
-        makefile_name = self.config['makefile_name']
-        inctests = self.config.checkInclTestCategory(TESTS['tests'])
         dir1 = '%s%s' % (m4base, os.path.sep)
-        mfd = 'Makefile.am'
-        if not makefile_name:
-            mfx = 'Makefile.am'
-        else:  # if makefile_name
-            mfx = makefile_name
         dir2 = ''
         while (dir1
-               and (joinpath(self.config['destdir'], dir1, mfd)
-                    or joinpath(dir1, mfd) == joinpath(sourcebase, mfx)
-                    or (gentests and joinpath(dir1, mfd) == joinpath(testsbase, mfx)))):
+               and (joinpath(self.config['destdir'], dir1, 'Makefile.am')
+                    or joinpath(dir1, 'Makefile.am') == joinpath(sourcebase, source_makefile_am)
+                    or (gentests and joinpath(dir1, 'Makefile.am') == joinpath(testsbase, tests_makefile_am)))):
             dir2 = joinpath(os.path.basename(dir1), dir2)
             dir1 = os.path.dirname(dir1)
         self.editor(dir1, 'EXTRA_DIST', joinpath(dir2, 'gnulib-cache.m4'))
index f99062089b5794b01da5b2614ea3e47a4e0bc658..a76de2ffe0a95c8a1d499158193a0e5c6b307094 100644 (file)
@@ -385,6 +385,11 @@ def main():
                         dest='makefile_name',
                         default=None,
                         nargs=1)
+    # tests-makefile-name
+    parser.add_argument('--tests-makefile-name',
+                        dest='tests_makefile_name',
+                        default=None,
+                        nargs=1)
     # macro-prefix
     parser.add_argument('--macro-prefix',
                         dest='macro_prefix',
@@ -606,6 +611,7 @@ def main():
                  or cmdargs.excl_unportable_tests != None
                  or cmdargs.avoids != None or cmdargs.lgpl != None
                  or cmdargs.makefile_name != None
+                 or cmdargs.tests_makefile_name != 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']
@@ -700,6 +706,9 @@ def main():
     makefile_name = cmdargs.makefile_name
     if makefile_name != None:
         makefile_name = makefile_name[0]
+    tests_makefile_name = cmdargs.tests_makefile_name
+    if tests_makefile_name != None:
+        tests_makefile_name = tests_makefile_name[0]
     macro_prefix = cmdargs.macro_prefix
     if macro_prefix != None:
         macro_prefix = macro_prefix[0]
@@ -738,6 +747,7 @@ def main():
         lgpl=lgpl,
         gnu_make=gnu_make,
         makefile_name=makefile_name,
+        tests_makefile_name=tests_makefile_name,
         libtool=libtool,
         conddeps=cond_dependencies,
         macro_prefix=macro_prefix,