From 4e2ffe9993030e170b0f53ae579ac272f15402f1 Mon Sep 17 00:00:00 2001 From: cryptocode Date: Mon, 13 Sep 2021 19:49:16 +0200 Subject: [PATCH] Have cmake copy flatbuffer schema files to simplify dev (#3446) --- nano/ipc_flatbuffers_lib/CMakeLists.txt | 6 ++++++ nano/node/ipc/flatbuffers_handler.cpp | 18 ++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/nano/ipc_flatbuffers_lib/CMakeLists.txt b/nano/ipc_flatbuffers_lib/CMakeLists.txt index d7e1d9ad4c..1cf92097d6 100644 --- a/nano/ipc_flatbuffers_lib/CMakeLists.txt +++ b/nano/ipc_flatbuffers_lib/CMakeLists.txt @@ -48,6 +48,12 @@ foreach(file ${files}) message( "Generating flatbuffers code for: ${flatbuffers_filename} into ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers" ) + + configure_file( + ${file} + ${PROJECT_BINARY_DIR}/${CMAKE_BUILD_TYPE}/api/flatbuffers/${flatbuffers_filename}.fbs + COPYONLY) + add_custom_command( OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/generated/flatbuffers/${flatbuffers_filename}_generated.h diff --git a/nano/node/ipc/flatbuffers_handler.cpp b/nano/node/ipc/flatbuffers_handler.cpp index ca91f527a9..01ca293796 100644 --- a/nano/node/ipc/flatbuffers_handler.cpp +++ b/nano/node/ipc/flatbuffers_handler.cpp @@ -35,25 +35,15 @@ std::string make_error_response (std::string const & error_message) /** * Returns the 'api/flatbuffers' directory, boost::none if not found. - * This searches the binary path as well as the parent (which is mostly useful for development) */ boost::optional get_api_path () { - auto parent_path = boost::dll::program_location ().parent_path (); - if (!boost::filesystem::exists (parent_path / "api" / "flatbuffers")) + boost::filesystem::path const fb_path = "api/flatbuffers"; + if (!boost::filesystem::exists (fb_path)) { - // See if the parent directory has the api subdirectories - if (parent_path.has_parent_path ()) - { - parent_path = boost::dll::program_location ().parent_path ().parent_path (); - } - - if (!boost::filesystem::exists (parent_path / "api" / "flatbuffers")) - { - return boost::none; - } + return boost::none; } - return parent_path / "api" / "flatbuffers"; + return fb_path; } }