.PHONY:all

clean:
	rm -rf ./gen/proto* /gen/openapi2/*

gofmt:
	find . -name "*.go" \
		-not -path "./gen" \
		-not -path ".git/*" \
		| xargs gofmt -s -d -w 

all:
	protoc \
		--proto_path  ./protos \
        --go_out      ./gen/proto --go_opt      paths=source_relative \
        --go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
		--grpc-gateway_out ./gen/proto \
		--grpc-gateway_opt paths=source_relative \
		--grpc-gateway_opt logtostderr=true \
		--grpc-gateway_opt generate_unbound_methods=true \
		--openapiv2_out ./gen/openapi2 \
		--openapiv2_opt logtostderr=true \
        ./protos/echo/v1/echo.proto

grpc:
	protoc \
		--proto_path  ./protos \
        --go_out      ./gen/proto --go_opt      paths=source_relative \
        --go-grpc_out ./gen/proto --go-grpc_opt paths=source_relative \
        ./protos/echo/v1/echo.proto

gateway:
	protoc \
		--proto_path  ./protos \
		--grpc-gateway_out ./gen/proto \
		--grpc-gateway_opt paths=source_relative \
		--grpc-gateway_opt logtostderr=true \
		--grpc-gateway_opt generate_unbound_methods=true \
		./protos/echo/v1/echo.proto

openapi:
	protoc \
		--proto_path  ./protos \
		--openapiv2_out ./gen/openapi2 \
		--openapiv2_opt logtostderr=true \
		/protos/echo/v1/echo.proto