-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (65 loc) · 3.39 KB
/
Makefile
File metadata and controls
88 lines (65 loc) · 3.39 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
PROTOCCMD = protoc
PROTOGEN_PATH = $(shell which protoc-gen-go)
PROTOGENGRPC_PATH = $(shell which protoc-gen-go-grpc)
GO_FILES := $(shell find $(SRC_DIR) -name '*.go')
GOCMD := go
GOBUILD := $(GOCMD) build
GOCLEAN := $(GOCMD) clean
LDFLAGS := -s -w
ifeq ($(OS), Windows_NT)
DEFAULT_BUILD_FILENAME := StealthIMFileAPI.exe
else
DEFAULT_BUILD_FILENAME := StealthIMFileAPI
endif
.PHONY: run
run: build
./bin/$(DEFAULT_BUILD_FILENAME)
StealthIM.FileAPI/fileapi_grpc.pb.go StealthIM.FileAPI/fileapi.pb.go: proto/fileapi.proto
$(PROTOCCMD) --plugin=protoc-gen-go=$(PROTOGEN_PATH) --plugin=protoc-gen-go-grpc=$(PROTOGENGRPC_PATH) --go-grpc_out=. --go_out=. proto/fileapi.proto
StealthIM.FileStorage/filestorage_grpc.pb.go StealthIM.FileStorage/filestorage.pb.go: proto/filestorage.proto
$(PROTOCCMD) --plugin=protoc-gen-go=$(PROTOGEN_PATH) --plugin=protoc-gen-go-grpc=$(PROTOGENGRPC_PATH) --go-grpc_out=. --go_out=. proto/filestorage.proto
StealthIM.DBGateway/db_gateway_grpc.pb.go StealthIM.DBGateway/db_gateway.pb.go: proto/db_gateway.proto
$(PROTOCCMD) --plugin=protoc-gen-go=$(PROTOGEN_PATH) --plugin=protoc-gen-go-grpc=$(PROTOGENGRPC_PATH) --go-grpc_out=. --go_out=. proto/db_gateway.proto
StealthIM.MSAP/msap_grpc.pb.go StealthIM.MSAP/msap.pb.go: proto/msap.proto
$(PROTOCCMD) --plugin=protoc-gen-go=$(PROTOGEN_PATH) --plugin=protoc-gen-go-grpc=$(PROTOGENGRPC_PATH) --go-grpc_out=. --go_out=. proto/msap.proto
.PHONY: proto
proto: ./StealthIM.FileAPI/fileapi_grpc.pb.go ./StealthIM.FileAPI/fileapi.pb.go StealthIM.FileStorage/filestorage_grpc.pb.go StealthIM.FileStorage/filestorage.pb.go ./StealthIM.DBGateway/db_gateway_grpc.pb.go ./StealthIM.DBGateway/db_gateway.pb.go ./StealthIM.MSAP/msap_grpc.pb.go ./StealthIM.MSAP/msap.pb.go
.PHONY: build
build: ./bin/$(DEFAULT_BUILD_FILENAME)
./bin/StealthIMFileAPI.exe: $(GO_FILES) proto
GOOS=windows GOARCH=amd64 go build -ldflags="$(LDFLAGS)" -o ./bin/StealthIMFileAPI.exe
./bin/StealthIMFileAPI: $(GO_FILES) proto
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ./bin/StealthIMFileAPI
.PHONY: build_run build_linux
build_win: ./bin/StealthIMFileAPI.exe
build_linux: ./bin/StealthIMFileAPI
.PHONY: docker_run
docker_run:
docker-compose up
./bin/StealthIMFileAPI.docker.zst: $(GO_FILES) proto
docker-compose build
docker save stealthimfileapi-app > ./bin/StealthIMFileAPI.docker
zstd ./bin/StealthIMFileAPI.docker -19
@rm ./bin/StealthIMFileAPI.docker
.PHONY: build_docker
build_docker: ./bin/StealthIMFileAPI.docker.zst
.PHONY: release
release: build_win build_linux build_docker
.PHONY: clean
clean:
@rm -rf ./StealthIM.*
@rm -rf ./bin
@rm -rf ./__debug*
.PHONY: dev
dev:
./run_env.sh
.PHONY: debug_proto
debug_proto:
cd test && python -m grpc_tools.protoc -I. --python_out=. --mypy_out=. --grpclib_python_out=. --proto_path=../proto fileapi.proto
./tool/stimfileapi/proto/fileapi_grpc.py ./tool/stimfileapi/proto/fileapi_pb2.py ./tool/stimfileapi/proto/fileapi_pb2.pyi: proto/fileapi.proto
@mkdir -p tool/stimfileapi/proto
python -m grpc_tools.protoc -Iproto --python_out=./tool/stimfileapi/proto --grpclib_python_out=./tool/stimfileapi/proto --mypy_out=./tool/stimfileapi/proto proto/fileapi.proto
@echo "Rewrite File"
@sed -i 's/import fileapi_pb2/from . import fileapi_pb2/g' ./tool/stimfileapi/proto/fileapi_grpc.py
.PHONY: proto_t
proto_t: ./tool/stimfileapi/proto/fileapi_grpc.py ./tool/stimfileapi/proto/fileapi_pb2.py ./tool/stimfileapi/proto/fileapi_pb2.pyi