2026-06-01 10:04:38 +02:00
|
|
|
from __future__ import annotations
|
2026-06-01 09:18:34 +02:00
|
|
|
|
2026-06-30 11:26:52 +02:00
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
|
|
2026-06-01 09:18:34 +02:00
|
|
|
from ....lib.log import NOTICE, log
|
|
|
|
|
from .Cmd import Cmd, Parent
|
2026-06-01 10:04:38 +02:00
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from argparse import ArgumentParser, Namespace
|
2026-06-01 09:18:34 +02:00
|
|
|
|
|
|
|
|
class CmdDep(Cmd): # export
|
|
|
|
|
|
|
|
|
|
def __init__(self, parent: Parent) -> None:
|
|
|
|
|
super().__init__(
|
|
|
|
|
parent,
|
|
|
|
|
'deps',
|
|
|
|
|
help = 'Check for circular dependencies between given modules',
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def add_arguments(self, parser: ArgumentParser) -> None:
|
|
|
|
|
super().add_arguments(parser)
|
|
|
|
|
parser.add_argument('module', nargs = '*', help = 'Modules')
|
|
|
|
|
parser.add_argument('-f', '--flavour', nargs = '?', default = 'build')
|
|
|
|
|
|
|
|
|
|
async def _run(self, args: Namespace) -> None:
|
2026-06-30 11:26:52 +02:00
|
|
|
cycle = self.app.find_circular_deps(args.module, args.flavour)
|
|
|
|
|
if cycle:
|
|
|
|
|
log(
|
|
|
|
|
NOTICE,
|
|
|
|
|
f'Found circular dependency in flavour {args.flavour}: '
|
|
|
|
|
' -> '.join(cycle)
|
|
|
|
|
)
|
2026-06-01 09:18:34 +02:00
|
|
|
exit(1)
|
|
|
|
|
log(
|
|
|
|
|
NOTICE,
|
|
|
|
|
f'No circular dependency found for flavour {args.flavour} in modules:',
|
|
|
|
|
' '.join(args.module),
|
|
|
|
|
)
|