mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-21 17:40:45 -06:00
fix: use python to modify makefile list
This commit is contained in:
parent
3e649ab027
commit
a901dc63c5
2 changed files with 7 additions and 3 deletions
|
@ -25,8 +25,7 @@ tprint = $(call py,print_py,$(1))
|
||||||
tprint-verbose= $(call py-verbose,print_py,$(1))
|
tprint-verbose= $(call py-verbose,print_py,$(1))
|
||||||
tconfirm = $(call py,confirm_py,$(1))
|
tconfirm = $(call py,confirm_py,$(1))
|
||||||
.PHONY: h help _help _print-ansi _update-task.mk
|
.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
|
||||||
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
|
|
||||||
ifdef PHONIFY
|
ifdef PHONIFY
|
||||||
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#% block name %#help#% endblock %#
|
#% block name %#help#% endblock %#
|
||||||
#% block script %#
|
#% block script %#
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from pathlib import Path
|
||||||
import subprocess
|
import subprocess
|
||||||
from textwrap import wrap
|
from textwrap import wrap
|
||||||
|
|
||||||
|
@ -39,11 +40,15 @@ def recipe_help_header(goal):
|
||||||
else:
|
else:
|
||||||
return f" {ansi.style(goal,'goal')}"
|
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"):
|
def get_goal_deps(goal="task.mk"):
|
||||||
make = os.getenv("MAKE", "make")
|
make = os.getenv("MAKE", "make")
|
||||||
cmd = [make, "-p", "-n", "-i"]
|
cmd = [make, "-p", "-n", "-i"]
|
||||||
for file in os.getenv("TASK_MAKEFILE_LIST", "").split():
|
for file in get_makefile_list():
|
||||||
cmd.extend(["-f", file])
|
cmd.extend(["-f", file])
|
||||||
database = subprocess.check_output(cmd, universal_newlines=True)
|
database = subprocess.check_output(cmd, universal_newlines=True)
|
||||||
dep_pattern = re.compile(r"^" + goal + ":(.*)?")
|
dep_pattern = re.compile(r"^" + goal + ":(.*)?")
|
||||||
|
|
Loading…
Reference in a new issue