Skip to content
This repository was archived by the owner on Jan 14, 2023. It is now read-only.

Commit eadc0fc

Browse files
committed
first steps.
1 parent 9032aad commit eadc0fc

File tree

8 files changed

+192
-19
lines changed

8 files changed

+192
-19
lines changed

Diff for: .project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>genjava</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.python.pydev.PyDevBuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.python.pydev.pythonNature</nature>
16+
</natures>
17+
</projectDescription>

Diff for: .pydevproject

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<?eclipse-pydev version="1.0"?><pydev_project>
3+
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
4+
<path>/${PROJECT_DIR_NAME}/src</path>
5+
</pydev_pathproperty>
6+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
7+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
8+
</pydev_project>

Diff for: cmake/genjava-extras.cmake.em

+40-18
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,24 @@ set(GENJAVA_BIN_DIR "${GENJAVA_DIR}/../../../@(CATKIN_PACKAGE_BIN_DESTINATION)")
99
set(GENMSG_JAVA_BIN ${GENJAVA_BIN_DIR}/genmsg_java.py)
1010
set(GENSRV_JAVA_BIN ${GENJAVA_BIN_DIR}/gensrv_java.py)
1111

12+
# genmsg usually uses this variable to configure the install location. we typically pick
13+
# it up from the environment configured by rosjava_build_tools.
14+
#set(genjava_INSTALL_DIR "maven/org/ros/rosjava_messages")
15+
set(ROS_MAVEN_DEPLOYMENT_REPOSITORY $ENV{ROS_MAVEN_DEPLOYMENT_REPOSITORY})
16+
if(NOT ROS_MAVEN_DEPLOYMENT_REPOSITORY)
17+
set(ROS_MAVEN_DEPLOYMENT_REPOSITORY "${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_MAVEN_DESTINATION}")
18+
endif()
19+
1220
# Generate .msg->.h for py
1321
# The generated .h files should be added ALL_GEN_OUTPUT_FILES_py
22+
#
23+
# Example arguments:
24+
#
25+
# ARG_PKG : foo_msgs
26+
# ARG_MSG : /mnt/zaphod/ros/rosjava/hydro/src/foo_msgs/msg/Foo.msg
27+
# ARG_IFLAGS : -Ifoo_msgs:/mnt/zaphod/ros/rosjava/hydro/src/foo_msgs/msg;-Istd_msgs:/opt/ros/hydro/share/std_msgs/cmake/../msg
28+
# ARG_MSG_DEPS : ???
29+
# ARG_GEN_OUTPUT_DIR : /mnt/zaphod/ros/rosjava/hydro/devel/${genjava_INSTALL_DIR}/foo_msgs
1430
macro(_generate_msg_java ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_DIR)
1531

