On 3/2/24 7:02 PM, Collin Funk wrote:
> When working on the one of the TODO entries I noticed that
> the gnulib-comp.m4 output was incorrect.
Here is the item I was working on. I _think_ I understood it correctly
but you guys are much more talented at shell than me. :)
Specifically, I was a bit confused at first by the
func_emit_autoconf_snippets function. The diff showed the following
change:
- for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
+ for m in $referenceable_modules; do echo $m; done | LC_ALL=C sort -u >
"$tmp"/modules
Which I didn't understand until seeing this line [1]:
deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join -
"$tmp"/modules`
This just means that join takes stdin as its first file which is the
piped output of sort. Then the second file is the sorted
referenceable_modules stored in "$tmp"/modules right?
If I am interpreting that correctly then the lines I used would be
correct I think:
depmodules = sorted(set(depmodules).intersection(referenceable_modules))
The merge-gnulib script output seems more correct than usual, but I
could be missing something.
[1]
https://git.savannah.gnu.org/cgit/gnulib.git/tree/gnulib-tool?id=589e96475f8f2d21a83405ab0672ce95091b80e5#n4296
Collin
From bf4cfc143601f17133238a32de68ca033fa1b757 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 2 Mar 2024 21:02:15 -0800
Subject: [PATCH] gnulib-tool.py: Follow gnulib-tool changes, part 39.
Follow gnulib-tool change
2017-12-28 Bruno Haible <br...@clisp.org>
gnulib-tool: Make --conditional-dependencies work better.
* pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Add argument
referenceable_modules. Use referencable_modules for dependencies.
* pygnulib/GLImport.py (GLImport.__init__): Don't reject the combination
of --conditional-dependencies with --with-tests.
(GLImport.gnulib_comp): Pass it.
* pygnulib/GLTestDir.py (GLTestDir.execute): Pass it.
* pygnulib/GLError.py (GLError.__repr__): Remove unused errno.
* pygnulib/main.py: Likewise.
---
ChangeLog | 15 +++++++++++++++
gnulib-tool.py.TODO | 16 ----------------
pygnulib/GLEmiter.py | 15 ++++++++-------
pygnulib/GLError.py | 2 --
pygnulib/GLImport.py | 13 ++-----------
pygnulib/GLTestDir.py | 12 ++++++------
pygnulib/main.py | 2 --
7 files changed, 31 insertions(+), 44 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 19b308e552..72723e31ef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-03-02 Collin Funk <collin.fu...@gmail.com>
+
+ gnulib-tool.py: Follow gnulib-tool changes, part 39.
+ Follow gnulib-tool change
+ 2017-12-28 Bruno Haible <br...@clisp.org>
+ gnulib-tool: Make --conditional-dependencies work better.
+ * pygnulib/GLEmiter.py (GLEmiter.autoconfSnippets): Add argument
+ referenceable_modules. Use referencable_modules for dependencies.
+ * pygnulib/GLImport.py (GLImport.__init__): Don't reject the combination
+ of --conditional-dependencies with --with-tests.
+ (GLImport.gnulib_comp): Pass it.
+ * pygnulib/GLTestDir.py (GLTestDir.execute): Pass it.
+ * pygnulib/GLError.py (GLError.__repr__): Remove unused errno.
+ * pygnulib/main.py: Likewise.
+
2024-03-02 Collin Funk <collin.fu...@gmail.com>
gnulib-tool.py: Fix output of gnulib-comp.m4.
diff --git a/gnulib-tool.py.TODO b/gnulib-tool.py.TODO
index babf3abb10..1cb436d90d 100644
--- a/gnulib-tool.py.TODO
+++ b/gnulib-tool.py.TODO
@@ -688,22 +688,6 @@ Date: Mon Sep 3 21:19:16 2018 +0200
--------------------------------------------------------------------------------
-commit 589e96475f8f2d21a83405ab0672ce95091b80e5
-Author: Bruno Haible <br...@clisp.org>
-Date: Fri Dec 29 00:29:23 2017 +0100
-
- gnulib-tool: Make --conditional-dependencies work better.
-
- Reported by Dmitry Selyutin <ghostman...@gmail.com>.
-
- * gnulib-tool (Options): Don't reject the combination of
- --conditional-dependencies with --with-tests.
- (func_emit_autoconf_snippets): Add argument referenceable_modules.
- Don't reference $modules.
- (func_import, func_create_testdir): Pass it.
-
---------------------------------------------------------------------------------
-
commit cd58dba367a3b8ffbebb23f2099a820106197fae
Author: Bruno Haible <br...@clisp.org>
Date: Sun Oct 29 16:57:32 2017 +0100
diff --git a/pygnulib/GLEmiter.py b/pygnulib/GLEmiter.py
index 7f850b8dec..83e84b665c 100644
--- a/pygnulib/GLEmiter.py
+++ b/pygnulib/GLEmiter.py
@@ -178,7 +178,7 @@ class GLEmiter(object):
emit = '%s\n' % '\n'.join(lines)
return emit
- def autoconfSnippets(self, modules, moduletable,
+ def autoconfSnippets(self, modules, referenceable_modules, moduletable,
verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir):
'''GLEmiter.autoconfSnippets(modules,
verifier, toplevel, disable_libtool, disable_gettext, replace_auxdir) -> str
@@ -191,6 +191,8 @@ class GLEmiter(object):
modules after they were processed.
modules argument represents list of modules; every module in this list must
be a GLModule instance.
+ referenceable_modules is the list of modules which may be referenced as
+ dependencies.
moduletable is a GLModuleTable instance, which contains necessary
information about dependencies of the modules.
verifier is an integer, which can be 0, 1 or 2.
@@ -207,6 +209,9 @@ class GLEmiter(object):
for module in modules:
if type(module) is not GLModule:
raise TypeError('each module must be a GLModule instance')
+ for module in referenceable_modules:
+ if type(module) is not GLModule:
+ raise TypeError('each referencable module must be a GLModule instance')
if type(moduletable) is not GLModuleTable:
raise TypeError('moduletable must be a GLFileAssistant, not %s'
% type(moduletable).__name__)
@@ -290,9 +295,7 @@ class GLEmiter(object):
emit += ' %s=true\n' % shellvar
depmodules = module.getDependenciesWithoutConditions()
# Intersect dependencies with the modules list.
- depmodules = [ dep
- for dep in depmodules
- if dep in modules ] # TODO should this be basemodules or modules?
+ depmodules = sorted(set(depmodules).intersection(referenceable_modules))
for depmodule in depmodules:
if moduletable.isConditional(depmodule):
shellfunc = depmodule.getShellFunc()
@@ -322,9 +325,7 @@ class GLEmiter(object):
if not moduletable.isConditional(module):
depmodules = module.getDependenciesWithoutConditions()
# Intersect dependencies with the modules list.
- depmodules = [ dep
- for dep in depmodules
- if dep in modules ] # TODO should this be basemodules or modules?
+ depmodules = sorted(set(depmodules).intersection(referenceable_modules))
for depmodule in depmodules:
if moduletable.isConditional(depmodule):
shellfunc = depmodule.getShellFunc()
diff --git a/pygnulib/GLError.py b/pygnulib/GLError.py
index 5c7420e8b1..eb6c732103 100644
--- a/pygnulib/GLError.py
+++ b/pygnulib/GLError.py
@@ -89,8 +89,6 @@ class GLError(Exception):
message = "missing testsbase argument; cache file doesn't contain it, so you might have to set this argument"
elif errno == 9:
message = "missing libname argument; cache file doesn't contain it, so you might have to set this argument"
- elif errno == 10:
- message = "conddeps are not supported with inctests"
elif errno == 11:
message = "incompatible licenses on modules: %s" % repr(errinfo)
elif errno == 12:
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index e18a9601ec..ce39d0f37e 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -241,10 +241,6 @@ class GLImport(object):
elif self.mode == MODES['update']:
modules = self.cache.getModules()
- # If user tries to apply conddeps and TESTS['tests'] together.
- if self.config.checkInclTestCategory(TESTS['tests']) and self.config['conddeps']:
- raise GLError(10, None)
-
# Update configuration dictionary.
self.config.update(self.cache)
for key in config.keys():
@@ -253,11 +249,6 @@ class GLImport(object):
self.config.update_key(config, key)
self.config.setModules(modules)
- # Check if conddeps is enabled together with inctests.
- inctests = self.config.checkInclTestCategory(TESTS['tests'])
- if self.config['conddeps'] and inctests:
- raise GLError(10, None)
-
# Define GLImport attributes.
self.emitter = GLEmiter(self.config)
self.filesystem = GLFileSystem(self.config)
@@ -651,7 +642,7 @@ AC_DEFUN([%s_INIT],
if witness_c_macro:
emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [%s])\n' % witness_c_macro
# Emit main autoconf snippets.
- emit += self.emitter.autoconfSnippets(moduletable['main'],
+ emit += self.emitter.autoconfSnippets(moduletable['main'], moduletable['main'],
moduletable, 0, True, False, True, replace_auxdir)
if witness_c_macro:
emit += ' m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
@@ -674,7 +665,7 @@ AC_DEFUN([%s_INIT],
emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], '
emit += '[$gl_module_indicator_condition])\n'
# Emit tests autoconf snippets.
- emit += self.emitter.autoconfSnippets(moduletable['tests'],
+ emit += self.emitter.autoconfSnippets(moduletable['tests'], moduletable['main'] + moduletable['tests'],
moduletable, 0, True, True, True, replace_auxdir)
emit += ' m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
emit += self.emitter.initmacro_end('%stests' % macro_prefix)
diff --git a/pygnulib/GLTestDir.py b/pygnulib/GLTestDir.py
index 51c3f7a944..5f290c30c3 100644
--- a/pygnulib/GLTestDir.py
+++ b/pygnulib/GLTestDir.py
@@ -470,11 +470,11 @@ class GLTestDir(object):
# autoconf snippets. It's cleanest to put those of the library before
# those of the tests.
emit += "gl_source_base='../%s'\n" % sourcebase
- emit += self.emitter.autoconfSnippets(modules,
+ emit += self.emitter.autoconfSnippets(modules, modules,
moduletable, 1, False, False, False,
replace_auxdir)
emit += "gl_source_base='.'"
- emit += self.emitter.autoconfSnippets(modules,
+ emit += self.emitter.autoconfSnippets(modules, modules,
moduletable, 2, False, False, False,
replace_auxdir)
emit += self.emitter.initmacro_end(macro_prefix)
@@ -588,10 +588,10 @@ class GLTestDir(object):
emit += self.emitter.initmacro_start(macro_prefix)
emit += 'gl_source_base=\'%s\'\n' % sourcebase
if single_configure:
- emit += self.emitter.autoconfSnippets(main_modules, moduletable,
+ emit += self.emitter.autoconfSnippets(main_modules, main_modules, moduletable,
0, False, False, False, replace_auxdir)
else: # if not single_configure
- emit += self.emitter.autoconfSnippets(modules, moduletable,
+ emit += self.emitter.autoconfSnippets(modules, modules, moduletable,
1, False, False, False, replace_auxdir)
emit += self.emitter.initmacro_end(macro_prefix)
if single_configure:
@@ -605,8 +605,8 @@ class GLTestDir(object):
emit += ' gl_module_indicator_condition=$%stests_WITNESS\n' % macro_prefix
emit += ' m4_pushdef([gl_MODULE_INDICATOR_CONDITION], '
emit += '[$gl_module_indicator_condition])\n'
- snippets = self.emitter.autoconfSnippets(tests_modules, moduletable,
- 1, True, False, False, replace_auxdir)
+ snippets = self.emitter.autoconfSnippets(tests_modules, main_modules + tests_modules,
+ moduletable, 1, True, False, False, replace_auxdir)
emit += snippets.strip()
emit += ' m4_popdef([gl_MODULE_INDICATOR_CONDITION])\n'
emit += self.emitter.initmacro_end('%stests' % macro_prefix)
diff --git a/pygnulib/main.py b/pygnulib/main.py
index f99062089b..6903b2ec8c 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -1228,8 +1228,6 @@ if __name__ == '__main__':
message += 'missing --tests-base option'
elif errno == 9:
message += 'missing --lib option'
- elif errno == 10:
- message = 'gnulib-tool: option --conditional-dependencies is not supported with --with-tests'
elif errno == 11:
incompatibilities = ''
message += 'incompatible license on modules:%s' % constants.NL
--
2.44.0