]> Savannah Git Hosting - gnulib.git/commitdiff
gnulib-tool.py: Implement option --avoid.
authorBruno Haible <bruno@clisp.org>
Thu, 4 Aug 2022 10:40:04 +0000 (12:40 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 4 Aug 2022 10:40:04 +0000 (12:40 +0200)
* pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Compute the
effective avoids list here.
(GLModuleTable.transitive_closure, GLModuleTable.add_dummy): Consider
the avoids list.
* pygnulib/GLImport.py (GLImport.gnulib_cache): Use the avoids list from
GLConfig directly.
(GLImport.prepare): No need any more to set the avoids list in the
GLModuleTable.

ChangeLog
pygnulib/GLImport.py
pygnulib/GLModuleSystem.py

index 705722bd14cd1ecb49f6510ccc5dc705795d96fe..2b2988c6bbdf6af715aed30470ad779a07d0f123 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2022-08-04  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool.py: Implement option --avoid.
+       * pygnulib/GLModuleSystem.py (GLModuleTable.__init__): Compute the
+       effective avoids list here.
+       (GLModuleTable.transitive_closure, GLModuleTable.add_dummy): Consider
+       the avoids list.
+       * pygnulib/GLImport.py (GLImport.gnulib_cache): Use the avoids list from
+       GLConfig directly.
+       (GLImport.prepare): No need any more to set the avoids list in the
+       GLModuleTable.
+
        gnulib-tool.py: Make --with/--without-*-tests handling a little safer.
        * pygnulib/GLConfig.py (__init__): Fix reset* invocations.
        setInclTestCategories, setExclTestCategories): Revert to old value if
index 58b8eaab9fa8e200c9aa707f9a3fd40323ffb328..28bef1d9f31511640d45113bb47062e69ac50ab8 100644 (file)
@@ -494,7 +494,7 @@ class GLImport(object):
         witness_c_macro = self.config['witness_c_macro']
         vc_files = self.config['vc_files']
         modules = [str(module) for module in moduletable['base']]
-        avoids = [str(avoid) for avoid in moduletable['avoids']]
+        avoids = self.config['avoids']
         emit += self.emiter.copyright_notice()
         emit += '''#
 # This file represents the specification of how gnulib-tool is used.
@@ -578,7 +578,6 @@ class GLImport(object):
         vc_files = self.config['vc_files']
         libtests = self.config['libtests']
         modules = [str(module) for module in moduletable['base']]
-        avoids = [str(avoid) for avoid in moduletable['avoids']]
         emit += '# DO NOT EDIT! GENERATED AUTOMATICALLY!\n'
         emit += self.emiter.copyright_notice()
         emit += '''#
@@ -762,7 +761,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         destdir = self.config['destdir']
         auxdir = self.config['auxdir']
         modules = list(self.config['modules'])
-        avoids = list(self.config['avoids'])
         sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
         pobase = self.config['pobase']
@@ -783,10 +781,8 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         verbose = self.config['verbosity']
         base_modules = sorted(
             set([self.modulesystem.find(m) for m in modules]))
-        avoids = sorted(set([self.modulesystem.find(a) for a in avoids]))
 
         # Perform transitive closure.
-        self.moduletable.setAvoids(avoids)
         final_modules = self.moduletable.transitive_closure(base_modules)
 
         # Show final module list.
