Skip to content

Commit

Permalink
(dbg) correct dlltool call
Browse files Browse the repository at this point in the history
  • Loading branch information
MementoRC committed Oct 4, 2024
1 parent 91ce13a commit ae31ce5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
11 changes: 8 additions & 3 deletions recipes/libdydx_v4_proto-devel/cmake/GenerateProtobufLib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ if(WIN32)
TARGET _proto_objects
PROTOC_OUT_DIR ${PROTO_BINARY_DIR}
OUT_VAR PROTO_GENERATED_FILES
PLUGIN "add_exports=$<TARGET_FILE:add_protoc_export>"
EXPORT_MACRO DYDX_V4_PROTO_EXPORT
PROTOC_OPTIONS
"--add_exports_out=${PROTO_BINARY_DIR}"
LANGUAGE cpp)
add_custom_command(
TARGET _proto_objects
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "Running add_protoc_export"
COMMAND $<TARGET_FILE:add_protoc_export> --add_exports_out=${PROTO_BINARY_DIR} -I ${CMAKE_SOURCE_DIR}/lib/proto ${proto_files}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS add_protoc_export
)
else()
protobuf_generate(
TARGET _proto_objects
Expand Down
10 changes: 5 additions & 5 deletions recipes/libdydx_v4_proto-devel/cmake/add_protoc_export.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <google/protobuf/compiler/plugin.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <fstream>
#include <string>

Expand All @@ -12,7 +12,7 @@ class AddExportsGenerator : public google::protobuf::compiler::CodeGenerator {
const std::string& parameter,
google::protobuf::compiler::GeneratorContext* generator_context,
std::string* error) const override {
std::string output = "#ifdef DYDX_V4_PROTO_EXPORT\n";
std::string output = "\n#ifdef DYDX_V4_PROTO_EXPORT\n";
for (int i = 0; i < file->message_type_count(); ++i) {
const google::protobuf::Descriptor* message = file->message_type(i);
output += "class DYDX_V4_PROTO_EXPORT " + message->name() + ";\n";
Expand All @@ -26,11 +26,11 @@ class AddExportsGenerator : public google::protobuf::compiler::CodeGenerator {

std::string file_name = file->name() + ".pb.h";
std::unique_ptr<google::protobuf::io::ZeroCopyOutputStream> stream(
generator_context->OpenForInsert(file_name, "includes"));
generator_context->Open(file_name));

if (stream) {
google::protobuf::io::Printer printer(stream.get(), '$');
printer.Print(output.c_str());
google::protobuf::io::CodedOutputStream coded_stream(stream.get());
coded_stream.WriteString(output);
} else {
*error = "Failed to open file for writing: " + file_name;
return false;
Expand Down

0 comments on commit ae31ce5

Please sign in to comment.