Makefile reworked.

This commit is contained in:
Philippe PITTOLI 2024-06-22 00:54:22 +02:00
parent bbf7a9a80e
commit 16b2869827
2 changed files with 20 additions and 56 deletions

View File

@ -1,17 +0,0 @@
#!/bin/sh
# Should we run the build?
if [ $# -lt 1 ]; then
exec >& 2
echo "Usage: $0 <exe>"
exit 1
fi
exe=$1
# If the binary hasn't already be compiled.
[ -f "${exe}" ] || exit 0
v=`find src/ -type f -newer "${exe}" | wc -l`
test "${v}" != "0"

View File

@ -1,7 +1,6 @@
all: build-server all: build-server
Q ?= @ Q ?= @
SHOULD_UPDATE = ./bin/should-update
OPTS ?= --progress OPTS ?= --progress
NAME ?= John NAME ?= John
@ -15,6 +14,8 @@ else
LOGIN_OPT = -l $(LOGIN) LOGIN_OPT = -l $(LOGIN)
endif endif
SOURCE_FILES = $(wildcard src/*.cr src/*/*.cr src/*/*/*.cr)
################## ##################
### SETUP COMMANDS ### SETUP COMMANDS
################## ##################
@ -36,46 +37,32 @@ add-first-user:
### REQUEST EXAMPLES ### REQUEST EXAMPLES
#################### ####################
add-user:
./bin/authc user add $(NAME) $(EMAIL) $(LOGIN_OPT)
register:
./bin/authc user register $(NAME) $(EMAIL)
ACTIVATION_KEY ?= put-your-key-here ACTIVATION_KEY ?= put-your-key-here
validate: add-user:; $(Q)./bin/authc user add $(NAME) $(EMAIL) $(LOGIN_OPT)
./bin/authc user validate $(NAME) $(ACTIVATION_KEY) register:; $(Q)./bin/authc user register $(NAME) $(EMAIL)
validate:; $(Q)./bin/authc user validate $(NAME) $(ACTIVATION_KEY)
get-user: get-user:; $(Q)./bin/authc user get $(NAME) $(LOGIN_OPT)
./bin/authc user get $(NAME) $(LOGIN_OPT)
migrate-user:
./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT)
USER_DB ?= /tmp/authd-migration-user-db.txt USER_DB ?= /tmp/authd-migration-user-db.txt
migrate-all-users: migrate-user:; ./bin/authc user migrate $(NAME) $(PASSWORD_HASH) $(LOGIN_OPT)
./bin/authc migration-script $(USER_DB) $(LOGIN_OPT) migrate-all-users:; ./bin/authc migration-script $(USER_DB) $(LOGIN_OPT)
SERVICE ?= 'auth' SERVICE ?= 'auth'
RESOURCE ?= '*' RESOURCE ?= '*'
UID ?= 1000 UID ?= 1000
permission-check:
./bin/authc permission check $(UID) $(SERVICE) $(RESOURCE) $(LOGIN_OPT)
PERMISSION ?= Read PERMISSION ?= Read
permission-set: permission-check:; ./bin/authc permission check $(UID) $(SERVICE) $(RESOURCE) $(LOGIN_OPT)
./bin/authc permission set $(UID) $(SERVICE) $(RESOURCE) $(PERMISSION) $(LOGIN_OPT) permission-set:; ./bin/authc permission set $(UID) $(SERVICE) $(RESOURCE) $(PERMISSION) $(LOGIN_OPT)
################### ###################
### DEVELOPER TOOLS ### DEVELOPER TOOLS
################### ###################
build-server: bin/authd: $(SOURCE_FILES); $(Q)shards build authd $(OPTS)
$(Q)-$(SHOULD_UPDATE) bin/authd && shards build authd $(OPTS) bin/authc: $(SOURCE_FILES); $(Q)shards build authc $(OPTS)
build-client: build-server: bin/authd
$(Q)-$(SHOULD_UPDATE) bin/authc && shards build authc $(OPTS) build-client: bin/authc
build: build-server build-client build: build-server build-client
doc: doc:
@ -88,18 +75,12 @@ DIR ?= docs
serve-doc: serve-doc:
darkhttpd $(DIR) --addr $(HTTPD_ADDR) --port $(HTTPD_PORT) --log $(HTTPD_ACCESS_LOGS) darkhttpd $(DIR) --addr $(HTTPD_ADDR) --port $(HTTPD_PORT) --log $(HTTPD_ACCESS_LOGS)
print-messages: print-messages:; cat src/requests/*.cr | ./bin/get-messages.awk
cat src/requests/*.cr | ./bin/get-messages.awk print-message-numbers:; make -s print-messages | grep -E "^[0-9]" | sort -n
print-message-numbers: print-messages-no-comments:; make -s print-messages | grep -vE '^[[:blank:]]+#'
make -s print-messages | grep -E "^[0-9]" | sort -n print-response-messages:; cat src/responses/*.cr | ./bin/get-messages.awk
print-messages-without-comments: print-response-message-numbers:; make -s print-response-messages | grep -E "^[0-9]" | sort -n
make -s print-messages | grep -vE '^[[:blank:]]+#' print-response-messages-no-comments:; make -s print-response-messages | grep -vE '^[[:blank:]]+#'
print-response-messages:
cat src/responses/*.cr | ./bin/get-messages.awk
print-response-message-numbers:
make -s print-response-messages | grep -E "^[0-9]" | sort -n
print-response-messages-without-comments:
make -s print-response-messages | grep -vE '^[[:blank:]]+#'
wipe-db: wipe-db:
rm -r $(DATA_DIRECTORY) rm -r $(DATA_DIRECTORY)