mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-11-14 21:17:53 -06:00
Compare commits
No commits in common. "b0f7493dc02fb92992bbcd2438aa986f71d49bda" and "bddd2f3bd24e5bf81c39fd1a0ea7b45e12835f90" have entirely different histories.
b0f7493dc0
...
bddd2f3bd2
7 changed files with 35 additions and 32 deletions
|
@ -9,7 +9,3 @@ EPILOG = \nfor more info: gh.dayl.in/task.mk
|
|||
PRINT_VARS := VERSION SHELL
|
||||
PHONIFY = 1
|
||||
|
||||
-include .task.mk
|
||||
.task.mk: $(TEMPLATES) generate.py
|
||||
$(call msg,re-jinjaing the local {a.b_cyan}.task.mk{a.end})
|
||||
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)
|
||||
|
|
5
Makefile
5
Makefile
|
@ -64,4 +64,7 @@ info: ## demonstrate usage of tprint
|
|||
task.mk: $(TEMPLATES) generate.py
|
||||
./generate.py $(VERSION) > task.mk
|
||||
|
||||
-include .task.cfg.dev.mk .task.cfg.mk
|
||||
-include .task.cfg.dev.mk .task.cfg.mk .task.mk
|
||||
.task.mk: $(TEMPLATES) generate.py
|
||||
$(call msg,re-jinjaing the local {a.b_cyan}.task.mk{a.end})
|
||||
@./generate.py $(VERSION) > .task.mk || (echo "generator failed!!" && rm .task.mk)
|
||||
|
|
|
@ -25,8 +25,11 @@ 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))
|
||||
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
|
||||
ifdef PHONIFY
|
||||
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
||||
$(shell $(call py-verbose,phonify_py))
|
||||
endif
|
||||
|
|
|
@ -42,7 +42,7 @@ def gen_makefile():
|
|||
return makefile
|
||||
|
||||
|
||||
def parse_help(file, hidden=False, require_msg=True):
|
||||
def parse_help(file, hidden=False):
|
||||
for line in file.splitlines():
|
||||
match = pattern.search(line)
|
||||
if match:
|
||||
|
@ -53,8 +53,7 @@ def parse_help(file, hidden=False, require_msg=True):
|
|||
):
|
||||
pass
|
||||
elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")):
|
||||
if not require_msg:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
pass
|
||||
else:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ def check_item(item):
|
|||
|
||||
|
||||
def main():
|
||||
items = " ".join((i["goal"] for i in parse_help(gen_makefile(),require_msg=False) if check_item(i)))
|
||||
items = " ".join((i["goal"] for i in parse_help(gen_makefile()) if check_item(i)))
|
||||
sys.stdout.write(".PHONY: " + items)
|
||||
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
# possible posix process substitions solution:
|
||||
# https://unix.stackexchange.com/a/639752
|
||||
# -###
|
||||
TASKMK_SHELL ?= $(shell cat /etc/shells | grep -E '/(bash|zsh)' | head -n 1)
|
||||
ifndef TASKMK_SHELL
|
||||
$(warning WARNING! task.mk features require bash or zsh)
|
||||
SHELL_CHECK ?= $(shell /bin/sh --version | grep 'bash|zsh|ksh')
|
||||
ifndef SHELL_CHECK
|
||||
$(error task.mk requires a process substition compatible shell)
|
||||
endif
|
||||
define _newline
|
||||
|
||||
|
||||
endef
|
||||
_escape_shellstring = $(subst ','\'',$(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1)))))
|
||||
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
||||
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||
_printline = printf -- "<----------------------------------->\n"
|
||||
|
@ -26,7 +26,7 @@ endef
|
|||
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||
else
|
||||
py = @$(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||
tbash = @$(TASKMK_SHELL) -c '$(TASKMK_SHELL) <(printf "$(call _create_string,$($(1)))")'
|
||||
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
||||
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
||||
endif
|
||||
py-verbose = $(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
|
||||
|
|
30
task.mk
30
task.mk
|
@ -1,7 +1,7 @@
|
|||
# }> [github.com/daylinmorgan/task.mk] <{ #
|
||||
# Copyright (c) 2022 Daylin Morgan
|
||||
# MIT License
|
||||
TASKMK_VERSION ?= v23.1.1-10-ge85d61c-dev
|
||||
TASKMK_VERSION ?= v23.1.1-7-gb411303-dev
|
||||
# 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.
|
||||
# You can update your .task.mk with `make _update-task.mk`
|
||||
|
@ -330,7 +330,7 @@ def check_item(item):
|
|||
args = parseargs(item.get("msgargs", ""))
|
||||
return not args.not_phony
|
||||
def main():
|
||||
items = " ".join((i["goal"] for i in parse_help(gen_makefile(),require_msg=False) if check_item(i)))
|
||||
items = " ".join((i["goal"] for i in parse_help(gen_makefile()) if check_item(i)))
|
||||
sys.stdout.write(".PHONY: " + items)
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -363,7 +363,7 @@ def gen_makefile():
|
|||
with open(file, "r") as f:
|
||||
makefile += f.read() + "\n\n"
|
||||
return makefile
|
||||
def parse_help(file, hidden=False, require_msg=True):
|
||||
def parse_help(file, hidden=False):
|
||||
for line in file.splitlines():
|
||||
match = pattern.search(line)
|
||||
if match:
|
||||
|
@ -374,8 +374,7 @@ def parse_help(file, hidden=False, require_msg=True):
|
|||
):
|
||||
pass
|
||||
elif not any(match.groupdict().get(k) for k in ("msg", "msgargs")):
|
||||
if not require_msg:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
pass
|
||||
else:
|
||||
yield {k: v for k, v in match.groupdict().items() if v is not None}
|
||||
def parseargs(argstring):
|
||||
|
@ -391,15 +390,15 @@ def parseargs(argstring):
|
|||
endef
|
||||
# ---- [python/bash script runner] ---- #
|
||||
|
||||
TASKMK_SHELL ?= $(shell cat /etc/shells | grep -E '/(bash|zsh)' | head -n 1)
|
||||
ifndef TASKMK_SHELL
|
||||
$(warning WARNING! task.mk features require bash or zsh)
|
||||
SHELL_CHECK ?= $(shell /bin/sh --version | grep 'bash|zsh|ksh')
|
||||
ifndef SHELL_CHECK
|
||||
$(error task.mk requires a process substition compatible shell)
|
||||
endif
|
||||
define _newline
|
||||
|
||||
|
||||
endef
|
||||
_escape_shellstring = $(subst ','\'',$(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1)))))
|
||||
_escape_shellstring = $(subst `,\`,$(subst ",\",$(subst $$,\$$,$(subst \,\\,$1))))
|
||||
_escape_printf = $(subst \,\\,$(subst %,%%,$1))
|
||||
_create_string = $(subst $(_newline),\n,$(call _escape_shellstring,$(call _escape_printf,$1)))
|
||||
_printline = printf -- "<----------------------------------->\n"
|
||||
|
@ -413,10 +412,10 @@ endef
|
|||
py = $(call _debug_runner,Python,python3,$($(1)))
|
||||
tbash = $(call _debug_runner,Bash,bash,$($(1)))
|
||||
else
|
||||
py = @$(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||
tbash = @$(TASKMK_SHELL) -c '$(TASKMK_SHELL) <(printf "$(call _create_string,$($(1)))")'
|
||||
py = @python3 <(printf "$(call _create_string,$($(1)))")
|
||||
tbash = @bash <(printf "$(call _create_string,$($(1)))")
|
||||
endif
|
||||
py-verbose = $(TASKMK_SHELL) -c 'python3 <(printf "$(call _create_string,$($(1)))")'
|
||||
py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
|
||||
# ---- [builtin recipes] ---- #
|
||||
ifeq (help,$(firstword $(MAKECMDGOALS)))
|
||||
HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
|
||||
|
@ -444,8 +443,11 @@ 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))
|
||||
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
|
||||
ifdef PHONIFY
|
||||
$(shell MAKEFILE_LIST='$(MAKEFILE_LIST)' $(call py-verbose,phonify_py))
|
||||
$(shell $(call py-verbose,phonify_py))
|
||||
endif
|
||||
|
|
Loading…
Reference in a new issue