cmds.projects.CmdBuild: Annotate types
CmdBuild lacks consistent type annotation, add that.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
40eac92333
commit
9623870f9a
1 changed files with 29 additions and 30 deletions
|
|
@ -1,15 +1,16 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
|
||||
from functools import lru_cache
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...App import Scope
|
||||
from ...lib.log import DEBUG, ERR, NOTICE, log
|
||||
from ...lib.util import get_profile_env, pretty_cmd
|
||||
from .Cmd import Cmd, Parent
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from argparse import ArgumentParser, Namespace
|
||||
|
|
@ -150,7 +151,9 @@ class CmdBuild(Cmd): # export
|
|||
dep_tree[k].remove(d)
|
||||
return 1
|
||||
|
||||
async def run_make(module, target, cur_project, num_projects) -> None:
|
||||
async def run_make(
|
||||
module: str, target: str, cur_project: int, num_projects: int
|
||||
) -> None:
|
||||
|
||||
patt = self.app.is_excluded_from_build(module)
|
||||
if patt is not None:
|
||||
|
|
@ -194,45 +197,44 @@ class CmdBuild(Cmd): # export
|
|||
except Exception as e:
|
||||
log(
|
||||
ERR,
|
||||
(
|
||||
f'Failed to make target "{target}" in module "{module}" '
|
||||
f'below base {self.app.projs_root}: {str(e)}'
|
||||
),
|
||||
f'Failed to make target "{target}" in module "{module}" '
|
||||
f'below base {self.app.projs_root}: {str(e)}'
|
||||
)
|
||||
raise
|
||||
|
||||
async def run_make_on_modules(modules, order, target):
|
||||
async def run_make_on_modules(
|
||||
modules: set[str], order: list[str], target: str
|
||||
) -> None:
|
||||
cur_project = 0
|
||||
num_projects = len(order)
|
||||
if target in ['clean', 'distclean']:
|
||||
for m in reversed(order):
|
||||
cur_project += 1
|
||||
await run_make(m, target, cur_project, num_projects)
|
||||
if m in modules:
|
||||
modules.remove(m)
|
||||
if not len(modules):
|
||||
log(NOTICE, 'All modules cleaned')
|
||||
return
|
||||
else:
|
||||
if target not in ['clean', 'distclean']:
|
||||
for m in order:
|
||||
cur_project += 1
|
||||
await run_make(m, target, cur_project, num_projects)
|
||||
return
|
||||
for m in reversed(order):
|
||||
cur_project += 1
|
||||
await run_make(m, target, cur_project, num_projects)
|
||||
if m in modules:
|
||||
modules.remove(m)
|
||||
if not len(modules):
|
||||
log(NOTICE, 'All modules cleaned')
|
||||
|
||||
async def run(args):
|
||||
async def run(args) -> None:
|
||||
|
||||
log(DEBUG, f'-------------------------------------- running {pretty_cmd()}')
|
||||
|
||||
modules = args.modules
|
||||
exclude = args.exclude.split()
|
||||
modules = set(args.modules)
|
||||
exclude = set(args.exclude.split())
|
||||
target = args.target
|
||||
|
||||
env_exclude = os.getenv('BUILD_EXCLUDE', '')
|
||||
if len(env_exclude):
|
||||
log(NOTICE, 'Exluding modules from environment: ' + env_exclude)
|
||||
exclude += ' ' + env_exclude
|
||||
if env_exclude is not None:
|
||||
log(NOTICE, f'Exluding modules from environment: {env_exclude}')
|
||||
exclude |= set(env_exclude.split())
|
||||
|
||||
# -- build
|
||||
order = []
|
||||
order: list[str] = []
|
||||
|
||||
glob_prereq_types = ['build']
|
||||
if re.match('pkg-.*', target) is not None:
|
||||
|
|
@ -251,7 +253,7 @@ class CmdBuild(Cmd): # export
|
|||
exit(0)
|
||||
|
||||
cur_project = 0
|
||||
log(NOTICE, 'Building target %s in %d projects:' % (target, len(order)))
|
||||
log(NOTICE, f'Building target {target} in {len(order)} projects:')
|
||||
for m in order:
|
||||
cur_project += 1
|
||||
log(NOTICE, ' %3d %s' % (cur_project, m))
|
||||
|
|
@ -263,12 +265,9 @@ class CmdBuild(Cmd): # export
|
|||
|
||||
log(
|
||||
NOTICE,
|
||||
(
|
||||
'Build done at %s' %
|
||||
(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
),
|
||||
'Build done at %s' %
|
||||
(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
|
||||
)
|
||||
|
||||
dep_cache: dict[str, dict[str, list[str]]] = {}
|
||||
|
||||
await run(args)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue