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 parser.add_argument('path', type=str, default=".",
00052 help='base path for the workspace')
00053 parser.add_argument('--track', action='store', default="",
00054 help='retrieve rosinstalls relevant to this track [groovy|hydro]')
00055 return parser.parse_args()
00056
00057 def populate(base_path, rosinstall_file_uri):
00058 '''
00059 @param rosinstall_file_uri : the uri for the rosinstall file
00060 @param distro : whether it is win_ros.STABLE or win_ros.UNSTABLE
00061 '''
00062 wstool_arguments = ['wstool',
00063 'merge',
00064 rosinstall_file_uri,
00065 "--target-workspace=%s"%os.path.join(base_path, 'src')
00066 ]
00067 wstool.wstool_cli.wstool_main(wstool_arguments)
00068 wstool_arguments = ['wstool',
00069 'update',
00070 "--target-workspace=%s"%os.path.join(base_path, 'src')
00071 ]
00072 wstool.wstool_cli.wstool_main(wstool_arguments)
00073
00074 if __name__ == "__main__":
00075 args = parse_args()
00076 if os.path.isabs(args.path):
00077 base_path = args.path
00078 else:
00079 base_path = os.path.abspath(args.path)
00080 if not os.path.isdir(base_path):
00081 os.mkdir(base_path)
00082 os.mkdir(os.path.join(base_path, 'src'))
00083 wstool_arguments = ['wstool', 'init', os.path.join(base_path, 'src')]
00084 try:
00085 wstool.wstool_cli.wstool_main(wstool_arguments)
00086 except ROSInstallException as e:
00087 sys.stderr.write("ERROR in wstool: %s\n" % str(e))
00088 sys.exit(1)
00089 except MultiProjectException as e:
00090 sys.stderr.write("ERROR in config: %s\n" % str(e))
00091 sys.exit(1)
00092 text = win_ros.write_setup_bat(base_path)
00093
00094 if args.track == "hydro":
00095 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/hydro-devel/msvc_hydro.rosinstall')
00096 toplevel_cmake_url = 'https://raw.github.com/ros/catkin/0.5.69/cmake/toplevel.cmake'
00097 elif args.track == "groovy":
00098 populate(base_path, 'https://raw.github.com/ros-windows/win_ros/groovy-devel/msvc_groovy.rosinstall')
00099 toplevel_cmake_url = 'https://raw.github.com/ros/catkin/groovy-devel/cmake/toplevel.cmake'
00100 else:
00101 toplevel_cmake_url = 'https://raw.github.com/ros/catkin/0.5.69/cmake/toplevel.cmake'
00102
00103 win_ros.write_toplevel_cmake(os.path.join(base_path, 'src'), toplevel_cmake_url)