generated from pieceowater-dev/lotof.sample.svc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
70 lines (58 loc) · 1.89 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
59
60
61
62
63
64
65
66
67
68
69
70
# Project configuration
APP_NAME = lotof.atrace.msvc.tracker
BUILD_DIR = bin
MAIN_FILE = cmd/server/main.go
PROTOC = protoc
PROTOC_GEN_GO = $(GOPATH)/bin/protoc-gen-go
PROTOC_GEN_GRPC_GO = $(GOPATH)/bin/protoc-gen-go-grpc
PROTOC_PKG = github.com/pieceowater-dev/lotof.atrace.proto
EXTERNAL_PROTOC_PKG = github.com/pieceowater-dev/lotof.hub.proto
PROTOC_PKG_PATH = $(shell go list -m -f '{{.Dir}}' $(PROTOC_PKG))
EXTERNAL_PROTOC_PKG_PATH = $(shell go list -m -f '{{.Dir}}' $(EXTERNAL_PROTOC_PKG))
PROTOC_DIR = protos
EXTERNAL_PROTOC_DIR = protos/lotof.hub.gtw
PROTOC_OUT_DIR = ./internal/core/grpc/generated
export PATH := /usr/local/bin:$(PATH)
.PHONY: all clean build run update setup grpc-gen grpc-clean grpc-update
# Default build target
all: build
# Setup the environment
setup: grpc-update
@echo "Setup completed!"
go mod tidy
# Update dependencies
update:
go mod tidy
# Build the project
build:
@mkdir -p $(BUILD_DIR)
go build -o $(BUILD_DIR)/$(APP_NAME) $(MAIN_FILE)
# Run the application
run: build
./$(BUILD_DIR)/$(APP_NAME)
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR) gql-clean grpc-clean
# gRPC code generation
grpc-gen:
@echo "Generating gRPC code from proto files..."
mkdir -p $(PROTOC_OUT_DIR)
find $(PROTOC_PKG_PATH)/$(PROTOC_DIR) -name "*.proto" | xargs $(PROTOC) \
-I $(PROTOC_PKG_PATH)/$(PROTOC_DIR) \
--go_out=$(PROTOC_OUT_DIR) \
--go-grpc_out=$(PROTOC_OUT_DIR)
@echo "gRPC code generation completed!"
grpc-gen-external:
@echo "Generating gRPC code from proto files..."
mkdir -p $(PROTOC_OUT_DIR)
find $(EXTERNAL_PROTOC_PKG_PATH)/$(PROTOC_DIR) -name "*.proto" | xargs $(PROTOC) \
-I $(EXTERNAL_PROTOC_PKG_PATH)/$(PROTOC_DIR) \
--go_out=$(PROTOC_OUT_DIR) \
--go-grpc_out=$(PROTOC_OUT_DIR)
@echo "gRPC code generation completed!"
# Clean gRPC generated files
grpc-clean:
rm -rf $(PROTOC_OUT_DIR)
# Update gRPC dependencies
grpc-update:
go get -u $(PROTOC_PKG)@latest