Skip to content

Commit

Permalink
Have flags of deprecation for message and service files
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed May 29, 2018
1 parent 5dfa703 commit 7c9d295
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 39 deletions.
18 changes: 6 additions & 12 deletions cmake/genmsg-extras.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,10 @@ macro(add_message_files)
endif()
_prepend_path(${MESSAGE_DIR} "${ARG_FILES}" FILES_W_PATH)

if(ARG_DEPRECATED)
list(APPEND ${PROJECT_NAME}_DEPRECATED_MESSAGE_FILES ${FILES_W_PATH})
else()
list(APPEND ${PROJECT_NAME}_MESSAGE_FILES ${FILES_W_PATH})
endif()
list(APPEND ${PROJECT_NAME}_MESSAGE_FILES ${FILES_W_PATH})
foreach(file ${FILES_W_PATH})
assert_file_exists(${file} "message file not found")
list(APPEND ${PROJECT_NAME}_MESSAGE_FILE_DEPRECATED_FLAGS ${ARG_DEPRECATED})
endforeach()

# remember path to messages to resolve them as dependencies
Expand Down Expand Up @@ -174,13 +171,10 @@ macro(add_service_files)
endif()
_prepend_path(${SERVICE_DIR} "${ARG_FILES}" FILES_W_PATH)

if(ARG_DEPRECATED)
list(APPEND ${PROJECT_NAME}_DEPRECATED_SERVICE_FILES ${FILES_W_PATH})
else()
list(APPEND ${PROJECT_NAME}_SERVICE_FILES ${FILES_W_PATH})
endif()
list(APPEND ${PROJECT_NAME}_SERVICE_FILES ${FILES_W_PATH})
foreach(file ${FILES_W_PATH})
assert_file_exists(${file} "service file not found")
list(APPEND ${PROJECT_NAME}_SERVICE_FILE_DEPRECATED_FLAGS ${ARG_DEPRECATED})
endforeach()

if(NOT ARG_NOINSTALL)
Expand Down Expand Up @@ -211,9 +205,9 @@ macro(generate_messages)
endif()

set(ARG_MESSAGES ${${PROJECT_NAME}_MESSAGE_FILES})
set(ARG_DEPRECATED_MESSAGES ${${PROJECT_NAME}_DEPRECATED_MESSAGE_FILES})
set(ARG_MESSAGE_DEPRECATED_FLAGS ${${PROJECT_NAME}_MESSAGE_FILE_DEPRECATED_FLAGS})
set(ARG_SERVICES ${${PROJECT_NAME}_SERVICE_FILES})
set(ARG_DEPRECATED_SERVICES ${${PROJECT_NAME}_DEPRECATED_SERVICE_FILES})
set(ARG_SERVICE_DEPRECATED_FLAGS ${${PROJECT_NAME}_SERVICE_FILE_DEPRECATED_FLAGS})
set(ARG_DEPENDENCIES ${ARG_DEPENDENCIES})

if(ARG_LANGS)
Expand Down
44 changes: 19 additions & 25 deletions cmake/pkg-genmsg.cmake.em
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import genmsg.gentools

# split incoming variables
messages = messages_str.split(';') if messages_str != '' else []
deprecated_messages = deprecated_messages_str.split(';') if deprecated_messages_str != '' else []
message_deprecated_flags = {m: d == 'TRUE' for m, d in zip(messages, message_deprecated_flags_bool.split(';'))}
services = services_str.split(';') if services_str != '' else []
deprecated_services = deprecated_services_str.split(';') if deprecated_services_str != '' else []
service_deprecated_flags = {s: d == 'TRUE' for s, d in zip(services, service_deprecated_flags_bool.split(';'))}
dependencies = dependencies_str.split(';') if dependencies_str != '' else []
dep_search_paths = dep_include_paths_str.split(';') if dep_include_paths_str != '' else []

Expand All @@ -32,34 +32,28 @@ for val in dep_search_paths:
is_even = True
dep_search_paths = dep_search_paths_dict

if not messages and not deprecated_messages and not services and not deprecated_services:
if not messages and not services:
print('message(WARNING "Invoking generate_messages() without having added any message or service file before.\nYou should either add add_message_files() and/or add_service_files() calls or remove the invocation of generate_messages().")')

