[wpiutil,glass,dlt] Replace libprotobuf with upb for dynamic decode (#7988)

libprotobuf is a very annoying dependency to deal with, and with the switch to nanopb for generated C++ code, libprotobuf is only used for dynamic decode in the GUI apps. libprotobuf has been swapped out with upb, a much smaller C-based library that supports reflection and can therefore do dynamic decode. This means we can remove the libprotobuf dependency and stop dealing with build issues because of it.
This commit is contained in:
Gold856
2025-08-17 01:56:32 -04:00
committed by GitHub
parent 7f35104012
commit d4311d5a29
408 changed files with 31336 additions and 141509 deletions

View File

@@ -110,13 +110,18 @@ void DataLogReaderThread::ReadMain() {
schema, err);
}
} else if (auto filename = wpi::remove_prefix(name, "/.schema/proto:")) {
#ifndef NO_PROTOBUF
// protobuf descriptor handling
if (!m_protoDb.Add(*filename, data)) {
upb_Status status;
status.ok = true;
upb_DefPool_AddFile(
m_protoPool,
google_protobuf_FileDescriptorProto_parse(
reinterpret_cast<const char*>(data.data()), data.size(), m_arena),
&status);
if (!status.ok) {
wpi::print("could not decode protobuf '{}' filename '{}'\n", name,
*filename);
}
#endif
}
}

View File

@@ -13,6 +13,8 @@
#include <utility>
#include <vector>
#include <upb/mem/arena.h>
#include <upb/reflection/def.h>
#include <wpi/DenseMap.h>
#include <wpi/Signal.h>
#include <wpi/mutex.h>
@@ -20,10 +22,6 @@
#include "wpi/datalog/DataLogReader.h"
#ifndef NO_PROTOBUF
#include <wpi/protobuf/ProtobufMessageDatabase.h>
#endif
namespace wpi::log {
class DataLogReaderRange {
@@ -88,9 +86,8 @@ class DataLogReaderThread {
}
wpi::StructDescriptorDatabase& GetStructDatabase() { return m_structDb; }
#ifndef NO_PROTOBUF
wpi::ProtobufMessageDatabase& GetProtobufDatabase() { return m_protoDb; }
#endif
upb_DefPool* GetProtobufDatabase() { return m_protoPool; }
upb_Arena* GetProtobufArena() { return m_arena; }
const wpi::log::DataLogReader& GetReader() const { return m_reader; }
@@ -109,9 +106,8 @@ class DataLogReaderThread {
std::map<std::string, DataLogReaderEntry, std::less<>> m_entriesByName;
wpi::DenseMap<int, DataLogReaderEntry*> m_entriesById;
wpi::StructDescriptorDatabase m_structDb;
#ifndef NO_PROTOBUF
wpi::ProtobufMessageDatabase m_protoDb;
#endif
upb_DefPool* m_protoPool = upb_DefPool_New();
upb_Arena* m_arena = upb_Arena_New();
std::thread m_thread;
};