From 6038b3fadb3bb9018a5053ebd842260e46e43598 Mon Sep 17 00:00:00 2001 From: Collin Funk Date: Wed, 6 Mar 2024 21:49:21 -0800 Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 45. Follow gnulib-tool changes 2021-12-12 Bruno Haible gnulib-tool: Support different basenames for the lib/,tests/ Makefiles. 2022-01-08 Bruno Haible 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 | 30 +++++++++++++++++++++++ gnulib-tool.py.TODO | 24 ------------------- pygnulib/GLConfig.py | 41 +++++++++++++++++++++++++------- pygnulib/GLImport.py | 47 +++++++++++++++++++++++-------------- pygnulib/GLInfo.py | 3 +++ pygnulib/GLMakefileTable.py | 23 +++++++++--------- pygnulib/main.py | 10 ++++++++ 7 files changed, 117 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9666d65ba2..cd8fa303bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2024-03-07 Collin Funk + + gnulib-tool.py: Follow gnulib-tool changes, part 45. + Follow gnulib-tool changes + 2021-12-12 Bruno Haible + gnulib-tool: Support different basenames for the lib/,tests/ Makefiles. + 2022-01-08 Bruno Haible + 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 gnulib-tool: Search for a working 'join' program. diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO index 8548013005..a78335e6fd 100644 --- a/gnulib-tool.py.TODO +++ b/gnulib-tool.py.TODO @@ -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 -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 -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 Date: Sun Aug 8 03:52:01 2021 +0200 diff --git a/pygnulib/GLConfig.py b/pygnulib/GLConfig.py index 1689e867b0..b0b59624b9 100644 --- a/pygnulib/GLConfig.py +++ b/pygnulib/GLConfig.py @@ -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. diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py index 5ffeaf26dc..24c6623293 100644 --- a/pygnulib/GLImport.py +++ b/pygnulib/GLImport.py @@ -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 _a_LDFLAGS or _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() diff --git a/pygnulib/GLInfo.py b/pygnulib/GLInfo.py index 08edb9b383..4d5d621e91 100644 --- a/pygnulib/GLInfo.py +++ b/pygnulib/GLInfo.py @@ -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 diff --git a/pygnulib/GLMakefileTable.py b/pygnulib/GLMakefileTable.py index 35f32685b5..fe2c8e3360 100644 --- a/pygnulib/GLMakefileTable.py +++ b/pygnulib/GLMakefileTable.py @@ -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')) diff --git a/pygnulib/main.py b/pygnulib/main.py index f99062089b..a76de2ffe0 100644 --- a/pygnulib/main.py +++ b/pygnulib/main.py @@ -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, -- 2.39.5