add Makefile to automate building

This commit is contained in:
guochao 2023-04-28 00:18:19 +08:00
parent df51451e47
commit 023996b276
Signed by: guochao
GPG Key ID: 79F7306D2AA32FC3

22
Makefile Normal file
View File

@ -0,0 +1,22 @@
PROTOC ?= $(shell which protoc)
PROTOS := $(shell find -name '*.proto')
PROTO_GEN_PB := $(subst .proto,.pb.go,$(PROTOS))
PROTO_GEN_GRPC := $(subst .proto,_grpc.pb.go,$(PROTOS))
GO_SRC := $(shell find -name '*.go')
.PHONY: all
all: build
.PHONY: build
build: bin/signal-server
bin/%: $(GO_SRC) $(PROTO_GEN_PB) $(PROTO_GEN_GRPC)
go build -o $@ ./$<
%_grpc.pb.go: %.proto
protoc --go-grpc_out=. --go-grpc_opt=paths=source_relative $<
%.pb.go: %.proto
protoc --go_out=. --go_opt=paths=source_relative $<