build(Makefile): unified phonyness of '--'-targets.

This commit is contained in:
Stephan Barth 2024-09-23 12:21:18 +02:00
parent 829058aea4
commit 371cdf1e3e

View File

@ -23,6 +23,8 @@ export DEV_PORT_HTTPS
########################### ###########################
##### GENERAL TARGETS ##### ##### GENERAL TARGETS #####
.PHONY: --%
.PHONY: help .PHONY: help
# HELP: print out this help message # HELP: print out this help message
help: help:
@ -32,11 +34,6 @@ help:
utils/makehelp.pl Makefile ; \ utils/makehelp.pl Makefile ; \
fi fi
.PHONY: all
# HELP: unfinished
all:
@echo "TODO"
.PHONY: clean .PHONY: clean
# HELP: remove all compilation results in the directory but leave containers and images unharmed # HELP: remove all compilation results in the directory but leave containers and images unharmed
clean: clean:
@ -105,11 +102,9 @@ test: test-frontend test-backend i18n-check
%-frontend: FRADRIVE_SERVICE=frontend %-frontend: FRADRIVE_SERVICE=frontend
%-frontend: --image-build --containerized---%-frontend; %-frontend: --image-build --containerized---%-frontend;
.PHONY: --%-frontend
--%-frontend: --containerized---frontend-dependencies-frontend; --%-frontend: --containerized---frontend-dependencies-frontend;
# HELP(compile-frontend): compile frontend # HELP(compile-frontend): compile frontend
.PHONY: --compile-frontend
--compile-frontend: --frontend-dependencies --compile-frontend: --frontend-dependencies
npx -- webpack --progress $(WATCH) npx -- webpack --progress $(WATCH)
@ -119,23 +114,19 @@ serve-frontend: CONTAINER_INTERACTIVE=-it
serve-frontend: serve-frontend:
$(MAKE) -- --containerized---compile-frontend WATCH=--watch $(MAKE) -- --containerized---compile-frontend WATCH=--watch
# .PHONY: --serve-frontend
# --serve-frontend: WATCH=--watch # --serve-frontend: WATCH=--watch
# --serve-frontend: --compile-frontend; # --serve-frontend: --compile-frontend;
# HELP(lint-frontend): lint frontend # HELP(lint-frontend): 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 # HELP(test-frontend): 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.
# npx -- karma start --conf karma.conf.cjs $(WATCH) # npx -- karma start --conf karma.conf.cjs $(WATCH)
.PHONY: --frontend-dependencies
--frontend-dependencies: node_modules package.json package-lock.json assets; --frontend-dependencies: node_modules package.json package-lock.json assets;
node_modules: package.json package-lock.json node_modules: package.json package-lock.json
@ -169,12 +160,10 @@ well-known: node_modules assets
%-prod-backend: FRADRIVE_SERVICE=backend %-prod-backend: FRADRIVE_SERVICE=backend
%-prod-backend: --image-build --containerized---%-prod-backend; %-prod-backend: --image-build --containerized---%-prod-backend;
.PHONY: --%-dev-backend
--%-dev-backend: FRADRIVE_SERVICE=backend --%-dev-backend: FRADRIVE_SERVICE=backend
--%-dev-backend: stackopts=--flag uniworx:dev --%-dev-backend: stackopts=--flag uniworx:dev
--%-dev-backend: --image-build --containerized---%-backend; --%-dev-backend: --image-build --containerized---%-backend;
.PHONY: --%-prod-backend
--%-prod-backend: FRADRIVE_SERVICE=backend --%-prod-backend: FRADRIVE_SERVICE=backend
--%-prod-backend: stackopts=--flag uniworx:-dev --%-prod-backend: stackopts=--flag uniworx:-dev
--%-prod-backend: --image-build --containerized-%-backend; --%-prod-backend: --image-build --containerized-%-backend;
@ -186,24 +175,20 @@ 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`; \
DEV_PORT_HTTPS=`docker/backend/dev_port.pl 3443 | tee .dev-port-https`; \ DEV_PORT_HTTPS=`docker/backend/dev_port.pl 3443 | tee .dev-port-https`; \
$(MAKE) -- --containerized---serve-dev-backend DEV_PORT_HTTP=$${DEV_PORT_HTTP} DEV_PORT_HTTPS=$${DEV_PORT_HTTPS} $(MAKE) -- --containerized---serve-dev-backend DEV_PORT_HTTP=$${DEV_PORT_HTTP} DEV_PORT_HTTPS=$${DEV_PORT_HTTPS}
.PHONY: --serve-dev-backend
--serve-dev-backend: start.sh --serve-dev-backend: start.sh
DEV_PORT_HTTP=`cat .dev-port-http`; \ DEV_PORT_HTTP=`cat .dev-port-http`; \
DEV_PORT_HTTPS=`cat .dev-port-https`; \ DEV_PORT_HTTPS=`cat .dev-port-https`; \
./start.sh ./start.sh
# HELP(compile-backend): compile backend # HELP(compile-backend): 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 # HELP(lint-backend): 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 # HELP(test-backend): 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)
@ -215,7 +200,6 @@ serve-database: --containerized-database
.PHONY: %-database .PHONY: %-database
%-database: %-database:
$(MAKE) -- --containerized---$*-database-backend $(MAKE) -- --containerized---$*-database-backend
.PHONY: --%-database
--%-database: .stack --%-database: .stack
SERVER_SESSION_ACID_FALLBACK=${SERVER_SESSION_ACID_FALLBACK:-true} ; \ SERVER_SESSION_ACID_FALLBACK=${SERVER_SESSION_ACID_FALLBACK:-true} ; \
AVSPASS=${AVSPASS:-nopasswordset} ; \ AVSPASS=${AVSPASS:-nopasswordset} ; \
@ -224,7 +208,6 @@ serve-database: --containerized-database
.stack: stack.yaml stack.yaml.lock .stack: stack.yaml stack.yaml.lock
.stack: .stack:
$(MAKE) -- --image-run---.stack $(MAKE) -- --image-run---.stack
.PHONY: --.stack
--.stack: stack.yaml stack.yaml.lock --.stack: stack.yaml stack.yaml.lock
stack build --fast --only-dependencies $(stackopts) stack build --fast --only-dependencies $(stackopts)
@ -239,7 +222,6 @@ serve-database: --containerized-database
############################# #############################
##### CONTAINER TARGETS ##### ##### CONTAINER TARGETS #####
.PHONY: --containerized-database
--containerized-database: FRADRIVE_SERVICE=database --containerized-database: FRADRIVE_SERVICE=database
# port forwarding is disabled in --network=host mode; nevertheless it is stated here for documentation reasons # port forwarding is disabled in --network=host mode; nevertheless it is stated here for documentation reasons
--containerized-database: CONTAINER_PORTS=-p 5432:5432/tcp --containerized-database: CONTAINER_PORTS=-p 5432:5432/tcp
@ -248,13 +230,11 @@ serve-database: --containerized-database
$(CONTAINER_COMMAND) run -it $(CONTAINER_PORTS) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$(FRADRIVE_SERVICE) ; \ $(CONTAINER_COMMAND) run -it $(CONTAINER_PORTS) --name fradrive.$(FRADRIVE_SERVICE).$$(date +'%Y-%m-%dT%H-%M-%S') fradrive/$(FRADRIVE_SERVICE) ; \
fi fi
.PHONY: --containerized-%-frontend
--containerized-%-frontend: FRADRIVE_SERVICE=frontend --containerized-%-frontend: FRADRIVE_SERVICE=frontend
#--containerized-%-frontend: --image-build --image-run-%-frontend; #--containerized-%-frontend: --image-build --image-run-%-frontend;
--containerized-%-frontend: --image-build --containerized-%-frontend: --image-build
$(MAKE) -- --image-run-$*-frontend $(MAKE) -- --image-run-$*-frontend
.PHONY: --containerized-%-backend
--containerized-%-backend: FRADRIVE_SERVICE=backend --containerized-%-backend: FRADRIVE_SERVICE=backend
#--containerized-%-backend: --image-build --image-run-%-backend; #--containerized-%-backend: --image-build --image-run-%-backend;
--containerized-%-backend: CONTAINER_PORTS=-p 127.0.0.1:$(DEV_PORT_HTTP):3000/tcp -p 127.0.0.1:$(DEV_PORT_HTTPS):3443/tcp --containerized-%-backend: CONTAINER_PORTS=-p 127.0.0.1:$(DEV_PORT_HTTP):3000/tcp -p 127.0.0.1:$(DEV_PORT_HTTPS):3443/tcp
@ -265,7 +245,6 @@ serve-database: --containerized-database
# HELP: rebuild the stated docker image (frontend, backend, database instead of %) # 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
--image-build: --image-build:
rm -f .Dockerfile rm -f .Dockerfile
ln -s docker/$(FRADRIVE_SERVICE)/Dockerfile .Dockerfile ln -s docker/$(FRADRIVE_SERVICE)/Dockerfile .Dockerfile
@ -278,7 +257,6 @@ image-rebuild-%:
$(CONTAINER_COMMAND) build $(NO_CACHE) -v $(PWD):$${MOUNT_DIR} --env IN_CONTAINER=true --build-arg MOUNT_DIR=$${MOUNT_DIR} --build-arg PROJECT_DIR=$${PROJECT_DIR} --tag fradrive/$(FRADRIVE_SERVICE) --file $(PWD)/.Dockerfile ; \ $(CONTAINER_COMMAND) build $(NO_CACHE) -v $(PWD):$${MOUNT_DIR} --env IN_CONTAINER=true --build-arg MOUNT_DIR=$${MOUNT_DIR} --build-arg PROJECT_DIR=$${PROJECT_DIR} --tag fradrive/$(FRADRIVE_SERVICE) --file $(PWD)/.Dockerfile ; \
fi fi
.PHONY: --image-run-%
--image-run-%: --image-run-%:
MOUNT_DIR=/mnt/fradrive; \ MOUNT_DIR=/mnt/fradrive; \
if [ "$(IN_CONTAINER)" == "true" ] ; then \ if [ "$(IN_CONTAINER)" == "true" ] ; then \
@ -294,7 +272,6 @@ image-rebuild-%:
.PHONY: i18n-check .PHONY: i18n-check
# HELP: check internationalization # HELP: check internationalization
i18n-check: --image-run---i18n-check i18n-check: --image-run---i18n-check
.PHONY: --i18n-check
--i18n-check: --i18n-check:
./missing-translations.sh ./missing-translations.sh
@echo No missing translations. @echo No missing translations.