Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 52 additions & 25 deletions rcljava/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ find_package(ament_cmake_export_jars REQUIRED)
find_package(rcl REQUIRED)
find_package(rmw REQUIRED)
find_package(rmw_implementation_cmake REQUIRED)
find_package(rcljava_common REQUIRED)
find_package(JavaExtra MODULE)

if (ANDROID)
if(ANDROID)
find_host_package(Java COMPONENTS Development)
else()
find_package(Java COMPONENTS Development)
find_package(JNI REQUIRED)
endif()

include (UseJava)
include(UseJava)

set(CMAKE_JAVA_COMPILE_FLAGS "-source" "1.6" "-target" "1.6")

if(NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra")
endif()

include_directories(include)

macro(target)
if(NOT "${target_suffix} " STREQUAL " ")
get_rcl_information("${rmw_implementation}" "rcl${target_suffix}")
Expand Down Expand Up @@ -56,37 +60,31 @@ macro(target)

ament_target_dependencies(${_target_name}
"rcl${target_suffix}"
"rcljava_common"
)

target_include_directories(${_target_name}
PUBLIC
${JNI_INCLUDE_DIRS}
)

if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
ament_export_libraries(${_target_name})
ament_export_libraries(${_target_name})

install(TARGETS ${_msg_name}${_javaext_suffix}
DESTINATION "${PYTHON_INSTALL_DIR}/${PROJECT_NAME}/${_msg_package_dir2}"
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(TARGETS ${_target_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
endif()
install(TARGETS ${_target_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

endforeach()

endmacro()

set(${PROJECT_NAME}_sources
"src/main/java/org/ros2/rcljava/Consumer.java"
"src/main/java/org/ros2/rcljava/Node.java"
"src/main/java/org/ros2/rcljava/RCLJava.java"
"src/main/java/org/ros2/rcljava/Publisher.java"
"src/main/java/org/ros2/rcljava/RCLJava.java"
"src/main/java/org/ros2/rcljava/Subscription.java"
"src/main/java/org/ros2/rcljava/Consumer.java"
)

add_jar("${PROJECT_NAME}_jar"
Expand All @@ -97,21 +95,50 @@ add_jar("${PROJECT_NAME}_jar"

call_for_each_rmw_implementation(target)

if(AMENT_ENABLE_TESTING)
set(_install_jar_dir "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}")
get_property(_jar_file TARGET "${PROJECT_NAME}_jar" PROPERTY "JAR_FILE")

install_jar("${PROJECT_NAME}_jar" "share/${PROJECT_NAME}/java")
ament_export_jars("share/${PROJECT_NAME}/java/${PROJECT_NAME}.jar")

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

ament_add_nose_test(rcljavatests test
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
set(${PROJECT_NAME}_test_sources
"src/test/java/org/ros2/rcljava/NodeTest.java"
"src/test/java/org/ros2/rcljava/PublisherTest.java"
"src/test/java/org/ros2/rcljava/RCLJavaTest.java"
"src/test/java/org/ros2/rcljava/SubscriptionTest.java"
)

set(${PROJECT_NAME}_testsuites
"org.ros2.rcljava.NodeTest"
"org.ros2.rcljava.PublisherTest"
"org.ros2.rcljava.RCLJavaTest"
"org.ros2.rcljava.SubscriptionTest"
)
endif()

if(NOT rosidl_generate_interfaces_SKIP_INSTALL)
set(_install_jar_dir "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}")
get_property(_jar_file TARGET "${PROJECT_NAME}_jar" PROPERTY "JAR_FILE")
set(_deps_library_paths "")
foreach(_dep_lib ${std_msgs_LIBRARIES})
get_filename_component(_dep_dir "${_dep_lib}" DIRECTORY)
list(APPEND _deps_library_paths ${_dep_dir})
endforeach()
list(APPEND _deps_library_paths ${CMAKE_CURRENT_BINARY_DIR})

foreach(testsuite ${${PROJECT_NAME}_testsuites})
add_junit_tests("${PROJECT_NAME}_tests_${testsuite}"
"${${PROJECT_NAME}_test_sources}"
TESTS
"${testsuite}"
INCLUDE_JARS
"${std_msgs_JARS}"
"${_jar_file}"
LIBRARY_PATHS
"${_deps_library_paths}"
)
endforeach()

install_jar("${PROJECT_NAME}_jar" "share/${PROJECT_NAME}/java")
ament_export_jars("share/${PROJECT_NAME}/java/${PROJECT_NAME}.jar")
endif()

ament_package()
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// Copyright 2016 Esteve Fernandez <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_ros2_rcljava_Node */

#ifndef _Included_org_ros2_rcljava_Node
#define _Included_org_ros2_rcljava_Node
#ifndef ORG_ROS2_RCLJAVA_NODE_H_
#define ORG_ROS2_RCLJAVA_NODE_H_
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -26,4 +40,4 @@ JNIEXPORT jlong JNICALL Java_org_ros2_rcljava_Node_nativeCreateSubscriptionHandl
#ifdef __cplusplus
}
#endif
#endif
#endif // ORG_ROS2_RCLJAVA_NODE_H_
43 changes: 43 additions & 0 deletions rcljava/include/org_ros2_rcljava_Publisher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2016 Esteve Fernandez <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_ros2_rcljava_Publisher */

#ifndef ORG_ROS2_RCLJAVA_PUBLISHER_H_
#define ORG_ROS2_RCLJAVA_PUBLISHER_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: org_ros2_rcljava_Publisher
* Method: nativePublish
* Signature: (JLjava/lang/Object;)
*/
JNIEXPORT void JNICALL Java_org_ros2_rcljava_Publisher_nativePublish
(JNIEnv *, jclass, jlong, jobject);

/*
* Class: org_ros2_rcljava_Node
* Method: nativeDispose
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_org_ros2_rcljava_Publisher_nativeDispose
(JNIEnv *, jclass, jlong, jlong);

#ifdef __cplusplus
}
#endif
#endif // ORG_ROS2_RCLJAVA_PUBLISHER_H_
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
// Copyright 2016 Esteve Fernandez <[email protected]>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class org_ros2_rcljava_RCLJava */

#ifndef _Included_org_ros2_rcljava_RCLJava
#define _Included_org_ros2_rcljava_RCLJava
#ifndef ORG_ROS2_RCLJAVA_RCLJAVA_H_
#define ORG_ROS2_RCLJAVA_RCLJAVA_H_
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -98,4 +112,4 @@ JNIEXPORT void JNICALL Java_org_ros2_rcljava_RCLJava_nativeShutdown
#ifdef __cplusplus
}
#endif
#endif
#endif // ORG_ROS2_RCLJAVA_RCLJAVA_H_
25 changes: 2 additions & 23 deletions rcljava/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

<buildtool_depend>ament_cmake</buildtool_depend>
<buildtool_depend>ament_cmake_export_jars</buildtool_depend>
<buildtool_depend>rcljava_common</buildtool_depend>

<buildtool_export_depend>rosidl_cmake</buildtool_export_depend>

<exec_depend>rmw_implementation</exec_depend>
Expand All @@ -21,32 +23,9 @@

<exec_depend>rcl</exec_depend>

<!--
<depend>rmw_implementation</depend>
-->
<!--
<depend>rcl</depend>
-->

<!--
<depend>rosidl_cmake</depend>
<depend>rosidl_parser</depend>

-->
<!--
<exec_depend>rosidl_default_runtime</exec_depend>

<depend>rmw_implementation</depend>
-->

<!--
<test_depend>ament_cmake_nose</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>std_msgs</test_depend>
<test_depend>rosidl_generator_java</test_depend>
<test_depend>rosidl_typesupport_opensplice_c</test_depend>
-->

<export>
<build_type>ament_cmake</build_type>
Expand Down
Loading