fix: collect correct file when invoked with -f

This commit is contained in:
Daylin Morgan 2022-09-24 17:25:15 -05:00
parent b75a3c2c98
commit 3defee72dc
2 changed files with 7 additions and 2 deletions

View file

@ -29,7 +29,8 @@ tconfirm = $(call py,confirm_py,$(1))
_update-task.mk:
$(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk
export MAKEFILE_LIST MAKE
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
ifndef INHERIT_SHELL
SHELL := $(shell which bash)
endif

View file

@ -82,7 +82,10 @@ def recipe_help_header(goal):
def get_goal_deps(goal="task.mk"):
make = os.getenv("MAKE", "make")
database = subprocess.check_output([make, "-p", "-n"], universal_newlines=True)
cmd = [make, "-p", "-n", "-i"]
for file in os.getenv("TASK_MAKEFILE_LIST", "").split():
cmd.extend(["-f", file])
database = subprocess.check_output(cmd, universal_newlines=True)
dep_pattern = re.compile(r"^" + goal + ":(.*)?")
for line in database.splitlines():
match = dep_pattern.search(line)
@ -196,4 +199,5 @@ def main():
if __name__ == "__main__":
main()
#% endblock %#