Skip to content

Inject options in nanopb .options files into the protobuf files used for code generation#922

Merged
ianmcorvidae merged 4 commits into
meshtastic:masterfrom
ianmcorvidae:nanopb-options-inject
May 31, 2026
Merged

Inject options in nanopb .options files into the protobuf files used for code generation#922
ianmcorvidae merged 4 commits into
meshtastic:masterfrom
ianmcorvidae:nanopb-options-inject

Conversation

@ianmcorvidae
Copy link
Copy Markdown
Contributor

This will let us look at things like max lengths, ostensible int sizes, and things like that if we want to, or library consumers want to.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds tooling to inject nanopb .options constraints (e.g. max_size, int_size, max_count) directly into the temporary .proto files used by the Python protobuf code generator, so that the generated *_pb2.py descriptors carry those nanopb annotations and can be inspected at runtime via field.GetOptions().Extensions[nanopb_pb2.nanopb]. The bulk of the diff is regenerated *_pb2.py files reflecting the new embedded options.

Changes:

  • New bin/inject_nanopb_options.py script that parses a nanopb .options file and rewrites field declarations in a .proto file to include inline (nanopb).* field options, adding a nanopb.proto import as needed.
  • bin/regen-protobufs.sh now invokes the injector for every .options/.proto pair before running protoc.
  • Regenerated _pb2.py descriptors across the protobuf package now contain serialized nanopb field options, along with the corresponding nanopb_pb2 imports and updated _serialized_start/_serialized_end offsets.

Reviewed changes

Copilot reviewed 1 out of 22 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bin/inject_nanopb_options.py New script that injects nanopb .options into proto field declarations.
bin/regen-protobufs.sh Calls the injector for each .options file before generating Python code.
meshtastic/protobuf/admin_pb2.py Regenerated with embedded nanopb field options and updated offsets.
meshtastic/protobuf/apponly_pb2.py Regenerated to embed nanopb settings option.
meshtastic/protobuf/atak_pb2.pyi Regenerated stub; lost the epw trailing comment docstring.
meshtastic/protobuf/cannedmessages_pb2.py Regenerated with messages max_size option.
meshtastic/protobuf/channel_pb2.py Regenerated with PSK/name/index nanopb options.
meshtastic/protobuf/clientonly_pb2.py Regenerated with DeviceProfile string size options.
meshtastic/protobuf/config_pb2.py Regenerated with many size/int_size options across configs.
meshtastic/protobuf/connection_status_pb2.py Regenerated with WiFi SSID size option.
meshtastic/protobuf/device_ui_pb2.py Regenerated with UI int_size and string size options.
meshtastic/protobuf/deviceonly_pb2.py Regenerated with UserLite/NodeInfoLite size options.
meshtastic/protobuf/interdevice_pb2.py Regenerated with NMEA max size option.
meshtastic/protobuf/module_config_pb2.py Regenerated with module config size/int_size options.
meshtastic/protobuf/mqtt_pb2.py Regenerated with MapReport string size options.
meshtastic/protobuf/rtttl_pb2.py Regenerated with ringtone max size.
meshtastic/protobuf/serial_hal_pb2.py Regenerated with serial HAL data/error size options.
meshtastic/protobuf/storeforward_pb2.py Regenerated with text max size option.
meshtastic/protobuf/telemetry_pb2.py Regenerated with int_size/repeated count options.
meshtastic/protobuf/xmodem_pb2.py Regenerated with seq/crc/buffer nanopb options.
Files not reviewed (19)
  • meshtastic/protobuf/admin_pb2.py: Language not supported
  • meshtastic/protobuf/apponly_pb2.py: Language not supported
  • meshtastic/protobuf/atak_pb2.py: Language not supported
  • meshtastic/protobuf/cannedmessages_pb2.py: Language not supported
  • meshtastic/protobuf/channel_pb2.py: Language not supported
  • meshtastic/protobuf/clientonly_pb2.py: Language not supported
  • meshtastic/protobuf/config_pb2.py: Language not supported
  • meshtastic/protobuf/connection_status_pb2.py: Language not supported
  • meshtastic/protobuf/device_ui_pb2.py: Language not supported
  • meshtastic/protobuf/deviceonly_pb2.py: Language not supported
  • meshtastic/protobuf/interdevice_pb2.py: Language not supported
  • meshtastic/protobuf/mesh_pb2.py: Language not supported
  • meshtastic/protobuf/module_config_pb2.py: Language not supported
  • meshtastic/protobuf/mqtt_pb2.py: Language not supported
  • meshtastic/protobuf/rtttl_pb2.py: Language not supported
  • meshtastic/protobuf/serial_hal_pb2.py: Language not supported
  • meshtastic/protobuf/storeforward_pb2.py: Language not supported
  • meshtastic/protobuf/telemetry_pb2.py: Language not supported
  • meshtastic/protobuf/xmodem_pb2.py: Language not supported

@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.57%. Comparing base (fddaad3) to head (a7d13eb).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #922   +/-   ##
=======================================
  Coverage   61.57%   61.57%           
=======================================
  Files          25       25           
  Lines        4448     4448           
=======================================
  Hits         2739     2739           
  Misses       1709     1709           
Flag Coverage Δ
unittests 61.57% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ianmcorvidae ianmcorvidae merged commit 5dde67e into meshtastic:master May 31, 2026
11 checks passed
@ianmcorvidae ianmcorvidae deleted the nanopb-options-inject branch May 31, 2026 17:27
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.

2 participants