Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
galaxie opened this issue Jun 11, 2018 · 0 comments
Open

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

galaxie opened this issue Jun 11, 2018 · 0 comments

Comments

@galaxie
Copy link
Contributor

galaxie commented Jun 11, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant