cmds.projects.BaseCmdPkgRelations: Support --skip-excluded

In a push to eventually merge class CmdRequiredOsPkg into this class,
add the --skip-excluded option required by it.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-03-15 14:19:32 +01:00
commit 489652a02f

View file

@ -5,6 +5,7 @@ from argparse import Namespace, ArgumentParser
from enum import Enum, auto from enum import Enum, auto
from ...lib.log import * from ...lib.log import *
from ...App import Scope
from ..Cmd import Cmd from ..Cmd import Cmd
from ..CmdProjects import CmdProjects from ..CmdProjects import CmdProjects
@ -30,6 +31,7 @@ class BaseCmdPkgRelations(Cmd):
dont_expand_version_macros: bool=False, dont_expand_version_macros: bool=False,
ignore: set[str] = set(), ignore: set[str] = set(),
quote: bool = False, quote: bool = False,
skip_excluded: bool = False,
) -> list[str]: ) -> list[str]:
if subsections is None: if subsections is None:
@ -42,6 +44,11 @@ class BaseCmdPkgRelations(Cmd):
if syntax == self.Syntax.debian: if syntax == self.Syntax.debian:
expand_semver_revision_range = True expand_semver_revision_range = True
if skip_excluded:
excluded = self.app.get_project_refs(modules, ['build'], 'exclude',
scope = Scope.One, add_self=False, names_only=True)
ignore |= set(excluded)
log(DEBUG, f'flavours="{", ".join(flavours)}", subsecs="{", ".join(subsecs)}", "ignore="{", ".join(ignore)}"') log(DEBUG, f'flavours="{", ".join(flavours)}", subsecs="{", ".join(subsecs)}", "ignore="{", ".join(ignore)}"')
version_pattern = re.compile("[0-9-.]*") version_pattern = re.compile("[0-9-.]*")
@ -150,6 +157,7 @@ class BaseCmdPkgRelations(Cmd):
dont_expand_version_macros = args.dont_expand_version_macros, dont_expand_version_macros = args.dont_expand_version_macros,
ignore = set(args.ignore.split(',')), ignore = set(args.ignore.split(',')),
quote = args.quote, quote = args.quote,
skip_excluded = args.skip_excluded,
) )
) )
@ -180,6 +188,8 @@ class BaseCmdPkgRelations(Cmd):
default=False, help='Don\'t expand VERSION and REVISION macros') default=False, help='Don\'t expand VERSION and REVISION macros')
parser.add_argument('--ignore', nargs='?', default='', help='Packages that ' parser.add_argument('--ignore', nargs='?', default='', help='Packages that '
'should be ignored together with their dependencies') 'should be ignored together with their dependencies')
parser.add_argument('--skip-excluded', action='store_true', default=False,
help='Don\'t consider or output modules matching the os cascade in their [build].exclude config')
parser.add_argument('--quote', action='store_true', default=False, parser.add_argument('--quote', action='store_true', default=False,
help='Put double quotes around each listed dependency') help='Put double quotes around each listed dependency')