Skip to content

Client generation with "o" or "module_name_prefix" options fails #6

@galaxie

Description

@galaxie

I was trying to generate ETCD3 client using the following specification https://github.com/kragniz/python-etcd3/tree/master/etcd3/proto and Erlang/OTP 20 on MacOS High Sierra.

Seems like some code generation options don't work as expected.

Protobuff specification resides in ./proto dir and desirable generated code path is ./compiled_client:

.
├── compiled_client
├── proto
│   ├── auth.proto
│   ├── kv.proto
│   └── rpc.proto
├── src
    ├── ...
├── Makefile
├── ...

I used the following code for generation, where PROJECT_ROOT is a string with an absolute path to the project.
I tried output dir option and module prefix option. Both end up with an exception.

% example 1
ProtoDir = "PROJECT_ROOT/proto".
OutputDir = "PROJECT_ROOT/compiled_client".
grpc_client:compile(
        filename:join(ProtoDir, "rpc.proto"),
        [
            {i, ProtoDir},
            {o, OutputDir},
            {use_packages, true}
        ]
    ).

** exception error: no match of right hand side value error
     in function  grpc_lib_compile:compile_pb/2 (src/grpc_lib_compile.erl, line 46)
     in call from grpc_lib_compile:file/2 (src/grpc_lib_compile.erl, line 30)
% file "PROJECT_ROOT/proto/rpc.erl" was generated
% example 2
ProtoDir = "PROJECT_ROOT/proto".
OutputDir = "PROJECT_ROOT/compiled_client".
grpc_client:compile(
        filename:join(ProtoDir, "rpc.proto"),
        [
            {i, ProtoDir},
            {module_name_prefix, test},
            {use_packages, true}
        ]
    ).
** exception error: no match of right hand side value error
     in function  grpc_lib_compile:compile_pb/2 (src/grpc_lib_compile.erl, line 46)
     in call from grpc_lib_compile:file/2 (src/grpc_lib_compile.erl, line 30)

%  file "PROJECT_ROOT/proto/testrpc.erl was generated

I guess the problem is caused by this function here https://github.com/Bluehouse-Technology/grpc_lib/blob/master/src/grpc_lib_compile.erl#L42 which doesn't respect possible generated file path or/and name change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions