-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
58 lines (48 loc) · 1.15 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
DIR = $(shell pwd)
CMD = $(DIR)/cmd
CONFIG_PATH = $(DIR)/config
IDL_PATH = $(DIR)/idl
OUTPUT_PATH = $(DIR)/output
SERVICES := template empty_room
service = $(word 1, $@)
# mock gen
MOCKS := user_mock
mock = $(word 1, $@)
PERFIX = "[Makefile]"
.PHONY: env-up
env-up:
@ docker compose -f ./docker/docker-compose.yml up -d
.PHONY: env-down
env-down:
@ cd ./docker && docker compose down
# build specific target
.PHONY: $(SERVICES)
$(SERVICES):
mkdir -p output
cd $(CMD)/$(service) && sh build.sh
cd $(CMD)/$(service)/output && cp -r . $(OUTPUT_PATH)/$(service)
@echo "$(PERFIX) Build $(service) target completed"
ifndef autorun
@echo "$(PERFIX) Automatic run server"
sh entrypoint.sh $(service)
endif
# mock
.PHONY: $(MOCKS)
$(MOCKS):
@mkdir -p mocks
mockgen -source=./idl/$(mock).go -destination=./mocks/$(mock).go -package=mocks
# clean targets
.PHONY: clean
clean:
@find . -type d -name "output" -exec rm -rf {} + -print
# build all
.PHONY: build-all
build-all:
@for var in $(SERVICES); do \
echo "$(PERFIX) building $$var service"; \
make $$var autorun=1; \
done
# use docker instead to run projects
.PHONY: docker
docker:
docker build -t fzuhelper .