1632
message(STATUS "GEN_MSG_JAVA..........._generate_msg_java")
@@ -19,26 +35,32 @@ macro(_generate_msg_java ARG_PKG ARG_MSG ARG_IFLAGS ARG_MSG_DEPS ARG_GEN_OUTPUT_
1935
message(STATUS " ARG_IFLAGS...........${ARG_IFLAGS}")
2036
message(STATUS " ARG_MSG_DEPS.........${ARG_MSG_DEPS}")
2137
message(STATUS " ARG_GEN_OUTPUT_DIR...${ARG_GEN_OUTPUT_DIR}")
38+
message(STATUS "GEN_MSG_JAVA...........done")
39+
message(STATUS "CMAKE_CURRENT_BINARY_DIR.......${CMAKE_CURRENT_BINARY_DIR}")
2240

2341
#Append msg to output dir
24-
# set(GEN_OUTPUT_DIR "${ARG_GEN_OUTPUT_DIR}/msg")
25-
# file(MAKE_DIRECTORY ${GEN_OUTPUT_DIR})
42+
#set(GEN_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
43+
#file(MAKE_DIRECTORY ${GEN_OUTPUT_DIR})
2644
#Create input and output filenames
27-
# get_filename_component(MSG_SHORT_NAME ${ARG_MSG} NAME_WE)
28-
#
29-
# set(MSG_GENERATED_NAME _${MSG_SHORT_NAME}.py)
30-
# set(GEN_OUTPUT_FILE ${GEN_OUTPUT_DIR}/${MSG_GENERATED_NAME})
31-
#
32-
# add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
33-
# DEPENDS ${GENMSG_PY_BIN} ${ARG_MSG} ${ARG_MSG_DEPS}
34-
# COMMAND ${CATKIN_ENV} ${PYTHON_EXECUTABLE} ${GENMSG_PY_BIN} ${ARG_MSG}
35-
# ${ARG_IFLAGS}
36-
# -p ${ARG_PKG}
37-
# -o ${GEN_OUTPUT_DIR}
38-
# COMMENT "Generating Python from MSG ${ARG_PKG}/${MSG_SHORT_NAME}"
39-
# )
40-
#
41-
# list(APPEND ALL_GEN_OUTPUT_FILES_py ${GEN_OUTPUT_FILE})
45+
get_filename_component(MSG_SHORT_NAME ${ARG_MSG} NAME_WE)
46+
47+
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/gradle)
48+
49+
#set(MSG_GENERATED_NAME ${MSG_SHORT_NAME}.java)
50+
#set(GEN_OUTPUT_FILE ${GEN_OUTPUT_DIR}/${MSG_GENERATED_NAME})
51+
#message(STATUS "GEN_OUTPUT_FILE..........${GEN_OUTPUT_FILE}")
52+
#add_custom_command(OUTPUT ${GEN_OUTPUT_FILE}
53+
# DEPENDS ${GENMSG_JAVA_BIN} ${ARG_MSG} ${ARG_MSG_DEPS}
54+
# COMMAND ${CATKIN_ENV} cmake
55+
# -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}
56+
# -m ${ARG_MSG}
57+
# ${ARG_IFLAGS}
58+
# -p ${ARG_PKG}
59+
# -o ${GEN_OUTPUT_DIR}
60+
# COMMENT "Generating Java code from MSG ${ARG_PKG}/${MSG_SHORT_NAME}"
61+
#)
62+
63+
#list(APPEND ALL_GEN_OUTPUT_FILES_java ${GEN_OUTPUT_FILE})
4264

4365
endmacro()
4466

@@ -71,7 +93,7 @@ endmacro()
7193

7294
macro(_generate_module_java ARG_PKG ARG_GEN_OUTPUT_DIR ARG_GENERATED_FILES)
7395

74-
message(STATUS "GEN_MODULE_PY..........._generate_module_py")
96+
message(STATUS "GEN_MODULE_JAVA..........._generate_module_java")
7597
# generate empty __init__ to make parent folder of msg/srv a python module
7698
if(NOT EXISTS ${ARG_GEN_OUTPUT_DIR}/__init__.py)
7799
file(WRITE ${ARG_GEN_OUTPUT_DIR}/__init__.py "")

