|
| 1 | +# Code generation |
| 2 | +# ----------------------------------------------------------------------------- |
| 3 | +PROTO_ROOT = flagd-schemas/protobuf |
| 4 | +PROTOS += $(PROTO_ROOT)/flagd/evaluation/v1/evaluation.proto |
| 5 | +GEN_SWIFT_ROOT = Sources/Flagd/Generated |
| 6 | +GEN_SWIFTS = $(patsubst $(PROTO_ROOT)/%.proto,$(GEN_SWIFT_ROOT)/%.pb.swift,$(PROTOS)) |
| 7 | +GEN_GRPC_SWIFTS = $(subst $(PROTO_ROOT),$(GEN_SWIFT_ROOT),$(PROTOS:.proto=.grpc.swift)) |
| 8 | +PROTOC_GEN_SWIFT = .build/debug/protoc-gen-swift |
| 9 | +PROTOC_GEN_GRPC_SWIFT = .build/debug/protoc-gen-grpc-swift |
| 10 | + |
| 11 | +$(PROTOC_GEN_SWIFT): |
| 12 | + swift build --product protoc-gen-swift |
| 13 | + |
| 14 | +$(PROTOC_GEN_GRPC_SWIFT): |
| 15 | + swift build --product protoc-gen-grpc-swift |
| 16 | + |
| 17 | +$(GEN_SWIFTS): $(PROTOS) $(PROTOC_GEN_SWIFT) |
| 18 | + @mkdir -pv $(GEN_SWIFT_ROOT) |
| 19 | + protoc $(PROTOS) \ |
| 20 | + --proto_path=$(PROTO_ROOT) \ |
| 21 | + --plugin=$(PROTOC_GEN_SWIFT) \ |
| 22 | + --swift_out=$(GEN_SWIFT_ROOT) \ |
| 23 | + --swift_opt=Visibility=Internal \ |
| 24 | + --experimental_allow_proto3_optional |
| 25 | + |
| 26 | +$(GEN_GRPC_SWIFTS): $(PROTOS) $(PROTOC_GEN_GRPC_SWIFT) |
| 27 | + @mkdir -pv $(GEN_SWIFT_ROOT) |
| 28 | + protoc $(PROTOS) \ |
| 29 | + --proto_path=$(PROTO_ROOT) \ |
| 30 | + --plugin=$(PROTOC_GEN_GRPC_SWIFT) \ |
| 31 | + --plugin=$(PROTOC_GEN_SWIFT) \ |
| 32 | + --swift_out=$(GEN_SWIFT_ROOT) \ |
| 33 | + --swift_opt=Visibility=Internal \ |
| 34 | + --grpc-swift_out=Client=true,Server=false:$(GEN_SWIFT_ROOT) |
| 35 | + |
| 36 | +.PHONY: generate |
| 37 | +generate: $(GEN_SWIFTS) $(GEN_GRPC_SWIFTS) |
| 38 | + |
| 39 | +.PHONY: delete-generated-code |
| 40 | +delete-generated-code: # Delete all pb.swift and .grpc.swift files. |
| 41 | + @read -p "Delete all *.pb.swift and *.grpc.swift files in Sources/Flagd [y/N]" ans && [ $${ans:-N} = y ] |
| 42 | + find Sources -name *.pb.swift -delete -o -name *.grpc.swift -delete |
0 commit comments