build: bump task.mk version again

This commit is contained in:
Daylin Morgan 2023-01-29 21:57:06 -06:00
parent a433539ba9
commit c220d225fc
3 changed files with 48 additions and 65 deletions

4
.task.cfg.mk Normal file
View file

@ -0,0 +1,4 @@
PHONIFY = true
msg = $(call tprint,{a.bold}==>{a.end} {a.b_magenta}$(1){a.end} {a.bold}<=={a.end})
USAGE = {a.b_green}Update MonoLisa with Nerd Fonts! {a.end}\n\n{a.header}usage{a.end}:\n make <recipe>\n
-include .task.mk

View file

@ -1,8 +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: 23.1.1 TASKMK_VERSION ?= 23.1.1
#
# 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`
@ -25,30 +24,27 @@ ifeq (help,$(firstword $(MAKECMDGOALS)))
HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) HELP_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
export HELP_ARGS export HELP_ARGS
endif endif
## h, help | show this help h help: ## show this help
h help:
$(call py,help_py) $(call py,help_py)
_help: export SHOW_HIDDEN=true _help: export SHOW_HIDDEN=true
_help: help _help: help
ifdef PRINT_VARS ifdef PRINT_VARS
$(foreach v,$(PRINT_VARS),$(eval export $(v))) TASKMK_VARS=$(subst $(eval ) ,<|>,$(foreach v,$(PRINT_VARS),$(v)=$($(v))))
.PHONY: vars v .PHONY: vars v
vars v: v vars:
$(call py,vars_py,$(PRINT_VARS)) $(call py,vars_py,$(TASKMK_VARS))
endif endif
### | args: -ws --hidden ### |> -ws --hidden
### task.mk builtins: | args: -d --hidden ### task.mk builtins: |> -d --hidden
## _print-ansi | show all possible ansi color code combinations _print-ansi: ## show all possible ansi color code combinations
_print-ansi:
$(call py,print_ansi_py) $(call py,print_ansi_py)
# functions to take f-string literals and pass to python print # functions to take f-string literals and pass to python print
tprint = $(call py,print_py,$(1)) tprint = $(call py,print_py,$(1))
tprint-sh = $(call pysh,print_py,$(1)) tprint-verbose= $(call py-verbose,print_py,$(1))
tconfirm = $(call py,confirm_py,$(1)) tconfirm = $(call py,confirm_py,$(1))
## _update-task.mk | downloads latest development version of task.mk _update-task.mk: ## downloads version of task.mk (TASKMK_VERSION=)
_update-task.mk:
$(call tprint,{a.b_cyan}Updating task.mk{a.end}) $(call tprint,{a.b_cyan}Updating task.mk{a.end})
curl https://raw.githubusercontent.com/daylinmorgan/task.mk/main/task.mk -o .task.mk curl https://raw.githubusercontent.com/daylinmorgan/task.mk/$(TASKMK_VERSION)/task.mk -o .task.mk
.PHONY: h help _help _print-ansi _update-task.mk .PHONY: h help _help _print-ansi _update-task.mk
TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST)) TASK_MAKEFILE_LIST := $(filter-out $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)),$(MAKEFILE_LIST))
export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST export MAKEFILE_LIST MAKE TASK_MAKEFILE_LIST
@ -77,7 +73,7 @@ else
py = @python3 <(printf "$(call _create_string,$($(1)))") py = @python3 <(printf "$(call _create_string,$($(1)))")
tbash = @bash <(printf "$(call _create_string,$($(1)))") tbash = @bash <(printf "$(call _create_string,$($(1)))")
endif endif
pysh = python3 <(printf "$(call _create_string,$($(1)))") py-verbose = python3 <(printf "$(call _create_string,$($(1)))")
# ---- [python scripts] ---- # # ---- [python scripts] ---- #
define help_py define help_py
import argparse import argparse
@ -92,26 +88,20 @@ a = ansi = Ansi(target="stdout")
MaxLens = namedtuple("MaxLens", "goal msg") MaxLens = namedtuple("MaxLens", "goal msg")
pattern = re.compile( pattern = re.compile(
r""" r"""
^\#\#\ (?:
(?P<goal>.*?)\s?\|\s?(?P<msg>.*?) ^\#\#\#\s+ # <- raw message
\s? |
(?: ^(?:
(?:\|\s?args:\s?|\|>) (?:\#\#\s+)?
\s? (?P<goal>.*?)(?:\s+\|>|:.*?\#\#)\s+
(?P<msgargs>.*?) ) # <- a custom goal or actual recipe
)? )
$$ (?P<msg>.*?)?\s? # <- help text (optional)
| (?:\|>\s+
^\#\#\#\ (?P<msgargs>.*?)
(?P<rawmsg>.*?) )? # <- style args (optional)
\s? $$
(?: """,
(?:\|\s?args:|\|\>)
\s?
(?P<rawargs>.*?)
)?
$$
""",
re.X, re.X,
) )
goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE) goal_pattern = re.compile(r"""^(?!#|\t)(.*):.*\n\t""", re.MULTILINE)
@ -234,7 +224,10 @@ def print_help():
lines = [cfg.usage] lines = [cfg.usage]
items = list(parse_help(gen_makefile())) items = list(parse_help(gen_makefile()))
maxlens = MaxLens( maxlens = MaxLens(
*(max((len(item[x]) for item in items if x in item)) for x in ["goal", "msg"]) *(
max((*(len(item[x]) for item in items if x in item), 0))
for x in ["goal", "msg"]
)
) )
for item in items: for item in items:
if "goal" in item: if "goal" in item:
@ -243,8 +236,8 @@ def print_help():
item["goal"], item["msg"], maxlens.goal, item.get("msgargs", "") item["goal"], item["msg"], maxlens.goal, item.get("msgargs", "")
) )
) )
if "rawmsg" in item: else:
lines.extend(fmt_rawmsg(item["rawmsg"], item.get("rawargs", ""), maxlens)) lines.extend(fmt_rawmsg(item["msg"], item.get("msgargs", ""), maxlens))
lines.append(cfg.epilog) lines.append(cfg.epilog)
print("\n".join(lines)) print("\n".join(lines))
def print_arg_help(help_args): def print_arg_help(help_args):
@ -292,12 +285,10 @@ define vars_py
import os import os
$(utils_py) $(utils_py)
ansi = Ansi(target="stdout") ansi = Ansi(target="stdout")
vars = "$2".split() task_vars = tuple(v.split('=') for v in "$2".split('<|>'))
length = max((len(v) for v in vars)) length = max((len(v[0]) for v in task_vars))
print(f"{ansi.header}vars{ansi.end}:\n") rows = (f" {ansi.params}{v[0]:<{length}}{ansi.end} = {v[1]}" for v in task_vars)
for v in vars: print('\n'.join((f"{ansi.header}vars{ansi.end}:\n", *rows,'')))
print(f" {ansi.params}{v:<{length}}{ansi.end} = {os.getenv(v)}")
print()
endef endef
define confirm_py define confirm_py
import sys import sys
@ -399,6 +390,7 @@ class Ansi:
print("Expected one or three values for bg as a list") print("Expected one or three values for bg as a list")
sys.exit(1) sys.exit(1)
return code + end return code + end
def add_cfg(self): def add_cfg(self):
cfg_styles = { cfg_styles = {
"header": "$(HEADER_STYLE)", "header": "$(HEADER_STYLE)",

View file

@ -4,45 +4,32 @@ ARGS ?= -c
NF_SRC := $(shell ./bin/get-font-files src) NF_SRC := $(shell ./bin/get-font-files src)
FONT_FLAGS := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2') FONT_FLAGS := $(shell ./bin/get-font-files MonoLisa 'otf,ttf,woff,woff2')
## patch | apply nerd fonts patch |> -gs b_magenta -ms bold patch: ./bin/font-patcher ## apply nerd fonts patch |> -gs b_magenta -ms bold
patch: ./bin/font-patcher
@./bin/patch-monolisa \ @./bin/patch-monolisa \
$(FONT_FLAGS) \ $(FONT_FLAGS) \
$(ARGS) $(ARGS)
## update-fonts | move fonts and update fc-cache update-fonts: ## move fonts and update fc-cache
.PHONY: update-fonts
update-fonts:
$(call msg,Adding Fonts To System) $(call msg,Adding Fonts To System)
@./bin/update-fonts @./bin/update-fonts
@fc-cache -f -v @fc-cache -f -v
## check | check fc-list for MonoLisa check: ## check fc-list for MonoLisa
.PHONY: check
check:
$(call msg,Checking System for Fonts) $(call msg,Checking System for Fonts)
@fc-list | grep "MonoLisa" @fc-list | grep "MonoLisa"
## update-src | update nerd fonts source update-src: ## update nerd fonts source
.PHONY: update-src
update-src:
$(call msg,Updating Source Files) $(call msg,Updating Source Files)
@./bin/update-src @./bin/update-src
## lint | run pre-commit hooks lint: ## run pre-commit hooks
.PHONY: lint
lint:
@pre-commit run --all @pre-commit run --all
## clean | remove patched fonts clean: ## remove patched fonts
.PHONY: clean
clean:
@rm -rf patched/* @rm -rf patched/*
# depends on daylinmorgan/yartsu # depends on daylinmorgan/yartsu
assets/help.svg: assets/help.svg:
yartsu -o $@ -t 'make help' -- $(MAKE) -s help yartsu -o $@ -t 'make help' -- $(MAKE) -s help
msg = $(call tprint,{a.bold}==>{a.end} {a.b_magenta}$(1){a.end} {a.bold}<=={a.end}) -include .task.cfg.mk
USAGE = {a.b_green}Update MonoLisa with Nerd Fonts! {a.end}\n\n{a.header}usage{a.end}:\n make <recipe>\n
-include .task.mk