build(Makefile): Help notification stub started.

This commit is contained in:
Stephan Barth 2024-09-23 11:03:18 +02:00
parent cf76752894
commit 1a5564031d
2 changed files with 70 additions and 0 deletions

View File

@ -10,29 +10,44 @@ export db ?= -cf
export DEV_PORT_HTTP export DEV_PORT_HTTP
export DEV_PORT_HTTPS export DEV_PORT_HTTPS
# HELP HEADER START
# To see the definition of all available targets, take a look into the Makefile.
# Targets starting with '--' are not meant to be directly called.
# If you want to do so anyway please use 'make -- [--target]' to not
# have '[--target]' to be treated as option to 'make'.
#
#
# Targets meant to be used by humans are:
# HELP HEADER END
########################### ###########################
##### GENERAL TARGETS ##### ##### GENERAL TARGETS #####
.PHONY: help .PHONY: help
# HELP: print out this help message
help: help:
@echo "Nothing to see here, go away" @echo "Nothing to see here, go away"
.PHONY: all .PHONY: all
# HELP: unfinished
all: all:
@echo "TODO" @echo "TODO"
.PHONY: clean .PHONY: clean
# HELP: remove all compilation results in the directory but leave containers and images unharmed
clean: clean:
rm -rf node_modules .npm .cache assets/icons assets/favicons static well-known rm -rf node_modules .npm .cache assets/icons assets/favicons static well-known
rm -rf .stack .stack-work .stack-work-build .stack-work-run .stack-work-test .stack-work-doc rm -rf .stack .stack-work .stack-work-build .stack-work-run .stack-work-test .stack-work-doc
rm -rf bin/ .Dockerfile .dev-port-http .dev-port-https rm -rf bin/ .Dockerfile .dev-port-http .dev-port-https
.PHONY: clean-all .PHONY: clean-all
# HELP: like clean but with container and image prune
clean-all: clean clean-all: clean
$(CONTAINER_COMMAND) system prune --all --force --volumes $(CONTAINER_COMMAND) system prune --all --force --volumes
$(CONTAINER_COMMAND) image prune --all --force $(CONTAINER_COMMAND) image prune --all --force
$(CONTAINER_COMMAND) volume prune --force $(CONTAINER_COMMAND) volume prune --force
.PHONY: release .PHONY: release
# HELP: unfinished
release: release:
./.gitlab-ci/version.pl -changelog CHANGELOG.md ./.gitlab-ci/version.pl -changelog CHANGELOG.md
git add CHANGELOG.md git add CHANGELOG.md
@ -56,6 +71,7 @@ release:
##### UNIFIED FRONTEND/BACKEND TARGETS ##### ##### UNIFIED FRONTEND/BACKEND TARGETS #####
.PHONY: serve .PHONY: serve
# HELP: serve frontend, backend, and database
serve: CONTAINER_INTERACTIVE=-it serve: CONTAINER_INTERACTIVE=-it
serve: serve:
$(MAKE) serve-database & $(MAKE) serve-database &
@ -63,12 +79,15 @@ serve:
$(MAKE) serve-backend $(MAKE) serve-backend
.PHONY: compile .PHONY: compile
# HELP: compile frontend and backend
compile: compile-frontend compile-backend compile: compile-frontend compile-backend
.PHONY: lint .PHONY: lint
# HELP: lint frontend and backend
lint: lint-frontend lint-backend lint: lint-frontend lint-backend
.PHONY: test .PHONY: test
# HELP: test frontend, backend, and check internationalization
test: test-frontend test-backend i18n-check test: test-frontend test-backend i18n-check
##### UNIFIED FRONTEND/BACKEND TARGETS ##### ##### UNIFIED FRONTEND/BACKEND TARGETS #####
@ -85,11 +104,13 @@ test: test-frontend test-backend i18n-check
.PHONY: --%-frontend .PHONY: --%-frontend
--%-frontend: --containerized---frontend-dependencies-frontend; --%-frontend: --containerized---frontend-dependencies-frontend;
# HELP(compile-frontend): compile frontend
.PHONY: --compile-frontend .PHONY: --compile-frontend
--compile-frontend: --frontend-dependencies --compile-frontend: --frontend-dependencies
npx -- webpack --progress $(WATCH) npx -- webpack --progress $(WATCH)
.PHONY: serve-frontend .PHONY: serve-frontend
# HELP: serve frontend (watch file changes)
serve-frontend: CONTAINER_INTERACTIVE=-it serve-frontend: CONTAINER_INTERACTIVE=-it
serve-frontend: serve-frontend:
$(MAKE) -- --containerized---compile-frontend WATCH=--watch $(MAKE) -- --containerized---compile-frontend WATCH=--watch
@ -98,11 +119,13 @@ serve-frontend:
# --serve-frontend: WATCH=--watch # --serve-frontend: WATCH=--watch
# --serve-frontend: --compile-frontend; # --serve-frontend: --compile-frontend;
# HELP(lint-frontend): lint frontend
.PHONY: --lint-frontend .PHONY: --lint-frontend
--lint-frontend: eslint.config.js --lint-frontend: eslint.config.js
npx -- eslint frontend/src $(FIX) npx -- eslint frontend/src $(FIX)
@echo Hooray! There are no hints. @echo Hooray! There are no hints.
# HELP(test-frontend): test frontend
.PHONY: --test-frontend .PHONY: --test-frontend
--test-frontend: karma.conf.cjs --test-frontend: karma.conf.cjs
@echo Karma frontend tests are currently broken after npm update and have therefor been temporarily disabled. @echo Karma frontend tests are currently broken after npm update and have therefor been temporarily disabled.
@ -153,6 +176,7 @@ well-known: node_modules assets
--%-prod-backend: --image-build --containerized-%-backend; --%-prod-backend: --image-build --containerized-%-backend;
.PHONY: serve-backend .PHONY: serve-backend
# HELP: serve backend
serve-backend: CONTAINER_INTERACTIVE=-it serve-backend: CONTAINER_INTERACTIVE=-it
serve-backend: serve-backend:
DEV_PORT_HTTP=`docker/backend/dev_port.pl 3000 | tee .dev-port-http`; \ DEV_PORT_HTTP=`docker/backend/dev_port.pl 3000 | tee .dev-port-http`; \
@ -164,19 +188,23 @@ serve-backend:
DEV_PORT_HTTPS=`cat .dev-port-https`; \ DEV_PORT_HTTPS=`cat .dev-port-https`; \
./start.sh ./start.sh
# HELP(compile-backend): compile backend
.PHONY: --compile-backend .PHONY: --compile-backend
--compile-backend: --compile-backend:
stack build --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only --local-bin-path $$(pwd)/bin $(stackopts) stack build --fast --profile --library-profiling --executable-profiling --flag uniworx:-library-only --local-bin-path $$(pwd)/bin $(stackopts)
# HELP(lint-backend): lint backend
.PHONY: --lint-backend .PHONY: --lint-backend
--lint-backend: --lint-backend:
stack build --test --fast --flag uniworx:library-only uniworx:test:hlint $(stackopts) stack build --test --fast --flag uniworx:library-only uniworx:test:hlint $(stackopts)
# HELP(test-backend): test backend
.PHONY: --test-backend .PHONY: --test-backend
--test-backend: --test-backend:
stack build --test --coverage --fast --flag uniworx:library-only $(stackopts) stack build --test --coverage --fast --flag uniworx:library-only $(stackopts)
.PHONY: serve-database .PHONY: serve-database
# HELP: serve database
serve-database: CONTAINER_INTERACTIVE=-it serve-database: CONTAINER_INTERACTIVE=-it
serve-database: --containerized-database serve-database: --containerized-database
@ -230,6 +258,7 @@ serve-database: --containerized-database
$(MAKE) -- --image-run-$*-backend $(MAKE) -- --image-run-$*-backend
.PHONY: image-rebuild .PHONY: image-rebuild
# HELP: rebuild the stated docker image (frontend, backend, database instead of %)
image-rebuild-%: image-rebuild-%:
$(MAKE) -- --image-build FRADRIVE_SERVICE=$* NO_CACHE=--no-cache $(MAKE) -- --image-build FRADRIVE_SERVICE=$* NO_CACHE=--no-cache
.PHONY: --image-build .PHONY: --image-build
@ -259,6 +288,7 @@ image-rebuild-%:
.PHONY: i18n-check .PHONY: i18n-check
# HELP: check internationalization
i18n-check: --image-run---i18n-check i18n-check: --image-run---i18n-check
.PHONY: --i18n-check .PHONY: --i18n-check
--i18n-check: --i18n-check:

40
utils/makehelp.pl Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env perl
use strict;
use warnings;
my %msg = ();
my @start = ();
READ: while(<>) {
if(m/^# HELP HEADER START/) {
while(<>) {
next READ if m/^# HELP HEADER END/;
if(m/# (.*)/) {
push @start, $1
} else {
die "$0: Invalid HELP HEADER section in Makefile!\n";
}
}
next READ
}
if(m/# HELP((?:\([^\(\)]+\))?):\s*(.*)/) {
my ($target, $message) = ($1, $2);
if($target=~m/\((.*)\)/) {
$target = $1;
} else {
my $line = <>;
die "$0: Unexpected end of file, target expected!\n" if not defined $line;
$line=~m/^([^:]+):/ or die "$0: HELP marker expects target but no target found!\n";
$target = $1
}
$msg{$target} .= $message
}
}
print "$_\n" for @start;
print "\n" if @start;
for my $tar(sort keys %msg) {
print "$tar\n $msg{$tar}\n\n"
}