lrascao / rebar3_gpb_plugin

A rebar3 plugin for automatically compiling .proto files using the gpb protobuf compiler
MIT License
55 stars 37 forks source link

Upcoming functions in gpb could maybe be useful for rebar3_gpb_plugin #130

Closed tomas-abrahamsson closed 3 years ago

tomas-abrahamsson commented 3 years ago

Hi, I was experimenting a bit with adding functions to gpb for calculating names of inputs dependencies and resulting outputs. It is currently on a branch in gpb, the makedep branch. I intend to merge it soon. This issue is mostly a heads-up, in case you think it could have use for it in rebar3_gpb_plugin, and if you should find something to add or modify for it to be of more value. Feel free to close this issue at any time.

Here's an annotated example to show how it works::

$ cat m/a2.proto 
syntax="proto2";
import "d/dir1/x.proto";
import "d/dir2/x.proto";
message MsgA { required uint32 f1 = 1; }

$ erl
1> gpb_compile:list_io("./m/a2.proto", [{i,"m"}, {o_erl,"src"}, {module_name_suffix, "_pb"}]).
[%% calculated outputs, options for output and renaming are considered:
 {erl_output,"src/a2_pb.erl"},
 {hrl_output,"./m/a2_pb.hrl"},
 %% Inputs, the first one is the main proto, any imports follow:
 {sources,["./m/a2.proto","m/d/dir1/x.proto",
           "m/d/dir2/x.proto"]},
 %% Any imported files that could not be located end up here:
 {missing,[]}]

(There are also some command line switches to access this functionality, inspired by the erlc and gcc -M family of options)

lrascao commented 3 years ago

ah nice, i'll keep this ticket open to remind to take a look into it, thanks!

tomas-abrahamsson commented 3 years ago

This is now included in the master from 4.15.1 (from 4.15.0 more precisely)

lrascao commented 3 years ago

closing via #136