fix: phonifier ignored goals without a message

This commit is contained in:
Daylin Morgan 2023-01-24 08:48:08 -06:00
parent bddd2f3bd2
commit 535118d27a
4 changed files with 11 additions and 9 deletions

View file

@ -31,5 +31,5 @@ export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
# SHELL := $(shell which bash) # SHELL := $(shell which bash)
# endif # endif
ifdef PHONIFY ifdef PHONIFY
$(shell $(call py-verbose,phonify_py)) $(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
endif endif

View file

@ -42,7 +42,7 @@ def gen_makefile():
return makefile return makefile
def parse_help(file, hidden=False): def parse_help(file, hidden=False, require_msg=True):
for line in file.splitlines(): for line in file.splitlines():
match = pattern.search(line) match = pattern.search(line)
if match: if match:
@ -53,7 +53,8 @@ def parse_help(file, hidden=False):
): ):
pass pass
elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")): elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")):
pass if not require_msg:
yield {k: v for k, v in match.groupdict().items() if v is not None}
else: else:
yield {k: v for k, v in match.groupdict().items() if v is not None} yield {k: v for k, v in match.groupdict().items() if v is not None}

View file

@ -14,7 +14,7 @@ def check_item(item):
def main(): def main():
items = " ".join((i["goal"] for i in parse_help(gen_makefile()) if check_item(i))) items = " ".join((i["goal"] for i in parse_help(gen_makefile(),require_msg=False) if check_item(i)))
sys.stdout.write(".PHONY: " + items) sys.stdout.write(".PHONY: " + items)

11
task.mk
View file

@ -1,7 +1,7 @@
# }> [github.com/daylinmorgan/task.mk] <{ # # }> [github.com/daylinmorgan/task.mk] <{ #
# Copyright (c) 2022 Daylin Morgan # Copyright (c) 2022 Daylin Morgan
# MIT License # MIT License
TASKMK_VERSION ?= v23.1.1-7-gb411303-dev TASKMK_VERSION ?= v23.1.1-8-gbddd2f3-dev
# task.mk should be included at the bottom of your Makefile with `-include .task.mk` # task.mk should be included at the bottom of your Makefile with `-include .task.mk`
# See below for the standard configuration options that should be set prior to including this file. # See below for the standard configuration options that should be set prior to including this file.
# You can update your .task.mk with `make _update-task.mk` # You can update your .task.mk with `make _update-task.mk`
@ -330,7 +330,7 @@ def check_item(item):
args = parseargs(item.get("msgargs", "")) args = parseargs(item.get("msgargs", ""))
return not args.not_phony return not args.not_phony
def main(): def main():
items = " ".join((i["goal"] for i in parse_help(gen_makefile()) if check_item(i))) items = " ".join((i["goal"] for i in parse_help(gen_makefile(),require_msg=False) if check_item(i)))
sys.stdout.write(".PHONY: " + items) sys.stdout.write(".PHONY: " + items)
if __name__ == "__main__": if __name__ == "__main__":
main() main()
@ -363,7 +363,7 @@ def gen_makefile():
with open(file, "r") as f: with open(file, "r") as f:
makefile += f.read() + "\n\n" makefile += f.read() + "\n\n"
return makefile return makefile
def parse_help(file, hidden=False): def parse_help(file, hidden=False, require_msg=True):
for line in file.splitlines(): for line in file.splitlines():
match = pattern.search(line) match = pattern.search(line)
if match: if match:
@ -374,7 +374,8 @@ def parse_help(file, hidden=False):
): ):
pass pass
elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")): elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")):
pass if not require_msg:
yield {k: v for k, v in match.groupdict().items() if v is not None}
else: else:
yield {k: v for k, v in match.groupdict().items() if v is not None} yield {k: v for k, v in match.groupdict().items() if v is not None}
def parseargs(argstring): def parseargs(argstring):
@ -449,5 +450,5 @@ export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
# SHELL := $(shell which bash) # SHELL := $(shell which bash)
# endif # endif
ifdef PHONIFY ifdef PHONIFY
$(shell $(call py-verbose,phonify_py)) $(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
endif endif