From edd963278386ed16e10c5d1fc7e0167d35b1f762 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 13 Oct 2023 09:19:32 -0500 Subject: [PATCH] Miscellaneous housekeeping (#398) Signed-off-by: Michael Carroll --- core/include/gz/msgs/convert/Pose.hh | 2 +- core/src/DynamicFactory.cc | 10 ++-- gz_msg_gen.bzl | 76 ---------------------------- test/integration/headers.cc | 1 - 4 files changed, 8 insertions(+), 81 deletions(-) delete mode 100644 gz_msg_gen.bzl diff --git a/core/include/gz/msgs/convert/Pose.hh b/core/include/gz/msgs/convert/Pose.hh index 73efa7e9..d18ccf46 100644 --- a/core/include/gz/msgs/convert/Pose.hh +++ b/core/include/gz/msgs/convert/Pose.hh @@ -21,7 +21,7 @@ #include // Message Headers -#include "gz/msgs/details/quaternion.pb.h" +#include "gz/msgs/quaternion.pb.h" #include "gz/msgs/pose.pb.h" // Data Headers diff --git a/core/src/DynamicFactory.cc b/core/src/DynamicFactory.cc index a8a7dac3..b46ad039 100644 --- a/core/src/DynamicFactory.cc +++ b/core/src/DynamicFactory.cc @@ -65,11 +65,15 @@ DynamicFactory::DynamicFactory() // Load all the descriptors found in the paths set with GZ_DESCRIPTOR_PATH. this->LoadDescriptors(descPaths); } - else + + auto globalPath = + std::filesystem::path(gz::msgs::getInstallPrefix()) / + "share" / "gz" / "protos"; + + if (std::filesystem::exists(globalPath)) { // Load descriptors from the global share path - this->LoadDescriptors((std::filesystem::path( - gz::msgs::getInstallPrefix()) / "share" / "gz" / "protos").string()); + this->LoadDescriptors(globalPath.string()); } } diff --git a/gz_msg_gen.bzl b/gz_msg_gen.bzl deleted file mode 100644 index 477e4875..00000000 --- a/gz_msg_gen.bzl +++ /dev/null @@ -1,76 +0,0 @@ -load("@rules_proto//proto:defs.bzl", "ProtoInfo") -load( - ":protobuf.bzl", - "declare_out_files", - "get_include_directory", - "get_out_dir", - "proto_path_to_generated_filename", - "protos_from_context", -) - -def gz_msg_gen_impl(ctx): - protos = protos_from_context(ctx) - dir_out = get_out_dir(protos, ctx) - - cc_files = declare_out_files(protos, ctx, "{}.pb.cc") - hh_files = declare_out_files(protos, ctx, "{}.pb.h") - out_files = cc_files + hh_files - - include_dirs = depset([get_include_directory(proto) for proto in protos]) - - args = [ - "--cpp_out=" + dir_out.path, - "--plugin=protoc-gen-gzmsgs=" + ctx.executable._plugin.path, - "--gzmsgs_out=" + dir_out.path, - ] - - for include_dir in include_dirs.to_list(): - args.append("--proto_path=" + include_dir) - - ctx.actions.run( - outputs = out_files, - inputs = protos, - tools = [ctx.executable._plugin, ctx.executable._protoc], - executable = ctx.executable._protoc, - arguments = args + [proto.path for proto in protos], - ) - - compilation_context = cc_common.create_compilation_context( - includes = depset([dir_out.path]), - ) - - return [ - DefaultInfo(files = depset(out_files)), - CcInfo(compilation_context = compilation_context), - ] - -gz_msg_gen = rule( - attrs = { - "deps": attr.label_list( - mandatory = True, - allow_empty = False, - providers = [ProtoInfo], - ), - "_plugin": attr.label( - default = Label("//gz_msgs:gz_msgs_gen"), - executable = True, - cfg = "host", - ), - "_protoc": attr.label( - default = Label("@com_google_protobuf//:protoc"), - executable = True, - cfg = "host", - ), - }, - # We generate .h files, so we need to output to genfiles. - output_to_genfiles = True, - implementation = gz_msg_gen_impl, -) - -def get_proto_headers(protos): - out = [] - for proto in protos: - split = proto.split("/")[1:] - split[2] = split[2].replace(".proto", ".pb.h") - out.append("/".join(split)) - return out diff --git a/test/integration/headers.cc b/test/integration/headers.cc index fe988858..64b88e49 100644 --- a/test/integration/headers.cc +++ b/test/integration/headers.cc @@ -16,7 +16,6 @@ */ #include -#include #include "gz/msgs/contact.pb.h" /////////////////////////////////////////////////