mirror of https://github.com/deuill/fawkss.git
Makefile: Simplify `make help` command.
This commit is contained in:
parent
32e3f189cc
commit
95da80f8c0
63
Makefile
63
Makefile
|
@ -36,40 +36,23 @@ RESET = \033[0m
|
|||
|
||||
# Awk script for extracting Fawkss documentation as Markdown.
|
||||
define EXTRACT_MARKDOWN
|
||||
/^(#|# .*)$$/ {
|
||||
if (f==1) {f=0; printf "```\n\n"}
|
||||
print substr($$0, 3)
|
||||
}
|
||||
/^[^#]/ {
|
||||
if (f==0) {f=1; printf "\n```awk\n"}
|
||||
print
|
||||
}
|
||||
!NF {
|
||||
print
|
||||
}
|
||||
END {
|
||||
if (f==1) {printf "```\n"}
|
||||
}
|
||||
/^(#|# .*)$$/ {
|
||||
if (f==1) {f=0; printf "```\n\n"}
|
||||
print substr($$0, 3)
|
||||
}
|
||||
/^[^#]/ {
|
||||
if (f==0) {f=1; printf "\n```awk\n"}
|
||||
print
|
||||
}
|
||||
!NF {
|
||||
print
|
||||
}
|
||||
END {
|
||||
if (f==1) {printf "```\n"}
|
||||
}
|
||||
endef
|
||||
export EXTRACT_MARKDOWN
|
||||
|
||||
# Template for help text produced by `make help`.
|
||||
define HELP_TEXT
|
||||
$(BOLD)Fawkss — The simple CSS preprocessor.$(RESET)
|
||||
|
||||
This Makefile contains tasks for processing auxiliary actions, such as
|
||||
generating documentation or running test cases.
|
||||
|
||||
$(UNDERLINE)Available Tasks$(RESET)
|
||||
|
||||
$(shell \
|
||||
awk -F \
|
||||
':|##' '/^##/ {c=$$2; getline; printf "$(BLUE)%10s$(RESET) %s\\n", $$1, c}' \
|
||||
$(MAKEFILE_LIST) \
|
||||
)
|
||||
endef
|
||||
export HELP_TEXT
|
||||
|
||||
# ----------------
|
||||
# Rule definitions
|
||||
# ----------------
|
||||
|
@ -97,12 +80,13 @@ $(TESTS):
|
|||
@$(FAWKSS) $@.test.$(TMPPID) > $@.actual.$(TMPPID)
|
||||
$(eval te = $(shell date +"%s%3N"))
|
||||
|
||||
@printf ">> $(BOLD)Testing file '$@'...$(RESET) "
|
||||
|
||||
# Generate diff between expected and actual results and print back to user.
|
||||
@result=$$($(DIFF) -ud $@.actual.$(TMPPID) $@.expected.$(TMPPID) | tail -n +3); \
|
||||
tt=`echo "$(ts) $(te)" | awk '{printf "(%.3fs)\n", (($$2-$$1)/1000)}'`; \
|
||||
printf ">> $(BOLD)Testing file '$@'...$(RESET) "; \
|
||||
@result=$$($(DIFF) -ud $@.expected.$(TMPPID) $@.actual.$(TMPPID) | tail -n +3); \
|
||||
if [ -z "$$result" ]; then \
|
||||
printf "$(GREEN)OK$(RESET) $$tt\n"; \
|
||||
time=`echo "$(ts) $(te)" | awk '{printf "(%.3fs)\n", (($$2-$$1)/1000)}'`; \
|
||||
printf "$(GREEN)OK$(RESET) $$time\n"; \
|
||||
else \
|
||||
printf "$(RED)FAIL$(RESET)\n"; \
|
||||
echo "$$result"; \
|
||||
|
@ -113,4 +97,11 @@ $(TESTS):
|
|||
|
||||
## Show usage information for this Makefile.
|
||||
help:
|
||||
@printf "$$HELP_TEXT\n"
|
||||
@printf "$(BOLD)Fawkss — The [ig]noble CSS preprocessor.$(RESET)\n\n"
|
||||
@printf "This Makefile contains tasks for processing auxiliary actions, such as\n"
|
||||
@printf "generating documentation or running test cases against the test suite.\n\n"
|
||||
@printf "$(UNDERLINE)Available Tasks$(RESET)\n\n"
|
||||
@awk -F \
|
||||
':|##' '/^##/ {c=$$2; getline; printf "$(BLUE)%10s$(RESET) %s\n", $$1, c}' \
|
||||
$(MAKEFILE_LIST)
|
||||
@printf "\n"
|
Loading…
Reference in New Issue