I was toying with possibilities to add per-proto gpb_opts as a possible solution to tomas-abrahamsson/gpb#197 and came up with this change. In its current form, it is a bit of proof-of-concept, for discussiong the idea. If things look good, I can go on to add documentation and examples and such things.
My idea was to add a per_proto_override key, which could add to options, or replace them altogether with other options.
I found a gpb_test repo that I used as an example. It has two files, demo_bytes.proto and demo2.proto. The gpb_opts in the rebar.config look like below, notice the module suffix override for "demo2.proto":
Here is some more description of the format extension (text from the commit message)
[...
% Common gpb opts
% These will be used if no per-proto override is specified
% NB: Currently output-dir options cannot be overridden
% ie, any common {o,Dir}, {o_erl,Dir} or {o_hrl,Dir} are used
...
{per_proto_override,
[{"dir1/a.proto", [{module_name_prefix, "dir1_"}]},
{"dir2/a.proto", [{module_name_prefix, "dir2_"}]},
{"dir2/b.proto", {replace, % <-- means to override all common options
[{verify, false}, ...]}},
{"dir2/c.proto", {merge, % <-- means to prepend to common options,
% this is the default,
% as in the a.proto examples above
[{verify, false}, ...]}}]}]
I was toying with possibilities to add per-proto
gpb_opts
as a possible solution to tomas-abrahamsson/gpb#197 and came up with this change. In its current form, it is a bit of proof-of-concept, for discussiong the idea. If things look good, I can go on to add documentation and examples and such things.My idea was to add a
per_proto_override
key, which could add to options, or replace them altogether with other options.I found a gpb_test repo that I used as an example. It has two files,
demo_bytes.proto
anddemo2.proto
. Thegpb_opts
in the rebar.config look like below, notice the module suffix override for "demo2.proto":This is what happens when I compile, notice the different suffix in the for the second proto:
Here is some more description of the format extension (text from the commit message)