Diff for: scripts/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
catkin_install_python(
2-
PROGRAMS genmsg_java.py gensrv_java.py
2+
PROGRAMS genjava.py gensrv_java.py
33
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

Diff for: scripts/genjava.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
3+
"""
4+
ROS message source code generation for Java
5+
6+
Converts ROS .msg files in a package into Java source code implementations.
7+
"""
8+
import os
9+
import sys
10+
11+
#import genjava.generator
12+
import genjava.genjava_main
13+
14+
if __name__ == "__main__":
15+
genjava.genjava_main.genmain(sys.argv, 'genmsg_java.py') #, genpy.generator.MsgGenerator())
16+

Diff for: scripts/genmsg_java.py

Whitespace-only changes.

Diff for: src/genjava/genjava_main.py

+110
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Software License Agreement (BSD License)
2+
#
3+
# Copyright (c) 2014, Daniel Stonier.
4+
# All rights reserved.
5+
#
6+
# Redistribution and use in source and binary forms, with or without
7+
# modification, are permitted provided that the following conditions
8+
# are met:
9+
#
10+
# * Redistributions of source code must retain the above copyright
11+
# notice, this list of conditions and the following disclaimer.
12+
# * Redistributions in binary form must reproduce the above
13+
# copyright notice, this list of conditions and the following
14+
# disclaimer in the documentation and/or other materials provided
15+
# with the distribution.
16+
# * Neither the name of Willow Garage, Inc. nor the names of its
17+
# contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23+
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24+
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25+
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26+
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29+
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30+
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31+
# POSSIBILITY OF SUCH DAMAGE.
32+
33+
##############################################################################
34+
# Imports
35+
##############################################################################
36+
37+
from __future__ import print_function
38+
import argparse
39+
import os
40+
#import sys
41+
#import traceback
42+
#import genmsg
43+
import genmsg.command_line
44+
45+
#from genmsg import MsgGenerationException
46+
#from . generate_initpy import write_modules
47+
48+
##############################################################################
49+
# Methods
50+
##############################################################################
51+
52+
53+
def parse_arguments():
54+
'''
55+
The include path has a special format, e.g.
56+
-Ifoo_msgs:/mnt/zaphod/ros/rosjava/hydro/src/foo_msgs/msg;-Istd_msgs:/opt/ros/hydro/share/std_msgs/cmake/../msg
57+
'''
58+
parser = argparse.ArgumentParser(description='Generate java code for a single ros message.')
59+
parser.add_argument('-m', '--message', action='store', help='the message file')
60+
parser.add_argument('-p', '--package', action='store', help='package to find the message file')
61+
parser.add_argument('-o', '--output-dir', action='store', help='output directory for the java code (e.g. build/foo_msgs)')
62+
parser.add_argument('-I', '--include-path', action='append', help="include paths to the package and deps msg files")
63+
#myargs = rospy.myargv(argv=sys.argv)
64+
#return parser.parse_args(args=myargs[1:])
65+
return parser.parse_args()
66+
67+
##############################################################################
68+
# Main
69+
##############################################################################
70+
71+
def genmain(argv, progname): # , gen):
72+
args = parse_arguments()
73+
print("genjava %s/%s" % (args.package, args.message))
74+
print(" output dir..........%s" % args.output_dir)
75+
search_path = genmsg.command_line.includepath_to_dict(args.include_path)
76+
print(" search path.......%s" % search_path)
77+
gradle_project_dir = os.path.join(args.output_dir, 'gradle')
78+
os.mkdir(gradle_project_dir)
79+
80+
# try:
81+
# if options.initpy:
82+
# if options.outdir:
83+
# retcode = write_modules(options.outdir)
84+
# else:
85+
# parser.error("Missing args")
86+
# else:
87+
# if len(args) < 2:
88+
# parser.error("please specify args")
89+
# if not os.path.exists(options.outdir):
90+
# # This script can be run multiple times in parallel. We
91+
# # don't mind if the makedirs call fails because somebody
92+
# # else snuck in and created the directory before us.
93+
# try:
94+
# os.makedirs(options.outdir)
95+
# except OSError as e:
96+
# if not os.path.exists(options.outdir):
97+
# raise
98+
# search_path = genmsg.command_line.includepath_to_dict(options.includepath)
99+
# retcode = gen.generate_messages(options.package, args[1:], options.outdir, search_path)
100+
# except genmsg.InvalidMsgSpec as e:
101+
# print("ERROR: ", e, file=sys.stderr)
102+
# retcode = 1
103+
# except MsgGenerationException as e:
104+
# print("ERROR: ", e, file=sys.stderr)
105+
# retcode = 2
106+
# except Exception as e:
107+
# traceback.print_exc()
108+
# print("ERROR: ",e)
109+
# retcode = 3
110+
# sys.exit(retcode or 0)

Diff for: src/genjava/genjava_main.pyc

1.67 KB
Binary file not shown.

0 commit comments

Comments
 (0)