winros_init_workspace.py
Go to the documentation of this file.
00001 # Software License Agreement (BSD License)
00002 #
00003 # Copyright (c) 2013, Yujin Robot, Inc.
00004 # All rights reserved.
00005 #
00006 # Redistribution and use in source and binary forms, with or without
00007 # modification, are permitted provided that the following conditions
00008 # are met:
00009 #
00010 #  * Redistributions of source code must retain the above copyright
00011 #    notice, this list of conditions and the following disclaimer.
00012 #  * Redistributions in binary form must reproduce the above
00013 #    copyright notice, this list of conditions and the following
00014 #    disclaimer in the documentation and/or other materials provided
00015 #    with the distribution.
00016 #  * Neither the name of Yujin Robot nor the names of its
00017 #    contributors may be used to endorse or promote products derived
00018 #    from this software without specific prior written permission.
00019 #
00020 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 # POSSIBILITY OF SUCH DAMAGE.
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)


win_python_build_tools
Author(s): Daniel Stonier
autogenerated on Wed Sep 16 2015 07:09:59