@@ -1001,7 +997,6 @@ AC_DEFUN([%s_FILE_LIST], [\n''' % macro_prefix
         destdir = self.config['destdir']
         auxdir = self.config['auxdir']
         modules = list(self.config['modules'])
-        avoids = list(self.config['avoids'])
         sourcebase = self.config['sourcebase']
         m4base = self.config['m4base']
         pobase = self.config['pobase']
index 7e4c6148e3b9992ce2fe3f548597a37b10071f09..13352ffb5c970a26241441e57e8964adb84e8b86 100644 (file)
@@ -896,17 +896,18 @@ class GLModuleTable(object):
             raise TypeError('config must be a GLConfig, not %s' %
                             type(config).__name__)
         self.config = config
+        self.filesystem = GLFileSystem(self.config)
+        self.modulesystem = GLModuleSystem(self.config)
         if type(inc_all_direct_tests) is not bool:
             raise TypeError('inc_all_direct_tests must be a bool, not %s' %
                             type(inc_all_direct_tests).__name__)
         self.inc_all_direct_tests = inc_all_direct_tests
         self.inc_all_indirect_tests = inc_all_indirect_tests
         self.avoids = list()  # Avoids
-        for avoid in self.avoids:
-            if type(avoid) is not GLModule:
-                raise TypeError('each avoid must be a GLModule instance')
-        self.filesystem = GLFileSystem(self.config)
-        self.modulesystem = GLModuleSystem(self.config)
+        for avoid in self.config.getAvoids():
+            module = self.modulesystem.find(avoid)
+            if module:
+                self.avoids.append(module)
 
     def __repr__(self):
         '''x.__repr__() <==> repr(x)'''
@@ -1007,72 +1008,74 @@ class GLModuleTable(object):
         outmodules = list()
         if self.config['conddeps']:
             for module in modules:
-                self.addUnconditional(module)
+                if module not in self.avoids:
+                    self.addUnconditional(module)
         while inmodules:
             inmodules_this_round = inmodules
             inmodules = list()
             for module in inmodules_this_round:
-                outmodules += [module]
-                if self.config['conddeps']:
-                    automake_snippet = \
-                        module.getAutomakeSnippet_Conditional()
-                    pattern = compiler('^if')
-                    if not pattern.findall(automake_snippet):
-                        self.addUnconditional(module)
-                    conditional = self.isConditional(module)
-                dependencies = module.getDependencies()
-                depmodules = [pair[0] for pair in dependencies]
-                conditions = [pair[1] for pair in dependencies]
-                if self.config.checkInclTestCategory(TESTS['tests']):
-                    testsname = module.getTestsName()
-                    if self.modulesystem.exists(testsname):
-                        testsmodule = self.modulesystem.find(testsname)
-                        depmodules += [testsmodule]
-                        conditions += [None]
-                for depmodule in depmodules:
-                    include = True
-                    status = depmodule.getStatus()
-                    for word in status:
-                        if word == 'obsolete':
-                            if not self.config.checkInclTestCategory(TESTS['obsolete']):
-                                include = False
-                        elif word == 'c++-test':
-                            if self.config.checkExclTestCategory(TESTS['c++-test']):
-                                include = False
-                            if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['c++-test'])):
-                                include = False
-                        elif word == 'longrunning-test':
-                            if self.config.checkExclTestCategory(TESTS['longrunning-test']):
-                                include = False
-                            if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['longrunning-test'])):
-                                include = False
-                        elif word == 'privileged-test':
-                            if self.config.checkExclTestCategory(TESTS['privileged-test']):
-                                include = False
-                            if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['privileged-test'])):
-                                include = False
-                        elif word == 'unportable-test':
-                            if self.config.checkExclTestCategory(TESTS['unportable-test']):
-                                include = False
-                            if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['unportable-test'])):
-                                include = False
-                        elif word.endswith('-test'):
-                            if not inc_all_tests:
-                                include = False
-                    if include and depmodule not in self.avoids:
-                        inmodules += [depmodule]
-                        if self.config['conddeps']:
-                            index = depmodules.index(depmodule)
-                            condition = conditions[index]
-                            if condition:
-                                self.addConditional(
-                                    module, depmodule, condition)
-                            else:  # if condition
-                                if conditional:
+                if module not in self.avoids:
+                    outmodules += [module]
+                    if self.config['conddeps']:
+                        automake_snippet = \
+                            module.getAutomakeSnippet_Conditional()
+                        pattern = compiler('^if')
+                        if not pattern.findall(automake_snippet):
+                            self.addUnconditional(module)
+                        conditional = self.isConditional(module)
+                    dependencies = module.getDependencies()
+                    depmodules = [pair[0] for pair in dependencies]
+                    conditions = [pair[1] for pair in dependencies]
+                    if self.config.checkInclTestCategory(TESTS['tests']):
+                        testsname = module.getTestsName()
+                        if self.modulesystem.exists(testsname):
+                            testsmodule = self.modulesystem.find(testsname)
+                            depmodules += [testsmodule]
+                            conditions += [None]
+                    for depmodule in depmodules:
+                        include = True
+                        status = depmodule.getStatus()
+                        for word in status:
+                            if word == 'obsolete':
+                                if not self.config.checkInclTestCategory(TESTS['obsolete']):
+                                    include = False
+                            elif word == 'c++-test':
+                                if self.config.checkExclTestCategory(TESTS['c++-test']):
+                                    include = False
+                                if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['c++-test'])):
+                                    include = False
+                            elif word == 'longrunning-test':
+                                if self.config.checkExclTestCategory(TESTS['longrunning-test']):
+                                    include = False
+                                if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['longrunning-test'])):
+                                    include = False
+                            elif word == 'privileged-test':
+                                if self.config.checkExclTestCategory(TESTS['privileged-test']):
+                                    include = False
+                                if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['privileged-test'])):
+                                    include = False
+                            elif word == 'unportable-test':
+                                if self.config.checkExclTestCategory(TESTS['unportable-test']):
+                                    include = False
+                                if not (inc_all_tests or self.config.checkInclTestCategory(TESTS['unportable-test'])):
+                                    include = False
+                            elif word.endswith('-test'):
+                                if not inc_all_tests:
+                                    include = False
+                        if include and depmodule not in self.avoids:
+                            inmodules += [depmodule]
+                            if self.config['conddeps']:
+                                index = depmodules.index(depmodule)
+                                condition = conditions[index]
+                                if condition:
                                     self.addConditional(
-                                        module, depmodule, True)
-                                else:  # if not conditional
-                                    self.addUnconditional(module)
+                                        module, depmodule, condition)
+                                else:  # if condition
+                                    if conditional:
+                                        self.addConditional(
+                                            module, depmodule, True)
+                                    else:  # if not conditional
+                                        self.addUnconditional(module)
             listing = list()  # Create empty list
             inmodules = sorted(set(inmodules))
             handledmodules = sorted(set(handledmodules + inmodules_this_round))
@@ -1146,7 +1149,8 @@ class GLModuleTable(object):
                         break
         if not have_lib_sources:
             dummy = self.modulesystem.find('dummy')
-            modules = sorted(set(modules + [dummy]))
+            if dummy not in self.avoids:
+                modules = sorted(set(modules + [dummy]))
         return list(modules)
 
     def filelist(self, modules):