2016-12-13 10:36:55 +01:00
|
|
|
SOURCES := $(shell find . -name "*.proto" -not -path ./vendor/\*)
|
|
|
|
|
|
|
|
TARGETS_GO := $(foreach source, $(SOURCES), $(source)_go)
|
|
|
|
TARGETS_TMPL := $(foreach source, $(SOURCES), $(source)_tmpl)
|
|
|
|
|
2016-12-13 16:11:50 +01:00
|
|
|
service_name = $(word 2,$(subst /, ,$1))
|
|
|
|
|
2016-12-13 10:36:55 +01:00
|
|
|
.PHONY: build
|
2016-12-13 16:03:16 +01:00
|
|
|
build: server
|
|
|
|
|
|
|
|
server: $(TARGETS_GO) $(TARGETS_TMPL)
|
2017-03-16 15:41:09 +01:00
|
|
|
go get ./...
|
2016-12-13 16:03:16 +01:00
|
|
|
go build -o server .
|
2016-12-13 10:36:55 +01:00
|
|
|
|
|
|
|
$(TARGETS_GO): %_go:
|
2017-03-16 15:41:09 +01:00
|
|
|
protoc --go_out=plugins=grpc:. "$*"
|
2016-12-13 16:11:50 +01:00
|
|
|
@mkdir -p services/$(call service_name,$*)/gen/pb
|
|
|
|
@mv ./services/$(call service_name,$*)/$(call service_name,$*).pb.go ./services/$(call service_name,$*)/gen/pb/pb.go
|
2016-12-13 10:36:55 +01:00
|
|
|
|
|
|
|
$(TARGETS_TMPL): %_tmpl:
|
|
|
|
@mkdir -p $(dir $*)gen
|
2016-12-15 16:30:14 +01:00
|
|
|
protoc -I. --gotemplate_out=destination_dir=services/$(call service_name,$*)/gen,template_dir=templates:services "$*"
|
2016-12-13 11:05:06 +01:00
|
|
|
@rm -rf services/services # need to investigate why this directory is created
|
2016-12-13 10:59:34 +01:00
|
|
|
gofmt -w $(dir $*)gen
|