mirror of
ssh://git.janware.com/janware/proj/jw-pkg
synced 2026-04-25 09:35:54 +02:00
jw.pkg.App: Code beautification
Major - but not yet sufficient - code beautification starting from
jw.pkg.App.
- Make more methods private
- Rename methods to be more self-explanatory
- Same for method arguments, notably clean up some inconsistent
uses of "module" vs "project"
- Add more type hints
Fix API breakage in the command modules.
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
2bbf5bd8e7
commit
6ca4af77d7
12 changed files with 204 additions and 209 deletions
|
|
@ -37,7 +37,7 @@ class CmdBuild(Cmd): # export
|
|||
else:
|
||||
dep_cache[prereq_type]: dict[str, str] = {}
|
||||
|
||||
ret = self.app.get_modules_from_project_txt([ cur ], ['pkg.requires.jw'],
|
||||
ret = self.app.get_project_refs([ cur ], ['pkg.requires.jw'],
|
||||
prereq_type, scope = Scope.Subtree, add_self=False, names_only=True)
|
||||
log(DEBUG, 'prerequisites = ' + ' '.join(ret))
|
||||
if cur in ret:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdCflags(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'build',
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], 'build',
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
out = []
|
||||
for m in reversed(deps):
|
||||
|
|
|
|||
|
|
@ -17,19 +17,8 @@ class CmdCheck(Cmd): # export
|
|||
parser.add_argument('-f', '--flavour', nargs='?', default = 'build')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
graph = {}
|
||||
path = []
|
||||
self.app.read_dep_graph(args.module, args.flavour, graph)
|
||||
unvisited = list(graph.keys())
|
||||
temp = set()
|
||||
while len(unvisited) != 0:
|
||||
m = unvisited[0]
|
||||
log(DEBUG, 'Checking circular dependency of', m)
|
||||
last = self.app.check_circular_deps(m, args.flavour, self.app.flip_graph(graph), unvisited, temp, path)
|
||||
if last is not None:
|
||||
log(DEBUG, 'Found circular dependency below', m, ', last is', last)
|
||||
print('Found circular dependency in flavour', args.flavour, ':', ' -> '.join(path))
|
||||
exit(1)
|
||||
print('No circular dependency found for flavour', args.flavour, ' in modules:',
|
||||
' '.join(args.module))
|
||||
exit(0)
|
||||
path = self.app.find_circular_deps(args.module, args.flavour)
|
||||
if path:
|
||||
print(f'Found circular dependency in flavour {args.flavour}:', ' -> '.join(path))
|
||||
exit(1)
|
||||
print(f'No circular dependency found for flavour {args.flavour} in modules:', ' '.join(args.module))
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdExepath(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
out = []
|
||||
for m in deps:
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ class CmdLdflags(Cmd): # export
|
|||
|
||||
# -L needs to contain more paths than libs linked with -l would require
|
||||
def __get_ldpathflags(self, names: list[str], exclude: list[str] = []) -> str:
|
||||
deps = self.app.get_modules_from_project_txt(names, ['pkg.requires.jw'], 'build',
|
||||
deps = self.app.get_project_refs(names, ['pkg.requires.jw'], 'build',
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
ret = []
|
||||
for m in deps:
|
||||
|
|
@ -38,7 +38,7 @@ class CmdLdflags(Cmd): # export
|
|||
return(' '.join(ret))
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'build',
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], 'build',
|
||||
scope = Scope.One, add_self=args.add_self, names_only=True)
|
||||
out = []
|
||||
for m in reversed(deps):
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdLdlibpath(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], [ 'run', 'build', 'devel' ],
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
out = []
|
||||
for m in deps:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdPath(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], 'run',
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], 'run',
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
out = []
|
||||
for m in deps:
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ class CmdPrereq(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'],
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'],
|
||||
args.flavour, scope = Scope.Subtree, add_self=False, names_only=True)
|
||||
print(' '.join(deps))
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdPythonpath(Cmd): # export
|
|||
p.add_argument('module', help='Modules', nargs='*')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
out = []
|
||||
for m in deps:
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CmdPythonpathOrig(Cmd): # export
|
|||
parser.add_argument('module', nargs='*', help='Modules')
|
||||
|
||||
async def _run(self, args: Namespace) -> None:
|
||||
deps = self.app.get_modules_from_project_txt(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
|
||||
deps = self.app.get_project_refs(args.module, ['pkg.requires.jw'], [ 'run', 'build' ],
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
r = ''
|
||||
for m in deps:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Iterable
|
||||
from argparse import Namespace, ArgumentParser
|
||||
|
||||
from ...App import Scope
|
||||
|
|
@ -29,7 +30,7 @@ class CmdRequiredOsPkg(Cmd): # export
|
|||
# TODO: This adds too much. Only the run dependencies of the build dependencies would be needed.
|
||||
flavours.append('run')
|
||||
log(DEBUG, "flavours = " + args.flavours)
|
||||
deps = self.app.get_modules_from_project_txt(modules, ['pkg.requires.jw'], flavours,
|
||||
deps = self.app.get_project_refs(modules, ['pkg.requires.jw'], flavours,
|
||||
scope = Scope.Subtree, add_self=True, names_only=True)
|
||||
if args.skip_excluded:
|
||||
for d in deps:
|
||||
|
|
@ -38,15 +39,12 @@ class CmdRequiredOsPkg(Cmd): # export
|
|||
subsecs = self.app.os_cascade()
|
||||
log(DEBUG, "subsecs = ", subsecs)
|
||||
requires = []
|
||||
for s in subsecs:
|
||||
for f in flavours:
|
||||
vals = self.app.collect_values(deps, 'pkg.requires.' + s, f)
|
||||
for sec in subsecs:
|
||||
for flavour in flavours:
|
||||
vals = self.app.get_values(deps, ['pkg.requires.' + sec], [flavour])
|
||||
if vals:
|
||||
requires = requires + vals
|
||||
if args.quote:
|
||||
requires = [f'"{dep}"' for dep in requires]
|
||||
# TODO: add all not in build tree as -devel
|
||||
r = ''
|
||||
for m in requires:
|
||||
r = r + ' ' + m
|
||||
print(r[1:])
|
||||
print(' '.join(requires))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue