github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/Makefile (about)

     1  # This is a Makefile which maintains files automatically generated but to be
     2  # shipped together with other files.
     3  # You don't have to rebuild these targets by yourself unless you develop
     4  # gRPC-Gateway itself.
     5  
     6  EXAMPLE_CLIENT_DIR=examples/internal/clients
     7  ECHO_EXAMPLE_SPEC=examples/internal/proto/examplepb/echo_service.swagger.json
     8  ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/echo/client.go \
     9  		  $(EXAMPLE_CLIENT_DIR)/echo/response.go \
    10  		  $(EXAMPLE_CLIENT_DIR)/echo/configuration.go \
    11  		  $(EXAMPLE_CLIENT_DIR)/echo/api_echo_service.go \
    12  		  $(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_simple_message.go \
    13  		  $(EXAMPLE_CLIENT_DIR)/echo/model_examplepb_embedded.go
    14  ABE_EXAMPLE_SPEC=examples/internal/proto/examplepb/a_bit_of_everything.swagger.json
    15  ABE_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/abe/model_a_bit_of_everything_nested.go \
    16  		 $(EXAMPLE_CLIENT_DIR)/abe/api_a_bit_of_everything_service.go \
    17  		 $(EXAMPLE_CLIENT_DIR)/abe/client.go \
    18  		 $(EXAMPLE_CLIENT_DIR)/abe/api_camel_case_service_name.go \
    19  		 $(EXAMPLE_CLIENT_DIR)/abe/configuration.go \
    20  		 $(EXAMPLE_CLIENT_DIR)/abe/api_echo_rpc.go \
    21  		 $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything.go \
    22  		 $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_a_bit_of_everything_repeated.go \
    23  		 $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_body.go \
    24  		 $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_numeric_enum.go \
    25  		 $(EXAMPLE_CLIENT_DIR)/abe/model_examplepb_update_v2_request.go \
    26  		 $(EXAMPLE_CLIENT_DIR)/abe/model_message_path_enum_nested_path_enum.go \
    27  		 $(EXAMPLE_CLIENT_DIR)/abe/model_nested_deep_enum.go \
    28  		 $(EXAMPLE_CLIENT_DIR)/abe/model_pathenum_path_enum.go \
    29  		 $(EXAMPLE_CLIENT_DIR)/abe/model_protobuf_field_mask.go \
    30  		 $(EXAMPLE_CLIENT_DIR)/abe/response.go
    31  UNANNOTATED_ECHO_EXAMPLE_SPEC=examples/internal/proto/examplepb/unannotated_echo_service.swagger.json
    32  UNANNOTATED_ECHO_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/unannotatedecho/client.go \
    33  		 $(EXAMPLE_CLIENT_DIR)/unannotatedecho/response.go \
    34  		 $(EXAMPLE_CLIENT_DIR)/unannotatedecho/configuration.go \
    35  		 $(EXAMPLE_CLIENT_DIR)/unannotatedecho/model_examplepb_unannotated_simple_message.go \
    36  		 $(EXAMPLE_CLIENT_DIR)/unannotatedecho/api_unannotated_echo_service.go
    37  RESPONSE_BODY_EXAMPLE_SPEC=examples/internal/proto/examplepb/response_body_service.swagger.json
    38  RESPONSE_BODY_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/responsebody/client.go \
    39  		 $(EXAMPLE_CLIENT_DIR)/responsebody/response.go \
    40  		 $(EXAMPLE_CLIENT_DIR)/responsebody/configuration.go \
    41  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out.go \
    42  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_body_out_response.go \
    43  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_repeated_response_strings.go \
    44  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out.go \
    45  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_examplepb_response_body_out_response.go \
    46  		 $(EXAMPLE_CLIENT_DIR)/responsebody/model_response_response_type.go \
    47  		 $(EXAMPLE_CLIENT_DIR)/responsebody/api_response_body_service.go
    48  GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC=examples/internal/proto/examplepb/generate_unbound_methods.swagger.json
    49  GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS=$(EXAMPLE_CLIENT_DIR)/generateunboundmethods/client.go \
    50  		 $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/response.go \
    51  		 $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/configuration.go \
    52  		 $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/model_examplepb_generate_unbound_methods_simple_message.go \
    53  		 $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/api_generate_unbound_methods.go
    54  
    55  EXAMPLE_CLIENT_SRCS=$(ECHO_EXAMPLE_SRCS) $(ABE_EXAMPLE_SRCS) $(UNANNOTATED_ECHO_EXAMPLE_SRCS) $(RESPONSE_BODY_EXAMPLE_SRCS) $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS)
    56  SWAGGER_CODEGEN=swagger-codegen
    57  
    58  $(ECHO_EXAMPLE_SRCS): $(ECHO_EXAMPLE_SPEC)
    59  	$(SWAGGER_CODEGEN) generate -i $(ECHO_EXAMPLE_SPEC) \
    60  		-l go -o examples/internal/clients/echo --additional-properties packageName=echo
    61  	@rm -f $(EXAMPLE_CLIENT_DIR)/echo/README.md \
    62  		$(EXAMPLE_CLIENT_DIR)/echo/git_push.sh
    63  $(ABE_EXAMPLE_SRCS): $(ABE_EXAMPLE_SPEC)
    64  	$(SWAGGER_CODEGEN) generate -i $(ABE_EXAMPLE_SPEC) \
    65  		-l go -o examples/internal/clients/abe --additional-properties packageName=abe
    66  	@rm -f $(EXAMPLE_CLIENT_DIR)/abe/README.md \
    67  		$(EXAMPLE_CLIENT_DIR)/abe/git_push.sh
    68  $(UNANNOTATED_ECHO_EXAMPLE_SRCS): $(UNANNOTATED_ECHO_EXAMPLE_SPEC)
    69  	$(SWAGGER_CODEGEN) generate -i $(UNANNOTATED_ECHO_EXAMPLE_SPEC) \
    70  		-l go -o examples/internal/clients/unannotatedecho --additional-properties packageName=unannotatedecho
    71  	@rm -f $(EXAMPLE_CLIENT_DIR)/unannotatedecho/README.md \
    72  		$(EXAMPLE_CLIENT_DIR)/unannotatedecho/git_push.sh
    73  $(RESPONSE_BODY_EXAMPLE_SRCS): $(RESPONSE_BODY_EXAMPLE_SPEC)
    74  	$(SWAGGER_CODEGEN) generate -i $(RESPONSE_BODY_EXAMPLE_SPEC) \
    75  		-l go -o examples/internal/clients/responsebody --additional-properties packageName=responsebody
    76  	@rm -f $(EXAMPLE_CLIENT_DIR)/responsebody/README.md \
    77  		$(EXAMPLE_CLIENT_DIR)/responsebody/git_push.sh
    78  $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS): $(GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC)
    79  	$(SWAGGER_CODEGEN) generate -i $(GENERATE_UNBOUND_METHODS_EXAMPLE_SPEC) \
    80  	    -l go -o examples/internal/clients/generateunboundmethods --additional-properties packageName=generateunboundmethods
    81  	@rm -f $(EXAMPLE_CLIENT_DIR)/generateunboundmethods/README.md \
    82  		$(EXAMPLE_CLIENT_DIR)/generateunboundmethods/git_push.sh
    83  
    84  install:
    85  	go install github.com/bufbuild/buf/cmd/buf@v1.14.0
    86  	go install \
    87  		./protoc-gen-openapiv2 \
    88  		./protoc-gen-grpc-gateway
    89  
    90  proto:
    91  	# These generation steps are run in order so that later steps can
    92  	# overwrite files produced by previous steps, if necessary.
    93  	buf generate
    94  	# Remove generated gateway in runtime tests, causes import cycle
    95  	rm ./runtime/internal/examplepb/non_standard_names.pb.gw.go
    96  	# Remove generated_input.proto files, bazel genrule relies on these
    97  	# *not* being generated (to avoid conflicts).
    98  	rm ./examples/internal/proto/examplepb/generated_input.pb.go
    99  	rm ./examples/internal/proto/examplepb/generated_input_grpc.pb.go
   100  	rm ./examples/internal/proto/examplepb/generated_input.pb.gw.go
   101  	buf generate \
   102  		--template ./examples/internal/proto/examplepb/openapi_merge.buf.gen.yaml \
   103  		--path ./examples/internal/proto/examplepb/openapi_merge_a.proto \
   104  		--path ./examples/internal/proto/examplepb/openapi_merge_b.proto
   105  	buf generate \
   106  		--template ./examples/internal/proto/examplepb/standalone_echo_service.buf.gen.yaml \
   107  		--path examples/internal/proto/examplepb/unannotated_echo_service.proto
   108  	mv examples/internal/proto/examplepb/unannotated_echo_service.pb.gw.go examples/internal/proto/standalone/
   109  	buf generate \
   110  		--template ./examples/internal/proto/examplepb/unannotated_echo_service.buf.gen.yaml \
   111  		--path examples/internal/proto/examplepb/unannotated_echo_service.proto
   112  	buf generate \
   113  		--template ./examples/internal/proto/examplepb/generate_unbound_methods.buf.gen.yaml \
   114  		--path examples/internal/proto/examplepb/generate_unbound_methods.proto
   115  	buf generate \
   116  		--template ./examples/internal/proto/examplepb/use_go_template.buf.gen.yaml \
   117  		--path examples/internal/proto/examplepb/use_go_template.proto
   118  	buf generate \
   119  		--template ./examples/internal/proto/examplepb/ignore_comment.buf.gen.yaml \
   120  		--path examples/internal/proto/examplepb/ignore_comment.proto
   121  	buf generate \
   122  		--template ./examples/internal/proto/examplepb/remove_internal_comment.buf.gen.yaml \
   123  		--path examples/internal/proto/examplepb/remove_internal_comment.proto
   124  	buf generate \
   125  		--template ./examples/internal/proto/examplepb/visibility_rule_preview_echo_service.buf.gen.yaml \
   126  		--path examples/internal/proto/examplepb/visibility_rule_echo_service.proto
   127  	mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_preview_echo_service.swagger.json
   128  	buf generate \
   129  		--template ./examples/internal/proto/examplepb/visibility_rule_internal_echo_service.buf.gen.yaml \
   130  		--path examples/internal/proto/examplepb/visibility_rule_echo_service.proto
   131  	mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_internal_echo_service.swagger.json
   132  	buf generate \
   133  		--template ./examples/internal/proto/examplepb/visibility_rule_none_echo_service.buf.gen.yaml \
   134  		--path examples/internal/proto/examplepb/visibility_rule_echo_service.proto
   135  	mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_none_echo_service.swagger.json
   136  	buf generate \
   137  		--template ./examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.buf.gen.yaml \
   138  		--path examples/internal/proto/examplepb/visibility_rule_echo_service.proto
   139  	mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_preview_and_internal_echo_service.swagger.json
   140  	buf generate \
   141  		--template ./examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.buf.gen.yaml \
   142  		--path examples/internal/proto/examplepb/visibility_rule_echo_service.proto
   143  	mv examples/internal/proto/examplepb/visibility_rule_echo_service.swagger.json examples/internal/proto/examplepb/visibility_rule_enums_as_ints_echo_service.swagger.json
   144  
   145  generate: proto $(ECHO_EXAMPLE_SRCS) $(ABE_EXAMPLE_SRCS) $(UNANNOTATED_ECHO_EXAMPLE_SRCS) $(RESPONSE_BODY_EXAMPLE_SRCS) $(GENERATE_UNBOUND_METHODS_EXAMPLE_SRCS)
   146  
   147  test: proto
   148  	go test -short -race ./...
   149  	go test -race ./examples/internal/integration -args -network=unix -endpoint=test.sock
   150  
   151  clean:
   152  	find . -type f -name '*.pb.go' -delete
   153  	find . -type f -name '*.swagger.json' -delete
   154  	find . -type f -name '*.pb.gw.go' -delete
   155  	rm -f $(EXAMPLE_CLIENT_SRCS)
   156  
   157  .PHONY: generate test clean proto install