drowzy / protobuf_generate

Protobuf code generation as a mix task
MIT License
9 stars 2 forks source link

【need_help】def generate(%Protobuf.Protoc.Context{} = ctx, %Google.Protobuf.FileDescriptorProto{} = desc, plugins) #5

Open openmindw opened 1 month ago

openmindw commented 1 month ago

env: Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns]

Mix 1.16.3 (compiled with Erlang/OTP 24)

wsl2-arch


when i use the commad: mix protobuf.generate --output-path=./lib --include-path=./priv/protos helloworld.proto it will report:

`

mix protobuf.generate --output-path=./lib --include-path=./priv/protos helloworld.proto

==> protobuf_generate Compiling 9 files (.ex) Generated protobuf_generate app ==> elixir_grpc Generated elixir_grpc app ** (FunctionClauseError) no function clause matching in ProtobufGenerate.CodeGen.generate/3

The following arguments were given to ProtobufGenerate.CodeGen.generate/3:

    # 1
    %Protobuf.Protoc.Context{plugins: [], global_type_mapping: %{"helloworld.proto" => %{".helloworld.HelloReply" => %{type_name: "Helloworld.HelloReply"}, ".helloworld.HelloRequest" => %{type_name: "Helloworld.HelloRequest"}}}, package: nil, package_prefix: nil, module_prefix: nil, syntax: nil, dep_type_mapping: %{}, namespace: [], gen_descriptors?: false, transform_module: nil, one_file_per_module?: false, include_docs?: false, custom_file_options: %{}}

    # 2
    nil

    # 3
    [ProtobufGenerate.Plugins.Enum, ProtobufGenerate.Plugins.Extension, ProtobufGenerate.Plugins.Message]

Attempted function clauses (showing 1 out of 1):

    def generate(%Protobuf.Protoc.Context{} = ctx, %Google.Protobuf.FileDescriptorProto{} = desc, plugins)

(protobuf_generate 0.1.2) lib/protobuf_generate/code_gen.ex:8: ProtobufGenerate.CodeGen.generate/3
(elixir 1.16.3) lib/enum.ex:4326: Enum.flat_map_list/2
(protobuf_generate 0.1.2) lib/mix/protobuf.generate.ex:124: Mix.Tasks.Protobuf.Generate.generate/2
(protobuf_generate 0.1.2) lib/mix/protobuf.generate.ex:86: Mix.Tasks.Protobuf.Generate.run/1
(mix 1.16.3) lib/mix/task.ex:478: anonymous fn/3 in Mix.Task.run_task/5
(mix 1.16.3) lib/mix/cli.ex:96: Mix.CLI.run_task/2
/root/.local/share/mise/installs/elixir/1.16.3/bin/mix:2: (file)

`

the helloword file code: ` syntax = "proto3";

package helloworld;

// The request message containing the user's name. message HelloRequest { string name = 1; }

// The response message containing the greeting message HelloReply { string message = 1; }

// The greeting service definition. service Greeter { // Greeting function rpc SayHello (HelloRequest) returns (HelloReply) {} }

`

openmindw commented 1 month ago

"protobuf_generate": {:hex, :protobuf_generate, "0.1.2", "45b9a9ae8606333cdea993ceaaecd799d206cdfe23348d37c06207eac76cbee6", [:mix], [{:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "55b0ff8385703317ca90e1bd30a2ece99e80ae0c73e6ebcfb374e84e57870d61"},

drowzy commented 1 month ago

Try: mix protobuf.generate --output-path=./lib --include-path=./priv/protos./priv/protos/test.proto