summaryrefslogtreecommitdiff
path: root/pygnulib/GLModuleSystem.py
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2022-08-04 12:40:04 +0200
committerBruno Haible <bruno@clisp.org>2022-08-04 12:40:04 +0200
commit353460b98e53e4244379d5526a2de5f42301e227 (patch)
treee550022cd6aa25f12e5f5a1bd86faee72abb89b0 /pygnulib/GLModuleSystem.py
parente7101c252c537dd198af9329d861c353241bcb61 (diff)
downloadgnulib-353460b98e53e4244379d5526a2de5f42301e227.tar.gz
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.
Diffstat (limited to 'pygnulib/GLModuleSystem.py')
-rw-r--r--pygnulib/GLModuleSystem.py138
1 files changed, 71 insertions, 67 deletions
diff --git a/pygnulib/GLModuleSystem.py b/pygnulib/GLModuleSystem.py
index 7e4c6148e3..13352ffb5c 100644
--- a/pygnulib/GLModuleSystem.py
+++ b/pygnulib/GLModuleSystem.py
@@ -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):