Makefile 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This is a simple Makefile that generates client library source code
  2. # for Google APIs using Protocol Buffers and gRPC for any supported
  3. # language. However, it does not compile the generated code into final
  4. # libraries that can be directly used with application code.
  5. #
  6. # Syntax example: make OUTPUT=./output LANGUAGE=java
  7. #
  8. # Choose the output directory
  9. OUTPUT ?= ./gens
  10. # Choose the target language.
  11. LANGUAGE ?= cpp
  12. # Choose grpc plugin
  13. GRPCPLUGIN ?= /usr/local/bin/grpc_$(LANGUAGE)_plugin
  14. # Choose the proto include directory.
  15. PROTOINCLUDE ?= /usr/local/include
  16. # Choose protoc binary
  17. PROTOC ?= protoc
  18. # Compile the entire repository
  19. #
  20. # NOTE: if "protoc" command is not in the PATH, you need to modify this file.
  21. #
  22. ifeq ($(LANGUAGE),go)
  23. $(error Go source files are not generated from this repository. See: https://github.com/google/go-genproto)
  24. endif
  25. FLAGS+= --proto_path=.:$(PROTOINCLUDE)
  26. FLAGS+= --$(LANGUAGE)_out=$(OUTPUT) --grpc_out=$(OUTPUT)
  27. FLAGS+= --plugin=protoc-gen-grpc=$(GRPCPLUGIN)
  28. SUFFIX:= pb.cc
  29. DEPS:= $(shell find google $(PROTOINCLUDE)/google/protobuf -type f -name '*.proto' | sed "s/proto$$/$(SUFFIX)/")
  30. all: $(DEPS)
  31. %.$(SUFFIX): %.proto
  32. mkdir -p $(OUTPUT)
  33. $(PROTOC) $(FLAGS) $*.proto
  34. clean:
  35. rm $(patsubst %,$(OUTPUT)/%,$(DEPS)) 2> /dev/null
  36. rm -rd $(OUTPUT)