@@ -40,57 +40,85 @@ endmacro()
40
40
# To facilitate this, the ARG_GENERATED_FILES is actually just the underlying ARG_MSG and ARG_SRV
41
41
# files which we feed the commands as DEPENDS to trigger their execution.
42
42
macro (_generate_module_java ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)
43
-
44
43
# ###############################
45
44
# Gradle Subproject
46
45
# ###############################
47
46
set (GRADLE_BUILD_DIR " ${CMAKE_CURRENT_BINARY_DIR}/java" )
48
47
set (GRADLE_BUILD_FILE " ${GRADLE_BUILD_DIR}/${ARG_PKG}/build.gradle" )
49
48
list (APPEND ALL_GEN_OUTPUT_FILES_java ${GRADLE_BUILD_FILE})
50
-
49
+ # a marker for the compiling script later to discover
50
+ # this command will only get run when an underlying dependency changes, whereas the compiling
51
+ # add_custom_target always runs (this was so we can ensure compile time dependencies are ok).
52
+ # So we leave this dropping to inform it when gradle needs to run so that we can skip by
53
+ # without the huge latency whenever we don't.
54
+ set (DROPPINGS_FILE " ${GRADLE_BUILD_DIR}/${ARG_PKG}/droppings" )
51
55
add_custom_command (OUTPUT ${GRADLE_BUILD_FILE}
52
- DEPENDS ${GENJAVA_BIN}
56
+ DEPENDS ${GENJAVA_BIN} ${ARG_GENERATED_FILES}
53
57
COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENJAVA_BIN}
54
58
- o ${GRADLE_BUILD_DIR}
55
59
- p ${ARG_PKG}
60
+ COMMAND touch ${DROPPINGS_FILE}
56
61
COMMENT " Generating Java gradle project from ${ARG_PKG}"
57
62
)
58
63
59
64
# ###############################
60
65
# Compile Gradle Subproject
61
66
# ###############################
67
+ # Push the compile back to the last thing that gets done before the generate messages
68
+ # is done for this package (see the PRE_LINK coupled with the TARGET option below). This
69
+ # is different to genpy, gencpp since it's a compile step. If you don't force it to be
70
+ # the last thing, then it may be trying to compile while dependencies are still getting
71
+ # themselves ready for ${ARG_PKG}_generate_messages in parallel.
72
+ # (i.e. beware of sequencing add_custom_command, it usually has to compete)
62
73
set (ROS_GRADLE_VERBOSE $ENV{ROS_GRADLE_VERBOSE})
63
74
if (ROS_GRADLE_VERBOSE)
64
- set (GRADLE_CMD " ./gradlew " )
75
+ set (verbosity " --verbosity " )
65
76
else ()
66
- set (GRADLE_CMD " ./gradlew;-q " )
77
+ set (verbosity " " )
67
78
endif ()
68
- set (GEN_OUTPUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/ generated_java_messages .flag )
69
79
70
- add_custom_command (OUTPUT ${GEN_OUTPUT_FILE}
80
+ add_custom_target (${ARG_PKG}_generate_messages_java_gradle
81
+ COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENJAVA_BIN}
82
+ ${verbosity}
83
+ -- compile
84
+ - o ${GRADLE_BUILD_DIR}
85
+ - p ${ARG_PKG}
71
86
DEPENDS ${GRADLE_BUILD_FILE} ${ARG_GENERATED_FILES}
72
- COMMAND ${CATKIN_ENV} ${GRADLE_CMD}
73
- COMMAND touch ${GEN_OUTPUT_FILE}
74
87
WORKING_DIRECTORY ${GRADLE_BUILD_DIR}/ ${ARG_PKG}
75
- COMMENT " Generating Java code for ${ARG_PKG}" )
76
- list (APPEND ALL_GEN_OUTPUT_FILES_java ${GEN_OUTPUT_FILE})
77
-
78
- # ###############################
79
- # Debugging
80
- # ###############################
81
- # foreach(gen_output_file ${ALL_GEN_OUTPUT_FILES_java})
82
- # message(STATUS "ALL_GEN_OUTPUT_FILES_java..........${gen_output_file}")
83
- # endforeach()
88
+ COMMENT " Compiling Java code for ${ARG_PKG}"
89
+ )
90
+ add_dependencies (${ARG_PKG}_generate_messages ${ARG_PKG}_generate_messages_java_gradle)
84
91
85
92
# ###############################
86
93
# Dependent Targets
87
94
# ###############################
95
+ # This is a bad hack that needs to disappear. e.g.
96
+ # - topic_tools and roscpp are both packages with a couple of msgs
97
+ # - topic tools messages doesn't actually depend on roscpp messages
98
+ # this is guarded, so it's not doubling up on work when called from catkin_package (roscpp does this too)
99
+ # and we need it to get access to the build_depends list just in case people called generate_messages before catkin_package()
100
+ if (NOT DEFINED ${ARG_PKG}_BUILD_DEPENDS)
101
+ catkin_package_xml (DIRECTORY ${PROJECT_SOURCE_DIR})
102
+ endif ()
103
+ foreach (depends ${${ARG_PKG}_BUILD_DEPENDS})
104
+ if (TARGET ${depends}_generate_messages_java_gradle)
105
+ message (STATUS " Adding dependency.....${depends}_generate_messages -> ${ARG_PKG}_generate_messages" )
106
+ add_dependencies (${ARG_PKG}_generate_messages_java_gradle ${depends}_generate_messages_java_gradle)
107
+ endif ()
108
+ endforeach ()
88
109
# Make sure we have built gradle-rosjava_bootstrap if it is in the source workspace
89
110
# (otherwise package.xml will make sure it has installed via rosdep/deb.
90
111
# if(TARGET gradle-rosjava_bootstrap)
91
112
# Preference would be to add it to ${ARG_PKG}_generate_messages_java but that
92
113
# is not defined till after this module is parsed, so add it all
93
114
# add_dependencies(${ARG_PKG}_generate_messages gradle-rosjava_bootstrap)
94
115
# endif()
116
+
117
+ # ###############################
118
+ # Debugging
119
+ # ###############################
120
+ # foreach(gen_output_file ${ALL_GEN_OUTPUT_FILES_java})
121
+ # message(STATUS "ALL_GEN_OUTPUT_FILES_java..........${gen_output_file}")
122
+ # endforeach()
95
123
endmacro ()
96
124
0 commit comments