From 2f987fa4e502b4fe1b74509ca094a9815377395b Mon Sep 17 00:00:00 2001 From: Peter Bech <1520592+techbech@users.noreply.github.com> Date: Tue, 10 Oct 2023 12:23:47 +0200 Subject: [PATCH] Reorganized protobuf (#37) --- CMakeLists.txt | 2 +- NEWS.rst | 2 +- .../{abacus_metric.proto => metrics.proto} | 0 src/abacus/detail/to_protobuf.hpp | 2 +- .../{abacus_metric.pb.cc => metrics.pb.cc} | 96 +++++++++---------- .../{abacus_metric.pb.h => metrics.pb.h} | 20 ++-- src/abacus/to_protobuf.cpp | 2 +- src/abacus/to_protobuf.hpp | 2 +- wscript | 3 +- 9 files changed, 65 insertions(+), 64 deletions(-) rename protobuf/{abacus_metric.proto => metrics.proto} (100%) rename src/abacus/protobuf/{abacus_metric.pb.cc => metrics.pb.cc} (92%) rename src/abacus/protobuf/{abacus_metric.pb.h => metrics.pb.h} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09f29aa..42f7b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,7 +64,7 @@ endif() target_link_libraries(abacus PRIVATE steinwurf::endian) target_link_libraries(abacus PUBLIC steinwurf::protobuf) -target_include_directories(abacus INTERFACE src) +target_include_directories(abacus PUBLIC src) target_compile_features(abacus PUBLIC cxx_std_14) add_library(steinwurf::abacus ALIAS abacus) diff --git a/NEWS.rst b/NEWS.rst index feeb79a..41115e3 100644 --- a/NEWS.rst +++ b/NEWS.rst @@ -6,7 +6,7 @@ every change, see the Git log. Latest ------ -* tbd +* Patch: Reorganized protobuf. 5.2.1 ----- diff --git a/protobuf/abacus_metric.proto b/protobuf/metrics.proto similarity index 100% rename from protobuf/abacus_metric.proto rename to protobuf/metrics.proto diff --git a/src/abacus/detail/to_protobuf.hpp b/src/abacus/detail/to_protobuf.hpp index a906d3c..22bda1d 100644 --- a/src/abacus/detail/to_protobuf.hpp +++ b/src/abacus/detail/to_protobuf.hpp @@ -6,7 +6,7 @@ #pragma once -#include "../protobuf/abacus_metric.pb.h" +#include "../protobuf/metrics.pb.h" #include "../view.hpp" #include "../version.hpp" diff --git a/src/abacus/protobuf/abacus_metric.pb.cc b/src/abacus/protobuf/metrics.pb.cc similarity index 92% rename from src/abacus/protobuf/abacus_metric.pb.cc rename to src/abacus/protobuf/metrics.pb.cc index 0122529..a406a6d 100644 --- a/src/abacus/protobuf/abacus_metric.pb.cc +++ b/src/abacus/protobuf/metrics.pb.cc @@ -1,7 +1,7 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: abacus_metric.proto +// source: abacus/protobuf/metrics.proto -#include "abacus_metric.pb.h" +#include "abacus/protobuf/metrics.pb.h" #include #include "google/protobuf/io/coded_stream.h" @@ -92,11 +92,11 @@ PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PROTOBUF_ATTRIBUTE_INIT_PRIORITY1 MetricsDefaultTypeInternal _Metrics_default_instance_; } // namespace protobuf } // namespace abacus -static ::_pb::Metadata file_level_metadata_abacus_5fmetric_2eproto[3]; -static const ::_pb::EnumDescriptor* file_level_enum_descriptors_abacus_5fmetric_2eproto[2]; +static ::_pb::Metadata file_level_metadata_abacus_2fprotobuf_2fmetrics_2eproto[3]; +static const ::_pb::EnumDescriptor* file_level_enum_descriptors_abacus_2fprotobuf_2fmetrics_2eproto[2]; static constexpr const ::_pb::ServiceDescriptor** - file_level_service_descriptors_abacus_5fmetric_2eproto = nullptr; -const ::uint32_t TableStruct_abacus_5fmetric_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( + file_level_service_descriptors_abacus_2fprotobuf_2fmetrics_2eproto = nullptr; +const ::uint32_t TableStruct_abacus_2fprotobuf_2fmetrics_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE( protodesc_cold) = { ~0u, // no _has_bits_ PROTOBUF_FIELD_OFFSET(::abacus::protobuf::Info, _internal_metadata_), @@ -162,43 +162,43 @@ static const ::_pb::Message* const file_default_instances[] = { &::abacus::protobuf::_Metric_default_instance_._instance, &::abacus::protobuf::_Metrics_default_instance_._instance, }; -const char descriptor_table_protodef_abacus_5fmetric_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { - "\n\023abacus_metric.proto\022\017abacus.protobuf\"\223" - "\002\n\004Info\022\014\n\004name\030\001 \001(\t\022\023\n\013description\030\002 \001" - "(\t\022#\n\004type\030\003 \001(\0162\025.abacus.protobuf.Type\022" - "#\n\004kind\030\004 \001(\0162\025.abacus.protobuf.Kind\022\014\n\004" - "unit\030\005 \001(\t\022\024\n\nuint64_min\030\006 \001(\004H\000\022\023\n\tint6" - "4_min\030\007 \001(\003H\000\022\025\n\013float64_min\030\010 \001(\001H\000\022\024\n\n" - "uint64_max\030\t \001(\004H\001\022\023\n\tint64_max\030\n \001(\003H\001\022" - "\025\n\013float64_max\030\013 \001(\001H\001B\005\n\003minB\005\n\003max\"\242\001\n" - "\006Metric\022(\n\004info\030\001 \001(\0132\025.abacus.protobuf." - "InfoH\001\210\001\001\022\026\n\014uint64_value\030\002 \001(\004H\000\022\025\n\013int" - "64_value\030\003 \001(\003H\000\022\027\n\rfloat64_value\030\004 \001(\001H" - "\000\022\024\n\nbool_value\030\005 \001(\010H\000B\007\n\005valueB\007\n\005_inf" - "o\"L\n\007Metrics\022\030\n\020protocol_version\030\001 \001(\r\022\'" - "\n\006metric\030\002 \003(\0132\027.abacus.protobuf.Metric*" - ",\n\004Kind\022\013\n\007COUNTER\020\000\022\014\n\010CONSTANT\020\001\022\t\n\005GA" - "UGE\020\002*4\n\004Type\022\n\n\006UINT64\020\000\022\t\n\005INT64\020\001\022\013\n\007" - "FLOAT64\020\002\022\010\n\004BOOL\020\003B\021Z\017abacus/protobufb\006" - "proto3" +const char descriptor_table_protodef_abacus_2fprotobuf_2fmetrics_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = { + "\n\035abacus/protobuf/metrics.proto\022\017abacus." + "protobuf\"\223\002\n\004Info\022\014\n\004name\030\001 \001(\t\022\023\n\013descr" + "iption\030\002 \001(\t\022#\n\004type\030\003 \001(\0162\025.abacus.prot" + "obuf.Type\022#\n\004kind\030\004 \001(\0162\025.abacus.protobu" + "f.Kind\022\014\n\004unit\030\005 \001(\t\022\024\n\nuint64_min\030\006 \001(\004" + "H\000\022\023\n\tint64_min\030\007 \001(\003H\000\022\025\n\013float64_min\030\010" + " \001(\001H\000\022\024\n\nuint64_max\030\t \001(\004H\001\022\023\n\tint64_ma" + "x\030\n \001(\003H\001\022\025\n\013float64_max\030\013 \001(\001H\001B\005\n\003minB" + "\005\n\003max\"\242\001\n\006Metric\022(\n\004info\030\001 \001(\0132\025.abacus" + ".protobuf.InfoH\001\210\001\001\022\026\n\014uint64_value\030\002 \001(" + "\004H\000\022\025\n\013int64_value\030\003 \001(\003H\000\022\027\n\rfloat64_va" + "lue\030\004 \001(\001H\000\022\024\n\nbool_value\030\005 \001(\010H\000B\007\n\005val" + "ueB\007\n\005_info\"L\n\007Metrics\022\030\n\020protocol_versi" + "on\030\001 \001(\r\022\'\n\006metric\030\002 \003(\0132\027.abacus.protob" + "uf.Metric*,\n\004Kind\022\013\n\007COUNTER\020\000\022\014\n\010CONSTA" + "NT\020\001\022\t\n\005GAUGE\020\002*4\n\004Type\022\n\n\006UINT64\020\000\022\t\n\005I" + "NT64\020\001\022\013\n\007FLOAT64\020\002\022\010\n\004BOOL\020\003B\021Z\017abacus/" + "protobufb\006proto3" }; -static ::absl::once_flag descriptor_table_abacus_5fmetric_2eproto_once; -const ::_pbi::DescriptorTable descriptor_table_abacus_5fmetric_2eproto = { +static ::absl::once_flag descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_once; +const ::_pbi::DescriptorTable descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto = { false, false, - 686, - descriptor_table_protodef_abacus_5fmetric_2eproto, - "abacus_metric.proto", - &descriptor_table_abacus_5fmetric_2eproto_once, + 696, + descriptor_table_protodef_abacus_2fprotobuf_2fmetrics_2eproto, + "abacus/protobuf/metrics.proto", + &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_once, nullptr, 0, 3, schemas, file_default_instances, - TableStruct_abacus_5fmetric_2eproto::offsets, - file_level_metadata_abacus_5fmetric_2eproto, - file_level_enum_descriptors_abacus_5fmetric_2eproto, - file_level_service_descriptors_abacus_5fmetric_2eproto, + TableStruct_abacus_2fprotobuf_2fmetrics_2eproto::offsets, + file_level_metadata_abacus_2fprotobuf_2fmetrics_2eproto, + file_level_enum_descriptors_abacus_2fprotobuf_2fmetrics_2eproto, + file_level_service_descriptors_abacus_2fprotobuf_2fmetrics_2eproto, }; // This function exists to be marked as weak. @@ -212,17 +212,17 @@ const ::_pbi::DescriptorTable descriptor_table_abacus_5fmetric_2eproto = { // vtables -> GetMetadata // By adding a weak function here we break the connection from the // individual vtables back into the descriptor table. -PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_abacus_5fmetric_2eproto_getter() { - return &descriptor_table_abacus_5fmetric_2eproto; +PROTOBUF_ATTRIBUTE_WEAK const ::_pbi::DescriptorTable* descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_getter() { + return &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto; } // Force running AddDescriptors() at dynamic initialization time. PROTOBUF_ATTRIBUTE_INIT_PRIORITY2 -static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_abacus_5fmetric_2eproto(&descriptor_table_abacus_5fmetric_2eproto); +static ::_pbi::AddDescriptorsRunner dynamic_init_dummy_abacus_2fprotobuf_2fmetrics_2eproto(&descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto); namespace abacus { namespace protobuf { const ::google::protobuf::EnumDescriptor* Kind_descriptor() { - ::google::protobuf::internal::AssignDescriptors(&descriptor_table_abacus_5fmetric_2eproto); - return file_level_enum_descriptors_abacus_5fmetric_2eproto[0]; + ::google::protobuf::internal::AssignDescriptors(&descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto); + return file_level_enum_descriptors_abacus_2fprotobuf_2fmetrics_2eproto[0]; } bool Kind_IsValid(int value) { switch (value) { @@ -235,8 +235,8 @@ bool Kind_IsValid(int value) { } } const ::google::protobuf::EnumDescriptor* Type_descriptor() { - ::google::protobuf::internal::AssignDescriptors(&descriptor_table_abacus_5fmetric_2eproto); - return file_level_enum_descriptors_abacus_5fmetric_2eproto[1]; + ::google::protobuf::internal::AssignDescriptors(&descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto); + return file_level_enum_descriptors_abacus_2fprotobuf_2fmetrics_2eproto[1]; } bool Type_IsValid(int value) { switch (value) { @@ -825,8 +825,8 @@ void Info::InternalSwap(Info* other) { ::google::protobuf::Metadata Info::GetMetadata() const { return ::_pbi::AssignDescriptors( - &descriptor_table_abacus_5fmetric_2eproto_getter, &descriptor_table_abacus_5fmetric_2eproto_once, - file_level_metadata_abacus_5fmetric_2eproto[0]); + &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_getter, &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_once, + file_level_metadata_abacus_2fprotobuf_2fmetrics_2eproto[0]); } // =================================================================== @@ -1173,8 +1173,8 @@ void Metric::InternalSwap(Metric* other) { ::google::protobuf::Metadata Metric::GetMetadata() const { return ::_pbi::AssignDescriptors( - &descriptor_table_abacus_5fmetric_2eproto_getter, &descriptor_table_abacus_5fmetric_2eproto_once, - file_level_metadata_abacus_5fmetric_2eproto[1]); + &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_getter, &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_once, + file_level_metadata_abacus_2fprotobuf_2fmetrics_2eproto[1]); } // =================================================================== @@ -1372,8 +1372,8 @@ void Metrics::InternalSwap(Metrics* other) { ::google::protobuf::Metadata Metrics::GetMetadata() const { return ::_pbi::AssignDescriptors( - &descriptor_table_abacus_5fmetric_2eproto_getter, &descriptor_table_abacus_5fmetric_2eproto_once, - file_level_metadata_abacus_5fmetric_2eproto[2]); + &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_getter, &descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto_once, + file_level_metadata_abacus_2fprotobuf_2fmetrics_2eproto[2]); } // @@protoc_insertion_point(namespace_scope) } // namespace protobuf diff --git a/src/abacus/protobuf/abacus_metric.pb.h b/src/abacus/protobuf/metrics.pb.h similarity index 98% rename from src/abacus/protobuf/abacus_metric.pb.h rename to src/abacus/protobuf/metrics.pb.h index 7e17d60..e7e8a09 100644 --- a/src/abacus/protobuf/abacus_metric.pb.h +++ b/src/abacus/protobuf/metrics.pb.h @@ -1,8 +1,8 @@ // Generated by the protocol buffer compiler. DO NOT EDIT! -// source: abacus_metric.proto +// source: abacus/protobuf/metrics.proto -#ifndef GOOGLE_PROTOBUF_INCLUDED_abacus_5fmetric_2eproto_2epb_2eh -#define GOOGLE_PROTOBUF_INCLUDED_abacus_5fmetric_2eproto_2epb_2eh +#ifndef GOOGLE_PROTOBUF_INCLUDED_abacus_2fprotobuf_2fmetrics_2eproto_2epb_2eh +#define GOOGLE_PROTOBUF_INCLUDED_abacus_2fprotobuf_2fmetrics_2eproto_2epb_2eh #include #include @@ -38,7 +38,7 @@ // Must be included last. #include "google/protobuf/port_def.inc" -#define PROTOBUF_INTERNAL_EXPORT_abacus_5fmetric_2eproto +#define PROTOBUF_INTERNAL_EXPORT_abacus_2fprotobuf_2fmetrics_2eproto namespace google { namespace protobuf { @@ -49,11 +49,11 @@ class AnyMetadata; } // namespace google // Internal implementation detail -- do not use these members. -struct TableStruct_abacus_5fmetric_2eproto { +struct TableStruct_abacus_2fprotobuf_2fmetrics_2eproto { static const ::uint32_t offsets[]; }; extern const ::google::protobuf::internal::DescriptorTable - descriptor_table_abacus_5fmetric_2eproto; + descriptor_table_abacus_2fprotobuf_2fmetrics_2eproto; namespace abacus { namespace protobuf { class Info; @@ -486,7 +486,7 @@ class Info final : PROTOBUF_TSAN_DECLARE_MEMBER }; union { Impl_ _impl_; }; - friend struct ::TableStruct_abacus_5fmetric_2eproto; + friend struct ::TableStruct_abacus_2fprotobuf_2fmetrics_2eproto; };// ------------------------------------------------------------------- class Metric final : @@ -725,7 +725,7 @@ class Metric final : PROTOBUF_TSAN_DECLARE_MEMBER }; union { Impl_ _impl_; }; - friend struct ::TableStruct_abacus_5fmetric_2eproto; + friend struct ::TableStruct_abacus_2fprotobuf_2fmetrics_2eproto; };// ------------------------------------------------------------------- class Metrics final : @@ -903,7 +903,7 @@ class Metrics final : PROTOBUF_TSAN_DECLARE_MEMBER }; union { Impl_ _impl_; }; - friend struct ::TableStruct_abacus_5fmetric_2eproto; + friend struct ::TableStruct_abacus_2fprotobuf_2fmetrics_2eproto; }; // =================================================================== @@ -1700,4 +1700,4 @@ inline const EnumDescriptor* GetEnumDescriptor<::abacus::protobuf::Type>() { #include "google/protobuf/port_undef.inc" -#endif // GOOGLE_PROTOBUF_INCLUDED_abacus_5fmetric_2eproto_2epb_2eh +#endif // GOOGLE_PROTOBUF_INCLUDED_abacus_2fprotobuf_2fmetrics_2eproto_2epb_2eh diff --git a/src/abacus/to_protobuf.cpp b/src/abacus/to_protobuf.cpp index 828b0c1..af3c933 100644 --- a/src/abacus/to_protobuf.cpp +++ b/src/abacus/to_protobuf.cpp @@ -6,7 +6,7 @@ // Distributed under the "BSD License". See the accompanying LICENSE.rst file. #include "detail/to_protobuf.hpp" -#include "protobuf/abacus_metric.pb.h" +#include "protobuf/metrics.pb.h" #include "to_protobuf.hpp" #include "view.hpp" diff --git a/src/abacus/to_protobuf.hpp b/src/abacus/to_protobuf.hpp index 01fea2d..731d118 100644 --- a/src/abacus/to_protobuf.hpp +++ b/src/abacus/to_protobuf.hpp @@ -8,7 +8,7 @@ #include -#include "protobuf/abacus_metric.pb.h" +#include "protobuf/metrics.pb.h" #include "version.hpp" #include "view.hpp" diff --git a/wscript b/wscript index 613a58a..0b365e4 100644 --- a/wscript +++ b/wscript @@ -33,6 +33,7 @@ def build(bld): use=["protobuf", "endian_includes", "bourne"], install_path="${PREFIX}/lib", cxxflags=cxxflags, + includes=["src"], export_includes=["src"], ) @@ -78,7 +79,7 @@ def protogen(ctx): os.mkdir("src/abacus/protobuf") ctx.exec_command( - f"./{protoc_location} --cpp_out ./src/abacus/protobuf --proto_path ./protobuf protobuf/*.proto" + f"(./{protoc_location} --cpp_out ./src --proto_path .. ../abacus/protobuf/*.proto)" ) ctx.exec_command(