mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
The Google C++ protobuf implementation has issues with dynamic linkage across DLL boundaries because it uses global variables. It also has a compile-time dependency because the protoc version must exactly match the libprotobuf version. Using nanopb with a customized generator fixes both of these issues. Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
29 lines
1.2 KiB
Diff
29 lines
1.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Thad House <thadhouse1@gmail.com>
|
|
Date: Tue, 29 Oct 2024 20:23:48 -0700
|
|
Subject: [PATCH 3/4] Generate messages or anything non static as callback
|
|
|
|
---
|
|
generator/nanopb_generator.py | 6 ++++--
|
|
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
|
|
index 239aed4f379b5d454e3b65c48ca11e9f92b6bc4d..3b59ba59e6fc997350b1368a2faebc051cd6176a 100755
|
|
--- a/generator/nanopb_generator.py
|
|
+++ b/generator/nanopb_generator.py
|
|
@@ -683,10 +683,12 @@ class Field(ProtoElement):
|
|
|
|
# Decide how the field data will be allocated
|
|
if field_options.type == nanopb_pb2.FT_DEFAULT:
|
|
- if can_be_static:
|
|
+ if desc.type == FieldD.TYPE_MESSAGE:
|
|
+ field_options.type = nanopb_pb2.FT_CALLBACK
|
|
+ elif can_be_static:
|
|
field_options.type = nanopb_pb2.FT_STATIC
|
|
else:
|
|
- field_options.type = field_options.fallback_type
|
|
+ field_options.type = nanopb_pb2.FT_CALLBACK
|
|
|
|
if field_options.type == nanopb_pb2.FT_STATIC and not can_be_static:
|
|
raise Exception("Field '%s' is defined as static, but max_size or "
|