22# Copyright (C) 2022 Intel Corporation
33# Copyright (c) 2022 Dell Inc, or its subsidiaries.
44
5- all :
6- rm -rf ./v1/{autogen.md,gen}
7- mkdir -p ./v1/gen/{go,cpp,python}
5+ # Make a variable named ','. Used to pass arguments with commas to protoc_compile.
6+ , := ,
87
9- docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l go -o ./v1/gen/go/ --go-source-relative
10- docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l cpp -o ./v1/gen/cpp/ --go-source-relative
11- docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}":/defs -v "${PWD}/../common/v1":/common namely/protoc-all:1.47_2 -i /common --lint -d v1 -l python -o ./v1/gen/python/ --go-source-relative
8+ CURRENT_VERSION := v1
129
13- # protoc-gen-doc doesn't support proto include paths parameter so we have to copy
14- # common included files to the proto directory
15- cp ../common/v1/uuid.proto "${PWD}"/v1
16- cp ../common/v1/object_key.proto "${PWD}"/v1
10+ define protoc_compile
11+ mkdir -p $(CURRENT_VERSION ) /gen/$(1 )
12+ protoc --proto_path=../common/$(CURRENT_VERSION ) --proto_path=$(CURRENT_VERSION ) \
13+ --$(1 ) _out=$(CURRENT_VERSION ) /gen/$(1 ) \
14+ $(2 ) \
15+ $(CURRENT_VERSION ) /*.proto
16+ endef
1717
18- docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -v "${PWD}"/v1:/protos pseudomuto/protoc-gen-doc --doc_opt=markdown,autogen.md
19- docker run --user=$$(id -u):$$(id -g) --rm -v "${PWD}"/v1/:/out -w /out --entrypoint=sh ghcr.io/docker-multiarch/google-api-linter:1.36.0 -c "api-linter /out/*.proto --output-format summary"
18+ all : python cpp go doc lint
2019
21- # remove common included files from the proto directory
22- rm "${PWD}"/v1/uuid.proto
23- rm "${PWD}"/v1/object_key.proto
20+ python :
21+ $(call protoc_compile,python,)
22+
23+ cpp :
24+ $(call protoc_compile,cpp,)
25+
26+ go :
27+ $(call protoc_compile,go,)
28+ mv $(CURRENT_VERSION ) /gen/go/github.com/opiproject/opi-api/storage/v1/gen/go/* $(CURRENT_VERSION ) /gen/go/
29+
30+ doc :
31+ $(call protoc_compile,doc,--doc_opt=markdown$(, ) autogen.md)
32+
33+ lint :
34+ $(call protoc_compile,lint)
35+
36+ clean :
37+ rm -rf gen
0 commit comments