From 023996b276569a3c73afd01a8d55f70420561660 Mon Sep 17 00:00:00 2001 From: guochao Date: Fri, 28 Apr 2023 00:18:19 +0800 Subject: [PATCH] add Makefile to automate building --- Makefile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..761fc82 --- /dev/null +++ b/Makefile @@ -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 $<