-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
72 lines (57 loc) · 1.55 KB
/
Makefile
File metadata and controls
72 lines (57 loc) · 1.55 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Basic commands
CLEAN := rm -f $(BINARY_OUTPUT)
ifeq ($(OS), Windows_NT)
CLEAN := del /q/s $(BINARY_OUTPUT) 2>&1 | exit 0
endif
# App info
BINARY_NAME := spotify.server
ENTRY_MAIN := ./bin/gateway
BINARY_NAME_GRPC := spotify.grpc
ENTRY_GRPC := ./bin/processor
PROTO_FILES := ./protocols
# Folders
OUTPUT_FOLDER := .build
BINARY_OUTPUT := $(OUTPUT_FOLDER)/$(BINARY_NAME)
BINARY_OUTPUT_GRPC := $(OUTPUT_FOLDER)/${BINARY_NAME_GRPC}
ifeq ($(OS), Windows_NT)
OUTPUT_FOLDER := .\.build
BINARY_OUTPUT := $(OUTPUT_FOLDER)\$(BINARY_NAME).exe
BINARY_OUTPUT_GRPC := $(OUTPUT_FOLDER)\${BINARY_NAME_GRPC}.exe
endif
.PHONY: setup ## Install all the build dependencies
setup:
@echo Updating dependency tree...
go mod tidy
go mod download
@echo Updated dependency tree successfully.
.PHONY: default
default: clean fmt build run
generate-proto:
protoc --go_out=. \
--go_opt=paths=source_relative \
--go-grpc_out=. \
--go-grpc_opt=paths=source_relative \
$(PROTO_FILES)/*.proto
build-container:
@echo building container...
docker compose up -d --build
@echo container built successfully.
build-grpc:
@echo Building grpc binary...
@go build -o $(BINARY_OUTPUT_GRPC) $(ENTRY_GRPC)
@echo Built grpc binary successfully.
build-server:
@echo Building server binary...
@go build -o $(BINARY_OUTPUT) $(ENTRY_MAIN)
@echo Built server binary successfully.
clean:
@go clean -i . && $(CLEAN)
fmt:
@gofmt -s -w -l .
build: build-grpc build-server
test:
@cd .example && npm run dev
run-grpc:
@$(BINARY_OUTPUT_GRPC)
run-server:
@$(BINARY_OUTPUT)