Hi Bruno,

On 3/3/24 4:30 AM, Bruno Haible wrote:
> In the original commit, I removed the error message
> "option --conditional-dependencies is not supported with --with-tests"
> only at one place (the command-line option checks), but left it in 
> func_import.
> You are removing it in both places (mode == 'import' as well as mode != 
> 'import).

Sorry, I forgot about this. The error should only be removed in mode
== 'import' correct? I've attached a patch which should hopefully be
correct in that case. The check is still performed when mode !=
'import'.

Collin
From 5dd9572597ada0790d9b9d9911c433fd25dca092 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Mon, 4 Mar 2024 12:35: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 when mode is 'import'.
(GLImport.gnulib_comp): Pass it.
* pygnulib/GLTestDir.py (GLTestDir.execute): Pass it.
---
 ChangeLog             | 13 +++++++++++++
 gnulib-tool.py.TODO   | 16 ----------------
 pygnulib/GLEmiter.py  | 15 ++++++++-------
 pygnulib/GLImport.py  |  9 ++-------
 pygnulib/GLTestDir.py | 12 ++++++------
 5 files changed, 29 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c22d5ce9ff..e6393e213d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-03-04  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 when mode is 'import'.
+	(GLImport.gnulib_comp): Pass it.
+	* pygnulib/GLTestDir.py (GLTestDir.execute): Pass it.
+
 2024-03-04  Bruno Haible  <br...@clisp.org>
 
 	doc: Tweak last commit.
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 8939917a0a..9435b10666 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 referenceable 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/GLImport.py b/pygnulib/GLImport.py
index e18a9601ec..9cf9a96e30 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -253,11 +253,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 +646,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 +669,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)
-- 
2.44.0

Reply via email to