summaryrefslogtreecommitdiff
path: root/pygnulib
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
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')
-rw-r--r--pygnulib/GLImport.py7
-rw-r--r--pygnulib/GLModuleSystem.py138
2 files changed, 72 insertions, 73 deletions
diff --git a/pygnulib/GLImport.py b/pygnulib/GLImport.py
index 58b8eaab9f..28bef1d9f3 100644
--- a/pygnulib/GLImport.py
+++ b/pygnulib/GLImport.py
@@ -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']
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):