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 shutil
00038 import subprocess
00039 import win_ros
00040 import argparse
00041
00042 def parse_args():
00043 parser = argparse.ArgumentParser(description="\
00044 Runs cmake/nmake on winros sources using configuration in config.cmake:\n\n\
00045 1. Expects sources are in ./src \n\
00046 2. Expects a toplevel cmake file in ./src/CMakeList.txt\n\
00047 3. Expects configuration settings in ./config.cmake\n",
00048 epilog="See http://www.ros.org/wiki/win_python_build_tools for details.",
00049 formatter_class=argparse.RawTextHelpFormatter )
00050 parser.add_argument('-p', '--pre-clean', action='store_true', help='clean the build directory (not config.cmake) before recompiling [false]')
00051 group = parser.add_mutually_exclusive_group()
00052 group.add_argument('-c', '--cmake-only', action='store_true', help='do not compile, cmake configuration only [false]')
00053 group.add_argument('-i', '--install', action='store_true', help='build and install sdk [false]')
00054
00055
00056 return parser.parse_args()
00057
00058 if __name__ == "__main__":
00059 args = parse_args()
00060 ws_path = os.path.abspath(".")
00061 build_path = os.path.join(ws_path, 'build')
00062 devel_path = os.path.join(ws_path, 'devel')
00063 src_path = os.path.join(ws_path, 'src')
00064
00065
00066
00067 error_str = win_ros.is_invalid_workspace(src_path)
00068 if error_str:
00069 sys.exit(error_str)
00070
00071
00072
00073 if not os.path.isfile(os.path.join(ws_path, "config.cmake")):
00074 print("--- no build configuration found (./config.cmake), creating a default.")
00075 win_ros.write_cmake_files(ws_path)
00076 shutil.rmtree(build_path, ignore_errors=True)
00077 os.mkdir(build_path)
00078
00079
00080
00081 if args.pre_clean:
00082 print("--- cleaning current cmake and build temporaries (not the build configuration).")
00083 shutil.rmtree(build_path, ignore_errors=True)
00084 shutil.rmtree(devel_path, ignore_errors=True)
00085 if os.path.isfile(os.path.join(build_path, 'Makefile')):
00086 if args.cmake_only:
00087 win_ros.execute_cmake(src_path, build_path)
00088 elif args.install:
00089 win_ros.execute_nmake_install(build_path)
00090 else:
00091 win_ros.execute_nmake(build_path)
00092 else:
00093 win_ros.execute_cmake(src_path, build_path)
00094 if not args.cmake_only:
00095 if args.install:
00096 win_ros.execute_nmake_install(build_path)
00097 else:
00098 win_ros.execute_nmake(build_path)