jw.build.cmds: Move build.cmds -> cmds.projects

Reorganize the Python module structure. Placing the command classes
under jw.cmds.projects instead of jw.build.cmds will allow to add a
nested command structure, with the current commands, being mostly
related to building software, found below a "projects" toplevel
command.

Other conceivable commands could be "package" for packaging, or
"distro" for commands wrapping the distribution's package manager.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-01-20 15:49:53 +01:00
commit 0b83c863a2
43 changed files with 49 additions and 13 deletions

View file

@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
import textwrap
from argparse import Namespace, ArgumentParser
from ..Cmd import Cmd
class CmdCreatePkgConfig(Cmd): # export
def __init__(self) -> None:
super().__init__('create-pkg-config', help='Generate a pkg-config file for a module')
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('-F', '--project-descr-file', default=None)
parser.add_argument('-d', '--description', default=None)
parser.add_argument('-n', '--name', default=None)
parser.add_argument('-s', '--summary', default=None)
parser.add_argument('-p', '--prefix', default=None)
parser.add_argument('-v', '--version', default=None)
parser.add_argument('-c', '--cflags', default=None)
parser.add_argument('-l', '--libflags', default=None)
parser.add_argument('-r', '--requires_run', default=None)
parser.add_argument('-R', '--requires_build', default=None)
parser.add_argument('-V', '--variables', nargs='*')
def _run(self, args: Namespace) -> None:
project_conf_var_keys = ['description', 'summary', 'requires_run', 'requires_build']
merged: dict[str, str] = {}
for key in project_conf_var_keys:
val = getattr(args, key)
if val is not None and args.project_descr_file:
val = self.app.get_value(args.name, key, None)
merged[key] = val
contents = textwrap.dedent(f"""\
prefix={args.prefix}
exec_prefix={{prefix}}
includedir={{prefix}}/include
libdir={{exec_prefix}}/lib
Name: {args.name}
Description: {merged['summary']}
Version: {args.version}
""")
if args.cflags is not None:
contents += f"Cflags: {args.cflags}\n"
if args.libflags is not None:
contents += f"Libs: {args.libflags}\n"
if merged['requires_run'] is not None:
contents += f"Requires: {cleanup_requires(merged['requires_run'])}"
if merged['requires_build'] is not None:
contents += f"Requires.private: {cleanup_requires(merged['requires_build'])}"
# not sure what to do with requires_devel
print(contents)