mirror of
https://github.com/daylinmorgan/task.mk.git
synced 2024-12-22 18:00:44 -06:00
Compare commits
7 commits
8f875a13d1
...
77e76edd16
Author | SHA1 | Date | |
---|---|---|---|
77e76edd16 | |||
a7f1fb7922 | |||
e2057870c5 | |||
5f5e15adaa | |||
9ee263b8b9 | |||
98c70aff13 | |||
9412fb2e2f |
9 changed files with 24 additions and 45 deletions
13
Makefile
13
Makefile
|
@ -32,7 +32,8 @@ release: version-check
|
||||||
$(call msg,Release Project)
|
$(call msg,Release Project)
|
||||||
@./generate.py $(VERSION) > task.mk
|
@./generate.py $(VERSION) > task.mk
|
||||||
@sed -i 's/task.mk\/.*\/task.mk/task.mk\/v$(VERSION)\/task.mk/g' README.md
|
@sed -i 's/task.mk\/.*\/task.mk/task.mk\/v$(VERSION)\/task.mk/g' README.md
|
||||||
@git add task.mk README.md
|
@sed -i 's/task.mk\/.*\/task.mk/task.mk\/v$(VERSION)\/task.mk/g' docs/index.md
|
||||||
|
@git add task.mk README.md docs/index.md
|
||||||
@git commit -m "release: v$(VERSION)" --no-verify
|
@git commit -m "release: v$(VERSION)" --no-verify
|
||||||
@git tag v$(VERSION)
|
@git tag v$(VERSION)
|
||||||
|
|
||||||
|
@ -53,7 +54,6 @@ version-check:
|
||||||
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
|
$(call tprint-sh,{a.green}VERSION LOOKS GOOD!{a.end});\
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
## info | demonstrate usage of tprint
|
## info | demonstrate usage of tprint
|
||||||
.PHONY: task
|
.PHONY: task
|
||||||
info:
|
info:
|
||||||
|
@ -62,23 +62,18 @@ info:
|
||||||
$(call tprint,$(mlmsg))
|
$(call tprint,$(mlmsg))
|
||||||
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
|
$(call tprint,{a.custom(fg=(148, 255, 15),bg=(103, 2, 15))}Custom Colors TOO!{a.end})
|
||||||
|
|
||||||
|
|
||||||
task.mk: $(TEMPLATES) generate.py
|
task.mk: $(TEMPLATES) generate.py
|
||||||
./generate.py $(VERSION) > task.mk
|
./generate.py $(VERSION) > task.mk
|
||||||
|
|
||||||
define USAGE
|
define USAGE
|
||||||
{a.$(HEADER_STYLE)}usage:{a.end}
|
{a.$(HEADER_STYLE)}usage:{a.end}\n make <recipe>\n
|
||||||
make <recipe>
|
|
||||||
|
|
||||||
Turn your {a.style('`Makefile`','b_magenta')} into
|
Turn your {a.style('`Makefile`','b_magenta')} into
|
||||||
the {a.italic}{a.underline}task runner{a.end} you always needed.
|
the {a.italic}{a.underline}task runner{a.end} you always needed.
|
||||||
See the example output below.
|
See the example output below.\n
|
||||||
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
EPILOG = \nfor more info: gh.dayl.in/task.mk
|
EPILOG = \nfor more info: gh.dayl.in/task.mk
|
||||||
PRINT_VARS := VERSION
|
PRINT_VARS := VERSION
|
||||||
|
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
.task.mk: $(TEMPLATES) generate.py
|
.task.mk: $(TEMPLATES) generate.py
|
||||||
$(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end})
|
$(call tprint,{a.b_yellow}re-jinjaing the local .task.mk{a.end})
|
||||||
|
|
10
README.md
10
README.md
|
@ -4,7 +4,12 @@
|
||||||
<p align="center">
|
<p align="center">
|
||||||
the task runner for GNU Make you've been missing
|
the task runner for GNU Make you've been missing
|
||||||
</p>
|
</p>
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://gh.dayl.in/task.mk">Documentation</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</br>
|
</br>
|
||||||
|
|
||||||
GNU make is an excellent build tool and the task runner we love to hate, but can't escape.
|
GNU make is an excellent build tool and the task runner we love to hate, but can't escape.
|
||||||
|
@ -32,14 +37,14 @@ If someone tries to invoke `make help` it will download `.task.mk` for them.
|
||||||
|
|
||||||
```make
|
```make
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk))
|
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk))
|
||||||
```
|
```
|
||||||
|
|
||||||
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
||||||
|
|
||||||
```make
|
```make
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk)
|
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk)
|
||||||
```
|
```
|
||||||
|
|
||||||
For more info see the [documentation](https://gh.dayl.in/task.mk).
|
For more info see the [documentation](https://gh.dayl.in/task.mk).
|
||||||
|
@ -52,6 +57,7 @@ But I just want a basic help output, surely I don't need python for this... you
|
||||||
|
|
||||||
```make
|
```make
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
|
### additional text printed with the help
|
||||||
.PHONY: help h
|
.PHONY: help h
|
||||||
help h: Makefile
|
help h: Makefile
|
||||||
@awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\
|
@awk -v fill=$(shell sed -n 's/^## \(.*\) | .*/\1/p' $< | wc -L)\
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
|
||||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
|
||||||
|
|
||||||
|
|
||||||
## check | get user confirmation or exit
|
## check | get user confirmation or exit
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check:
|
check:
|
||||||
|
|
|
@ -1,6 +1,3 @@
|
||||||
msgfmt = {a.style('==>','bold')} {a.style('$(1)','b_magenta')} {a.style('<==','bold')}
|
|
||||||
msg = $(call tprint,$(call msgfmt ,$(1)))
|
|
||||||
|
|
||||||
### examples of task.mk features | args: --divider --align center --msg-style b_red
|
### examples of task.mk features | args: --divider --align center --msg-style b_red
|
||||||
define list_files_py
|
define list_files_py
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
@ -34,14 +31,6 @@ endef
|
||||||
embedded-bash:
|
embedded-bash:
|
||||||
$(call tbash,bash_script,bash multiline is probably working)
|
$(call tbash,bash_script,bash multiline is probably working)
|
||||||
|
|
||||||
define mlmsg
|
|
||||||
{a.b_yellow}
|
|
||||||
It can even be multiline!{a.end}
|
|
||||||
{a.style('and styles can be defined','red')}
|
|
||||||
as python {a.bold}f-string{a.end} literals
|
|
||||||
{a.end}
|
|
||||||
endef
|
|
||||||
|
|
||||||
define USAGE
|
define USAGE
|
||||||
{a.$(HEADER_STYLE)}usage:{a.end}
|
{a.$(HEADER_STYLE)}usage:{a.end}
|
||||||
make <recipe>
|
make <recipe>
|
||||||
|
|
|
@ -23,7 +23,7 @@ Current Features:
|
||||||
Depends on `GNU Make`, obviously and `Python >=3.7`.
|
Depends on `GNU Make`, obviously and `Python >=3.7`.
|
||||||
|
|
||||||
Wait python?!?!, I'm not `pip` installing some package just to parse my makefile.
|
Wait python?!?!, I'm not `pip` installing some package just to parse my makefile.
|
||||||
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/blob/main/task.mk).
|
I agree, all you need is one file [`.task.mk`](https://github.com/daylinmorgan/task.mk/v22.9.19/task.mk).
|
||||||
You can automagically include it with just two additional lines to your `Makefile` (and probably one to your `.gitignore`) and your good to go.
|
You can automagically include it with just two additional lines to your `Makefile` (and probably one to your `.gitignore`) and your good to go.
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
@ -33,14 +33,14 @@ If someone tries to invoke `make help` it will download `.task.mk` for them.
|
||||||
|
|
||||||
```make
|
```make
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk))
|
$(if $(filter help,$(MAKECMDGOALS)),$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk))
|
||||||
```
|
```
|
||||||
|
|
||||||
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
You might also consider making it a consistently downloaded dependency if you plan to use any of it's advanced feature set, by dropping the `$(MAKECMDGOALS)` check.
|
||||||
|
|
||||||
```make
|
```make
|
||||||
-include .task.mk
|
-include .task.mk
|
||||||
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.14/task.mk -o .task.mk)
|
$(if $(wildcard .task.mk),,.task.mk: ; curl -fsSL https://raw.githubusercontent.com/daylinmorgan/task.mk/v22.9.19/task.mk -o .task.mk)
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, you can use the builtin rule `_update-task.mk` to update to the latest development version.
|
Alternatively, you can use the builtin rule `_update-task.mk` to update to the latest development version.
|
||||||
|
|
|
@ -9,4 +9,4 @@ DIVIDER ?= ─
|
||||||
HELP_SEP ?= │
|
HELP_SEP ?= │
|
||||||
# python f-string literals
|
# python f-string literals
|
||||||
EPILOG ?=
|
EPILOG ?=
|
||||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
|
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
||||||
|
|
|
@ -53,7 +53,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr):
|
||||||
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
||||||
return (
|
return (
|
||||||
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
||||||
+ " $(HELP_SEP) "
|
+ f" $(HELP_SEP) "
|
||||||
+ ansi.style(msg, msg_style)
|
+ ansi.style(msg, msg_style)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,9 @@
|
||||||
#% block name %#print_ansi#% endblock %#
|
#% block name %#print_ansi#% endblock %#
|
||||||
#% block script %#
|
#% block script %#
|
||||||
##- '$(ansi_py)' -##
|
##- '$(ansi_py)' -##
|
||||||
|
sep = f"$(HELP_SEP)"
|
||||||
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
||||||
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
||||||
print(
|
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
|
||||||
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
|
|
||||||
codes_names[code], code + "******" + ansi.end, repr(code)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
#% endblock %#
|
#% endblock %#
|
||||||
|
|
13
task.mk
13
task.mk
|
@ -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
|
||||||
# version: v22.9.14-18-g1a018e2-dev
|
# version: 22.9.19
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
@ -17,7 +17,7 @@ DIVIDER ?= ─
|
||||||
HELP_SEP ?= │
|
HELP_SEP ?= │
|
||||||
# python f-string literals
|
# python f-string literals
|
||||||
EPILOG ?=
|
EPILOG ?=
|
||||||
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>
|
USAGE ?={ansi.$(HEADER_STYLE)}usage{ansi.end}:\n make <recipe>\n
|
||||||
# ---- [buitlin recipes] ---- #
|
# ---- [buitlin recipes] ---- #
|
||||||
## h, help | show this help
|
## h, help | show this help
|
||||||
.PHONY: help h
|
.PHONY: help h
|
||||||
|
@ -112,7 +112,7 @@ def fmt_goal(goal, msg, max_goal_len, argstr):
|
||||||
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
msg_style = args.msg_style.strip() if args.msg_style else "$(MSG_STYLE)"
|
||||||
return (
|
return (
|
||||||
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
ansi.style(f" {goal:>{max_goal_len}}", goal_style)
|
||||||
+ " $(HELP_SEP) "
|
+ f" $(HELP_SEP) "
|
||||||
+ ansi.style(msg, msg_style)
|
+ ansi.style(msg, msg_style)
|
||||||
)
|
)
|
||||||
def fmt_rawmsg(msg, argstr, maxlens):
|
def fmt_rawmsg(msg, argstr, maxlens):
|
||||||
|
@ -237,13 +237,10 @@ print(f"""$(2)""")
|
||||||
endef
|
endef
|
||||||
define print_ansi_py
|
define print_ansi_py
|
||||||
$(ansi_py)
|
$(ansi_py)
|
||||||
|
sep = f"$(HELP_SEP)"
|
||||||
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
codes_names = {getattr(ansi, attr): attr for attr in ansi.__dict__}
|
||||||
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
for code in sorted(codes_names.keys(), key=lambda item: (len(item), item)):
|
||||||
print(
|
print(f"{codes_names[code]:>20} {sep} {code+'*****'+ansi.end} {sep} {repr(code)}")
|
||||||
"{:>20} $(HELP_SEP) {} $(HELP_SEP) {}".format(
|
|
||||||
codes_names[code], code + "******" + ansi.end, repr(code)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
endef
|
endef
|
||||||
define vars_py
|
define vars_py
|
||||||
import os
|
import os
|
||||||
|
|
Loading…
Reference in a new issue