36
36
37
37
from __future__ import print_function
38
38
import argparse
39
- # import os
39
+ import os
40
40
#import sys
41
41
#import traceback
42
42
#import genmsg
43
43
#import genmsg.command_line
44
44
45
- #from genmsg import MsgGenerationException
46
- #from . generate_initpy import write_modules
45
+ import rosjava_build_tools
46
+ import catkin_pkg . packages
47
47
from . import gradle_project
48
48
49
49
##############################################################################
52
52
53
53
54
54
def parse_arguments (argv ):
55
- '''
56
- The include path has a special format, e.g.
57
- -Ifoo_msgs:/mnt/zaphod/ros/rosjava/hydro/src/foo_msgs/msg;-Istd_msgs:/opt/ros/hydro/share/std_msgs/cmake/../msg
58
- '''
59
55
parser = argparse .ArgumentParser (description = 'Generate java code for a single ros message.' )
60
56
#parser.add_argument('-m', '--message', action='store', help='the message file')
61
57
parser .add_argument ('-p' , '--package' , action = 'store' , help = 'package to find the message file' )
62
58
parser .add_argument ('-o' , '--output-dir' , action = 'store' , help = 'output directory for the java code (e.g. build/foo_msgs)' )
63
59
parser .add_argument ('-c' , '--compile' , default = False , action = 'store_true' , help = 'switch to compile mode (default is generating mode)' )
64
60
parser .add_argument ('-v' , '--verbosity' , default = False , action = 'store_true' , help = 'enable verbosity in debugging (false)' )
61
+ # The include path has a special format, e.g.
62
+ # -Ifoo_msgs:/mnt/zaphod/ros/rosjava/hydro/src/foo_msgs/msg;-Istd_msgs:/opt/ros/hydro/share/std_msgs/cmake/../msg
65
63
#parser.add_argument('-I', '--include-path', action='append', help="include paths to the package and deps msg files")
66
64
#myargs = rospy.myargv(argv=sys.argv)
67
65
#return parser.parse_args(args=myargs[1:])
@@ -73,9 +71,41 @@ def parse_arguments(argv):
73
71
74
72
75
73
def main (argv ):
74
+ '''
75
+ Used as the builder for genjava on the fly as other message language interfaces
76
+ are built. There is a bit of smarts inside this to work out when msgs have
77
+ changed and so forth.
78
+ '''
76
79
args = parse_arguments (argv [1 :])
77
80
#print("genjava %s/%s" % (args.package, args.message))
78
81
if not args .compile :
79
82
gradle_project .create (args .package , args .output_dir )
80
83
else :
81
84
gradle_project .build (args .package , args .output_dir , args .verbosity )
85
+
86
+
87
+ def standalone_parse_arguments (argv ):
88
+ parser = argparse .ArgumentParser (description = 'Generate artifacts for any/all discoverable message packages.' )
89
+ parser .add_argument ('-p' , '--package' , action = 'store' , default = None , help = 'package to generate (if not specified, all will be built)' )
90
+ parser .add_argument ('-o' , '--output-dir' , action = 'store' , default = 'build' , help = 'output directory for the java code (e.g. build/foo_msgs)' )
91
+ parser .add_argument ('-v' , '--verbose' , default = False , action = 'store_true' , help = 'enable verbosity in debugging (false)' )
92
+ return parser .parse_args (argv )
93
+
94
+
95
+ def standalone_main (argv ):
96
+ '''
97
+ This guy is a brute force standalone message artifact generator. It parses
98
+ the environment looking for the package (or just all) you wish to
99
+ generate artifacts for.
100
+ '''
101
+ args = standalone_parse_arguments (argv [1 :])
102
+ #print("genjava %s/%s/%s" % (args.package, args.output_dir, args.verbose))
103
+
104
+ if args .package is not None :
105
+ sorted_package_tuples = rosjava_build_tools .catkin .index_message_package_dependencies_from_local_environment (package_name = args .package )
106
+ else :
107
+ sorted_package_tuples = rosjava_build_tools .catkin .index_message_package_dependencies_from_local_environment ()
108
+
109
+ print ("Generating message artifacts for: \n %s" % [p .name for (unused_relative_path , p ) in sorted_package_tuples ])
110
+ for unused_relative_path , p in sorted_package_tuples :
111
+ gradle_project .standalone_create_and_build (p .name , args .output_dir , args .verbose )
0 commit comments