msg_deps = {}
msg_dep_types = {}
msg_is_deprecated = {}
for is_deprecated, msgs in zip([0, 1], [messages, deprecated_messages]):
for m in msgs:
try:
_deps = genmsg.deps.find_msg_dependencies_with_type(pkg_name, m, dep_search_paths)
msg_deps[m] = [d[1] for d in _deps]
msg_dep_types[m] = [d[0] for d in _deps]
msg_is_deprecated[m] = is_deprecated
except genmsg.MsgNotFound as e:
print('message(FATAL_ERROR "Could not find messages which \'%s\' depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?\n%s")' % (m, str(e).replace('"', '\\"')))
for m in messages:
try:
_deps = genmsg.deps.find_msg_dependencies_with_type(pkg_name, m, dep_search_paths)
msg_deps[m] = [d[1] for d in _deps]
msg_dep_types[m] = [d[0] for d in _deps]
except genmsg.MsgNotFound as e:
print('message(FATAL_ERROR "Could not find messages which \'%s\' depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?\n%s")' % (m, str(e).replace('"', '\\"')))

srv_deps = {}
srv_dep_types = {}
srv_is_deprecated = {}
for is_deprecated, srvs in zip([0, 1], [services, deprecated_services]):
for s in srvs:
try:
_deps = genmsg.deps.find_srv_dependencies_with_type(pkg_name, s, dep_search_paths)
srv_deps[s] = [d[1] for d in _deps]
srv_dep_types[s] = [d[0] for d in _deps]
srv_is_deprecated[s] = is_deprecated
except genmsg.MsgNotFound as e:
print('message(FATAL_ERROR "Could not find messages which \'%s\' depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?\n%s")' % (s, str(e).replace('"', '\\"')))
for s in services:
try:
_deps = genmsg.deps.find_srv_dependencies_with_type(pkg_name, s, dep_search_paths)
srv_deps[s] = [d[1] for d in _deps]
srv_dep_types[s] = [d[0] for d in _deps]
except genmsg.MsgNotFound as e:
print('message(FATAL_ERROR "Could not find messages which \'%s\' depends on. Did you forget to specify generate_messages(DEPENDENCIES ...)?\n%s")' % (s, str(e).replace('"', '\\"')))

}@
message(STATUS "@(pkg_name): @(len(messages)) messages, @(len(services)) services")
Expand Down Expand Up @@ -100,7 +94,7 @@ _generate_msg_@(l[3:])(@pkg_name
"${MSG_I_FLAGS}"
"@(';'.join(msg_deps[m]).replace("\\","/"))"
${CATKIN_DEVEL_PREFIX}/${@(l)_INSTALL_DIR}/@pkg_name
"@msg_is_deprecated[m]"
"@message_deprecated_flags[m]"
)
@[end for]@# messages

Expand All @@ -111,7 +105,7 @@ _generate_srv_@(l[3:])(@pkg_name
"${MSG_I_FLAGS}"
"@(';'.join(srv_deps[s]).replace("\\","/"))"
${CATKIN_DEVEL_PREFIX}/${@(l)_INSTALL_DIR}/@pkg_name
"@srv_is_deprecated[s]"
"@service_deprecated_flags[s]"
)
@[end for]@# services
Expand Down
4 changes: 2 additions & 2 deletions cmake/pkg-genmsg.context.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# generated from genmsg/cmake/pkg-genmsg.context.in

messages_str = "@ARG_MESSAGES@"
deprecated_messages_str = "@ARG_DEPRECATED_MESSAGES@"
message_deprecated_flags_bool = "@ARG_MESSAGE_DEPRECATED_FLAGS@"
services_str = "@ARG_SERVICES@"
deprecated_services_str = "@ARG_DEPRECATED_SERVICES@"
service_deprecated_flags_bool = "@ARG_SERVICE_DEPRECATED_FLAGS@"
pkg_name = "@PROJECT_NAME@"
dependencies_str = "@ARG_DEPENDENCIES@"
langs = "@GEN_LANGS@"
Expand Down

0 comments on commit 7c9d295

Please sign in to comment.