fix: use python to modify makefile list

This commit is contained in:
Daylin Morgan 2023-01-29 15:19:47 -06:00
parent 3e649ab027
commit a901dc63c5
2 changed files with 7 additions and 3 deletions

View File

@ -25,8 +25,7 @@ tprint = $(call py,print_py,$(1))
tprint-verbose= $(call py-verbose,print_py,$(1))
tconfirm = $(call py,confirm_py,$(1))
.PHONY: h help _help _print-ansi _update-task.mk
TASK_MAKEFILE_LIST := $(filter-out .task.cfg.mk .task.mk,$(MAKEFILE_LIST))
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
export MAKEFILE_LIST MAKE
ifdef PHONIFY
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
endif

View File

@ -2,6 +2,7 @@
#% block name %#help#% endblock %#
#% block script %#
from collections import namedtuple
from pathlib import Path
import subprocess
from textwrap import wrap
@ -39,11 +40,15 @@ def recipe_help_header(goal):
else:
return f" {ansi.style(goal,'goal')}"
def get_makefile_list():
pattern = re.compile(r'^\.?task.*?\.mk$$') ###- make needs a double dollar -###
makefiles = os.getenv("MAKEFILE_LIST", "").split()
return (f for f in makefiles if not pattern.match(Path(f).name))
def get_goal_deps(goal="task.mk"):
make = os.getenv("MAKE", "make")
cmd = [make, "-p", "-n", "-i"]
for file in os.getenv("TASK_MAKEFILE_LIST", "").split():
for file in get_makefile_list():
cmd.extend(["-f", file])
database = subprocess.check_output(cmd, universal_newlines=True)
dep_pattern = re.compile(r"^" + goal + ":(.*)?")