Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 from __future__ import print_function
00034 import sys
00035 import os
00036 import os.path
00037 import win_ros
00038 import argparse
00039 import wstool.wstool_cli
00040 from rosinstall.helpers import ROSInstallException
00041 from rosinstall.common import MultiProjectException
00042
00043 def parse_args():
00044 parser = argparse.ArgumentParser(description="\
00045 Prepares a win-ros workspace:\n\n\
00046 1. Prepares a multi-vcs workspace with wstool \n\
00047 2. Populates with pre-specified win-ros source sets if requested\n\
00048 3. Prepares a convenience setup.bat",
00049 epilog="See http://www.ros.org/wiki/win_python_build_tools for details.",
00050 formatter_class=argparse.RawTextHelpFormatter )
00051 group = parser.add_mutually_exclusive_group()
00052 group.add_argument('--sdk-stable', action='store_true',
00053 help='populate with the sdk stable sources [false]')
00054 group.add_argument('--sdk-unstable', action='store_true',
00055 help='populate with the sdk unstable sources [false]')
00056 group.add_argument('--comms-stable', action='store_true',
00057 help='populate with the comms stable sources [false]')
00058 group.add_argument('--comms-unstable', action='store_true',
00059 help='populate with the comms unstable sources [false]')
00060 parser.add_argument('path', type=str, default=".",
00061 help='base path for the workspace')
00062 return parser.parse_args()
00063
00064 def populate(base_path, rosinstall_file_uri):
00065 '''
00066 @param rosinstall_file_uri : the uri for the rosinstall file
00067 @param distro : whether it is win_ros.STABLE or win_ros.UNSTABLE
00068 '''
00069 wstool_arguments = ['wstool',
00070 'merge',
00071 rosinstall_file_uri,
00072 "--target-workspace=%s"%os.path.join(base_path, 'src')
00073 ]
00074 wstool.wstool_cli.wstool_main(wstool_arguments)
00075 wstool_arguments = ['wstool',
00076 'update',
00077 "--target-workspace=%s"%os.path.join(base_path, 'src')
00078 ]
00079 wstool.wstool_cli.wstool_main(wstool_arguments)
00080
00081 if __name__ == "__main__":
00082 args = parse_args()
00083 if os.path.isabs(args.path):
00084 base_path = args.path
00085 else:
00086 base_path = os.path.abspath(args.path)
00087 if not os.path.isdir(base_path):
00088 os.mkdir(base_path)
00089 os.mkdir(os.path.join(base_path, 'src'))
00090 wstool_arguments = ['wstool', 'init', os.path.join(base_path, 'src')]
00091 try:
00092 wstool.wstool_cli.wstool_main(wstool_arguments)
00093 except ROSInstallException as e:
00094 sys.stderr.write("ERROR in wstool: %s\n" % str(e))
00095 sys.exit(1)
00096 except MultiProjectException as e:
00097 sys.stderr.write("ERROR in config: %s\n" % str(e))
00098 sys.exit(1)
00099 text = win_ros.write_setup_bat(base_path)
00100 distro = win_ros.STABLE
00101 if args.sdk_stable:
00102 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/groovy-devel/msvc_groovy.rosinstall')
00103
00104 if args.sdk_unstable:
00105 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/groovy-devel/msvc_unstable.rosinstall')
00106 distro = win_ros.UNSTABLE
00107 if args.comms_stable:
00108
00109 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/groovy-devel/msvc_unstable_comms.rosinstall')
00110 if args.comms_unstable:
00111 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/groovy-devel/msvc_unstable_comms.rosinstall')
00112 distro = win_ros.UNSTABLE
00113 win_ros.write_toplevel_cmake(os.path.join(base_path, 'src'), distro)