mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-15 12:03:31 +01:00
build.cmds.CmdCreatePkgConfig: Add module
Implement the functionality of create-pkg-config.sh in a Python module CmdCreatePkgConfig.py. This allows to remove create-pkg-config.sh and jw-build-functions.sh. Note that the translation was done pretty literally to play it safe. More code can and should be removed by taking advantage of the fact that jw-projects.py knows more about the project than the shell scripts. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
3370dd6236
commit
31537a0bd6
4 changed files with 59 additions and 557 deletions
57
src/python/jw/build/cmds/CmdCreatePkgConfig.py
Normal file
57
src/python/jw/build/cmds/CmdCreatePkgConfig.py
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue