pw_protobuf: Codegen kConstantCase field enums

pw_protobuf generated code includes an "enum class Fields : uint32_t"
type in in message, with values equal to the IDs for each field in the
message.

Unfortunately, the existing generated code uses SNAKE_CASE for the
names, rather than kConstantCase. In addition to be against the
style guide, this makes collisions with legacy C macros much more
likely.

Indeed, I ran into this issue due to a naming collison on OUTPUT_TYPE
between stm32cube.h and descriptor.pwpb.h. Of course, ST deserves
significant blame here for using inadequately namespaced global
identifiers... it's not just pw_protobuf's fault for not using
kConstantCase.

This commit does not yet migrate pigweed code to use the kConstantCase
values, that will be in an immediate follow-on. However, this commit
DOES add a GN variable to control generation of the legacy
names (in addition to new names):
    pw_protobuf_compiler_GENERATE_LEGACY_ENUM_SNAKE_CASE_NAMES

This currently defaults to true, but will change to default to false
after the follow-on commit which migrates upstream pigweed away from
SNAKE_CASE. That will have to be done by an upstream pigweed developer.

Bug: b/266298474
Change-Id: I460a7d203905d39d234d3bf1a7621b52b188c109
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/126804
Commit-Queue: Wyatt Hepler <hepler@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
7 files changed
tree: e3589b9b6a54c19d52b0d7428e0d392b9ca3d677
  1. .allstar/
  2. .vscode/
  3. build_overrides/
  4. docker/
  5. docs/
  6. pw_allocator/
  7. pw_analog/
  8. pw_android_toolchain/
  9. pw_arduino_build/
  10. pw_assert/
  11. pw_assert_basic/
  12. pw_assert_log/
  13. pw_assert_tokenized/
  14. pw_assert_zephyr/
  15. pw_async/
  16. pw_base64/
  17. pw_bloat/
  18. pw_blob_store/
  19. pw_bluetooth/
  20. pw_bluetooth_hci/
  21. pw_boot/
  22. pw_boot_cortex_m/
  23. pw_build/
  24. pw_build_info/
  25. pw_build_mcuxpresso/
  26. pw_bytes/
  27. pw_checksum/
  28. pw_chrono/
  29. pw_chrono_embos/
  30. pw_chrono_freertos/
  31. pw_chrono_stl/
  32. pw_chrono_threadx/
  33. pw_chrono_zephyr/
  34. pw_cli/
  35. pw_compilation_testing/
  36. pw_console/
  37. pw_containers/
  38. pw_cpu_exception/
  39. pw_cpu_exception_cortex_m/
  40. pw_crypto/
  41. pw_digital_io/
  42. pw_docgen/
  43. pw_doctor/
  44. pw_env_setup/
  45. pw_file/
  46. pw_function/
  47. pw_fuzzer/
  48. pw_hdlc/
  49. pw_hex_dump/
  50. pw_i2c/
  51. pw_i2c_mcuxpresso/
  52. pw_ide/
  53. pw_interrupt/
  54. pw_interrupt_cortex_m/
  55. pw_interrupt_zephyr/
  56. pw_intrusive_ptr/
  57. pw_kvs/
  58. pw_libc/
  59. pw_log/
  60. pw_log_android/
  61. pw_log_basic/
  62. pw_log_null/
  63. pw_log_rpc/
  64. pw_log_string/
  65. pw_log_tokenized/
  66. pw_log_zephyr/
  67. pw_malloc/
  68. pw_malloc_freelist/
  69. pw_metric/
  70. pw_minimal_cpp_stdlib/
  71. pw_module/
  72. pw_multisink/
  73. pw_package/
  74. pw_perf_test/
  75. pw_persistent_ram/
  76. pw_polyfill/
  77. pw_preprocessor/
  78. pw_presubmit/
  79. pw_protobuf/
  80. pw_protobuf_compiler/
  81. pw_random/
  82. pw_result/
  83. pw_ring_buffer/
  84. pw_router/
  85. pw_rpc/
  86. pw_rust/
  87. pw_snapshot/
  88. pw_software_update/
  89. pw_span/
  90. pw_spi/
  91. pw_status/
  92. pw_stm32cube_build/
  93. pw_stream/
  94. pw_string/
  95. pw_symbolizer/
  96. pw_sync/
  97. pw_sync_baremetal/
  98. pw_sync_embos/
  99. pw_sync_freertos/
  100. pw_sync_stl/
  101. pw_sync_threadx/
  102. pw_sync_zephyr/
  103. pw_sys_io/
  104. pw_sys_io_arduino/
  105. pw_sys_io_baremetal_lm3s6965evb/
  106. pw_sys_io_baremetal_stm32f429/
  107. pw_sys_io_emcraft_sf2/
  108. pw_sys_io_mcuxpresso/
  109. pw_sys_io_pico/
  110. pw_sys_io_stdio/
  111. pw_sys_io_stm32cube/
  112. pw_sys_io_zephyr/
  113. pw_system/
  114. pw_target_runner/
  115. pw_thread/
  116. pw_thread_embos/
  117. pw_thread_freertos/
  118. pw_thread_stl/
  119. pw_thread_threadx/
  120. pw_tls_client/
  121. pw_tls_client_boringssl/
  122. pw_tls_client_mbedtls/
  123. pw_tokenizer/
  124. pw_tool/
  125. pw_toolchain/
  126. pw_trace/
  127. pw_trace_tokenized/
  128. pw_transfer/
  129. pw_unit_test/
  130. pw_varint/
  131. pw_watch/
  132. pw_web/
  133. pw_work_queue/
  134. seed/
  135. targets/
  136. third_party/
  137. ts/
  138. zephyr/
  139. .bazelignore
  140. .bazelrc
  141. .clang-format
  142. .clang-tidy
  143. .eslintrc.json
  144. .git-blame-ignore-revs
  145. .gitattributes
  146. .gitignore
  147. .gn
  148. .mypy.ini
  149. .prettierrc.js
  150. .pw_ide.yaml
  151. .pylintrc
  152. activate.bat
  153. Android.bp
  154. AUTHORS
  155. bootstrap.bat
  156. bootstrap.sh
  157. BUILD.bazel
  158. BUILD.gn
  159. BUILDCONFIG.gn
  160. CMakeLists.txt
  161. jest.config.ts
  162. Kconfig.zephyr
  163. LICENSE
  164. modules.gni
  165. OWNERS
  166. package-lock.json
  167. package.json
  168. PIGWEED_MODULES
  169. PW_PLUGINS
  170. pyproject.toml
  171. README.md
  172. rollup.config.js
  173. tsconfig.json
  174. WORKSPACE
README.md

Pigweed

Pigweed is an open source collection of embedded-targeted libraries–or as we like to call them, modules. These modules are building blocks and infrastructure that enable faster and more reliable development on small-footprint MMU-less 32-bit microcontrollers like the STMicroelectronics STM32L452 or the Nordic nRF52832.

For more information please see our website: https://pigweed.dev/.

Links