3636
3737from __future__ import print_function
3838import argparse
39- # import os
39+ import os
4040#import sys
4141#import traceback
4242#import genmsg
4343#import genmsg.command_line
4444
45- #from genmsg import MsgGenerationException
46- #from . generate_initpy import write_modules
45+ import rosjava_build_tools
46+ import catkin_pkg . packages
4747from . import gradle_project
4848
4949##############################################################################
5252
5353
5454def 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- '''
5955 parser = argparse .ArgumentParser (description = 'Generate java code for a single ros message.' )
6056 #parser.add_argument('-m', '--message', action='store', help='the message file')
6157 parser .add_argument ('-p' , '--package' , action = 'store' , help = 'package to find the message file' )
6258 parser .add_argument ('-o' , '--output-dir' , action = 'store' , help = 'output directory for the java code (e.g. build/foo_msgs)' )
6359 parser .add_argument ('-c' , '--compile' , default = False , action = 'store_true' , help = 'switch to compile mode (default is generating mode)' )
6460 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
6563 #parser.add_argument('-I', '--include-path', action='append', help="include paths to the package and deps msg files")
6664 #myargs = rospy.myargv(argv=sys.argv)
6765 #return parser.parse_args(args=myargs[1:])
@@ -73,9 +71,41 @@ def parse_arguments(argv):
7371
7472
7573def 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+ '''
7679 args = parse_arguments (argv [1 :])
7780 #print("genjava %s/%s" % (args.package, args.message))
7881 if not args .compile :
7982 gradle_project .create (args .package , args .output_dir )
8083 else :
8184 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