[wpiutil] Change C++ protobuf to nanopb (#7309)

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>
This commit is contained in:
Thad House
2024-11-07 22:42:50 -08:00
committed by GitHub
parent fd2e0c0427
commit 8b8b634f65
166 changed files with 17522 additions and 1571 deletions

View File

@@ -8,10 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Ellipse2d.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Ellipse2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Ellipse2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg, const frc::Ellipse2d& value);
using MessageStruct = wpi_proto_ProtobufEllipse2d;
using InputStream = wpi::ProtoInputStream<frc::Ellipse2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Ellipse2d>;
static std::optional<frc::Ellipse2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Ellipse2d& value);
};

View File

@@ -8,10 +8,14 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Pose2d.h"
#include "pb.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Pose2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Pose2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg, const frc::Pose2d& value);
using MessageStruct = wpi_proto_ProtobufPose2d;
using InputStream = wpi::ProtoInputStream<frc::Pose2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Pose2d>;
static std::optional<frc::Pose2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Pose2d& value);
};

View File

@@ -8,10 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Pose3d.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Pose3d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Pose3d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg, const frc::Pose3d& value);
using MessageStruct = wpi_proto_ProtobufPose3d;
using InputStream = wpi::ProtoInputStream<frc::Pose3d>;
using OutputStream = wpi::ProtoOutputStream<frc::Pose3d>;
static std::optional<frc::Pose3d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Pose3d& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Quaternion.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Quaternion> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Quaternion Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Quaternion& value);
using MessageStruct = wpi_proto_ProtobufQuaternion;
using InputStream = wpi::ProtoInputStream<frc::Quaternion>;
using OutputStream = wpi::ProtoOutputStream<frc::Quaternion>;
static std::optional<frc::Quaternion> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Quaternion& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Rectangle2d.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Rectangle2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Rectangle2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Rectangle2d& value);
using MessageStruct = wpi_proto_ProtobufRectangle2d;
using InputStream = wpi::ProtoInputStream<frc::Rectangle2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Rectangle2d>;
static std::optional<frc::Rectangle2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Rectangle2d& value);
};

View File

@@ -8,11 +8,14 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Rotation2d.h"
#include "pb.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Rotation2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Rotation2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Rotation2d& value);
using MessageStruct = wpi_proto_ProtobufRotation2d;
using InputStream = wpi::ProtoInputStream<frc::Rotation2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Rotation2d>;
static std::optional<frc::Rotation2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Rotation2d& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Rotation3d.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Rotation3d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Rotation3d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Rotation3d& value);
using MessageStruct = wpi_proto_ProtobufRotation3d;
using InputStream = wpi::ProtoInputStream<frc::Rotation3d>;
using OutputStream = wpi::ProtoOutputStream<frc::Rotation3d>;
static std::optional<frc::Rotation3d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Rotation3d& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Transform2d.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Transform2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Transform2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Transform2d& value);
using MessageStruct = wpi_proto_ProtobufTransform2d;
using InputStream = wpi::ProtoInputStream<frc::Transform2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Transform2d>;
static std::optional<frc::Transform2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Transform2d& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Transform3d.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Transform3d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Transform3d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Transform3d& value);
using MessageStruct = wpi_proto_ProtobufTransform3d;
using InputStream = wpi::ProtoInputStream<frc::Transform3d>;
using OutputStream = wpi::ProtoOutputStream<frc::Transform3d>;
static std::optional<frc::Transform3d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Transform3d& value);
};

View File

@@ -8,11 +8,14 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Translation2d.h"
#include "pb.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Translation2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Translation2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Translation2d& value);
using MessageStruct = wpi_proto_ProtobufTranslation2d;
using InputStream = wpi::ProtoInputStream<frc::Translation2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Translation2d>;
static std::optional<frc::Translation2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Translation2d& value);
};

View File

@@ -8,11 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Translation3d.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Translation3d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Translation3d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg,
const frc::Translation3d& value);
using MessageStruct = wpi_proto_ProtobufTranslation3d;
using InputStream = wpi::ProtoInputStream<frc::Translation3d>;
using OutputStream = wpi::ProtoOutputStream<frc::Translation3d>;
static std::optional<frc::Translation3d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Translation3d& value);
};

View File

@@ -8,10 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Twist2d.h"
#include "wpimath/protobuf/geometry2d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Twist2d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Twist2d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg, const frc::Twist2d& value);
using MessageStruct = wpi_proto_ProtobufTwist2d;
using InputStream = wpi::ProtoInputStream<frc::Twist2d>;
using OutputStream = wpi::ProtoOutputStream<frc::Twist2d>;
static std::optional<frc::Twist2d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Twist2d& value);
};

View File

@@ -8,10 +8,13 @@
#include <wpi/protobuf/Protobuf.h>
#include "frc/geometry/Twist3d.h"
#include "wpimath/protobuf/geometry3d.npb.h"
template <>
struct WPILIB_DLLEXPORT wpi::Protobuf<frc::Twist3d> {
static google::protobuf::Message* New(google::protobuf::Arena* arena);
static frc::Twist3d Unpack(const google::protobuf::Message& msg);
static void Pack(google::protobuf::Message* msg, const frc::Twist3d& value);
using MessageStruct = wpi_proto_ProtobufTwist3d;
using InputStream = wpi::ProtoInputStream<frc::Twist3d>;
using OutputStream = wpi::ProtoOutputStream<frc::Twist3d>;
static std::optional<frc::Twist3d> Unpack(InputStream& stream);
static bool Pack(OutputStream& stream, const frc::Twist3d& value);
};