Skip to content

Support records format and flexible gpb options#23

Open
7run wants to merge 1 commit intotsloughter:masterfrom
7run:feat/support-records-format
Open

Support records format and flexible gpb options#23
7run wants to merge 1 commit intotsloughter:masterfrom
7run:feat/support-records-format

Conversation

@7run
Copy link
Copy Markdown

@7run 7run commented Mar 4, 2026

Summary

Currently, the plugin hardcodes maps and {i, "."} in the gpb compile options, which prevents users from using the records format and limits control over include paths.

This PR makes the following changes:

  • Remove hardcoded maps option — Allow users to choose between maps and records format via their own gpb_opts configuration
  • Remove hardcoded {i, "."} — Let users specify proper include paths through gpb_opts
  • Fix relative paths to absolute — Convert o_hrl and i paths in gpb_opts to be relative to the application's base directory, preventing issues in umbrella projects or non-standard directory layouts
  • Support both map and tuple formats in resolve_method/2 — When using records mode, gpb returns method data as tuples ({rpc, Name, Input, Output, ...}) instead of maps. This adds a function clause to handle the tuple format

Backward Compatibility

Existing users who rely on the default maps behavior are not affected. The use_packages and strings_as_binaries options remain as defaults. Users who want records format can now simply add records (or omit maps) in their gpb_opts.

Related

This is related to #14, which also addresses GPB option flexibility, though with a different approach.

- Remove hardcoded 'maps' option to allow records format
- Remove hardcoded '{i, "."}' to let users specify include paths
- Fix relative paths (o_hrl, i) to be absolute based on app directory
- Add o_hrl directory to include path for compilation
- Support both map and tuple formats in resolve_method/2
- Update gpb dependency to 4.21.5 for Erlang syntax compatibility
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

Successfully merging this pull request may close these issues.

1 participant