projects.mk / jw-projects.py: Support tmpl_dir && tmpls-dir

For a project to supply templates, it needs to advertise their
location. For this, the tmpl_dir make variable is added to
projects.mk. If other-project wants to get hold of some-project's
templates, it can do, e.g.:

  TEMPLATES = $(wilcard $(call tmpl_dir,some-project)/*.tmpl)

To achieve this, support for the tmpls-dir command is added to
jw-projects.py.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2025-12-17 12:36:40 +01:00
commit ced42938e1
3 changed files with 32 additions and 1 deletions

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from argparse import Namespace, ArgumentParser
from ..Cmd import Cmd
class CmdTmplDir(Cmd): # export
def __init__(self) -> None:
super().__init__('tmpl-dir', help='Print directory containing templates of a given module')
def add_arguments(self, parser: ArgumentParser) -> None:
super().add_arguments(parser)
parser.add_argument('module', nargs='*', help='Modules')
def _run(self, args: Namespace) -> None:
r = []
for m in args.module:
r.append(self.app.tmpl_dir(m))
print(' '.join(r))