Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generator expression #374

Merged
merged 5 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
gz_configure_project(VERSION_SUFFIX
CONFIG_EXTRAS "gz-msgs-extras.cmake.in")

# Install cmake support files
install(
DIRECTORY cmake/
DESTINATION "${PROJECT_CMAKE_EXTRAS_INSTALL_DIR}"
)

#============================================================================
# Set project-specific options
#============================================================================
Expand Down Expand Up @@ -153,6 +147,22 @@ add_subdirectory(python)
#============================================================================
gz_create_packages()

#============================================================================
# Install cmake extras for downstream users
#============================================================================
# Necessary to populate generator expressions
file(
GENERATE
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/gz-cmake/gz-msgs-extras.cmake"
INPUT "${CMAKE_CURRENT_BINARY_DIR}/gz-cmake/gz-msgs-extras.cmake"
)

# Install cmake support files
install(
DIRECTORY cmake/
DESTINATION "${PROJECT_CMAKE_EXTRAS_INSTALL_DIR}"
)

#============================================================================
# Create documentation
#============================================================================
Expand Down
12 changes: 12 additions & 0 deletions core/src/DynamicFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ void DynamicFactory::LoadDescriptors(const std::string &_paths)
if (_paths.empty())
return;

std::cout << "DynamicFactory::LoadDescriptors(" << _paths << "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove


// Split all the directories containing .desc files.
std::vector<std::string> descDirs =
split(_paths, kEnvironmentVariableSeparator);
Expand Down Expand Up @@ -113,6 +115,16 @@ void DynamicFactory::LoadDescriptors(const std::string &_paths)
for (const google::protobuf::FileDescriptorProto &fileDescriptorProto :
fileDescriptorSet.file())
{
// If the descriptor already exists in the database, then skip it.
// This may happen as gz_desc files can potentially contain the
// transitive message definitions
google::protobuf::FileDescriptorProto checkDescriptorProto;
if (this->db.FindFileByName(
fileDescriptorProto.name(), &checkDescriptorProto))
{
continue;
}

if (!static_cast<bool>(pool.BuildFile(fileDescriptorProto)))
{
std::cerr << "DynamicFactory(). Unable to place descriptors from ["
Expand Down
2 changes: 1 addition & 1 deletion gz-msgs-extras.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ include(${@PROJECT_NAME@_DIR}/gz_msgs_generate.cmake)

set(@PROJECT_NAME@_INSTALL_PATH "${@PROJECT_NAME@_DIR}/@PROJECT_CMAKE_EXTRAS_PATH_TO_PREFIX@")
cmake_path(NORMAL_PATH @PROJECT_NAME@_INSTALL_PATH OUTPUT_VARIABLE @PROJECT_NAME@_INSTALL_PATH)
set(PROTOC_NAME "@PROJECT_NAME@_protoc_plugin")
set(PROTOC_NAME "$<TARGET_FILE_NAME:@PROJECT_NAME@_protoc_plugin>")
set(PROTO_SCRIPT_NAME "@PROJECT_NAME@_generate.py")
set(FACTORY_SCRIPT_NAME "@PROJECT_NAME@_generate_factory.py")

Expand Down