manifest: add ImportFlag.IGNORE_PROJECTS

This will be useful for relaxing 'west update PROJECT' behavior.

Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
Martí Bolívar 2020-01-30 11:41:13 -08:00 committed by Marti Bolivar
parent 55fbe61203
commit 295637d4d1
1 changed files with 20 additions and 1 deletions

View File

@ -129,11 +129,27 @@ class ImportFlag(enum.IntFlag):
- IGNORE: ignore all "import:" attributes in "self:" and "projects:" - IGNORE: ignore all "import:" attributes in "self:" and "projects:"
- FORCE_PROJECTS: always invoke importer callback for "projects:" imports - FORCE_PROJECTS: always invoke importer callback for "projects:" imports
- IGNORE_PROJECTS: ignore "import:" attributes in "projects:" only;
still respect "import:" in "self:"
''' '''
DEFAULT = 0 DEFAULT = 0
IGNORE = 1 IGNORE = 1
FORCE_PROJECTS = 2 FORCE_PROJECTS = 2
IGNORE_PROJECTS = 4
def _flags_ok(flags):
# Sanity-check the combination of flags.
F_I = ImportFlag.IGNORE
F_FP = ImportFlag.FORCE_PROJECTS
F_IP = ImportFlag.IGNORE_PROJECTS
if (flags & F_I) or (flags & F_IP):
return not (flags & F_FP)
elif flags & (F_FP | F_IP):
return (flags & F_FP) ^ (flags & F_IP)
else:
return True
class Manifest: class Manifest:
'''The parsed contents of a west manifest file. '''The parsed contents of a west manifest file.
@ -338,6 +354,8 @@ class Manifest:
''' '''
if source_file and source_data: if source_file and source_data:
raise ValueError('both source_file and source_data were given') raise ValueError('both source_file and source_data were given')
if not _flags_ok(import_flags):
raise ValueError(f'bad import_flags {import_flags:x}')
self.path = None self.path = None
'''Path to the file containing the manifest, or None if '''Path to the file containing the manifest, or None if
@ -766,7 +784,8 @@ class Manifest:
# Track project imports unless we are ignoring those. # Track project imports unless we are ignoring those.
imp = pd.get('import') imp = pd.get('import')
if imp: if imp:
if self._import_flags & ImportFlag.IGNORE: if self._import_flags & (ImportFlag.IGNORE |
ImportFlag.IGNORE_PROJECTS):
_logger.debug( _logger.debug(
f'project {project}: ignored import ({imp})') f'project {project}: ignored import ({imp})')
else: else: