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
00034
00035
00036
00037 import sys
00038 import os
00039 import subprocess
00040 import shutil
00041 import cmake_var
00042 import glob
00043
00044
00045
00046
00047
00048 def execute_cmake(src_path, build_path):
00049 if not os.path.isdir(build_path):
00050 os.mkdir(build_path)
00051 ws_path = os.path.join(parent_directory(build_path))
00052 override_cmake_str = '-DCMAKE_USER_MAKE_RULES_OVERRIDE:STRING="' + override_filename() + '" '
00053 cache_cmake_str = '-C "' + os.path.join(ws_path, 'config.cmake') + '" '
00054 devel_prefix = '-DCATKIN_DEVEL_PREFIX=' + os.path.join(ws_path, 'devel') + ' '
00055 cmake_command = 'cmake -G "NMake Makefiles" ' + cache_cmake_str + override_cmake_str + devel_prefix + src_path
00056 print("\nExecuting cmake on the workspace source directory:\n")
00057 print(" %s\n" % cmake_command)
00058 os.chdir(build_path)
00059 proc = subprocess.Popen(cmake_command, shell=True)
00060 proc.wait()
00061
00062 def execute_nmake(build_path):
00063 if not os.path.isdir(build_path):
00064 execute_cmake(src_path, build_path)
00065 if not os.path.isfile(os.path.join(build_path, 'CMakeCache.txt')):
00066 execute_cmake(src_path, build_path)
00067 os.chdir(build_path)
00068 print("\nExecuting nmake in the root build directory\n")
00069 proc = subprocess.Popen('nmake', shell=True)
00070 proc.wait()
00071
00072 def execute_nmake_install(build_path):
00073 if not os.path.isdir(build_path):
00074 execute_cmake(src_path, build_path)
00075 if not os.path.isfile(os.path.join(build_path, 'CMakeCache.txt')):
00076 execute_cmake(src_path, build_path)
00077 os.chdir(build_path)
00078 print("\nExecuting nmake in the root build directory and install\n")
00079 proc = subprocess.Popen('nmake install', shell=True)
00080 returncode = proc.wait()
00081 if returncode == 0:
00082 copy_debuginfo(build_path)
00083
00084 def override_filename():
00085 return os.path.join(os.path.dirname(__file__), 'cmake', 'MsvcOverrides.cmake')
00086
00087 def parent_directory(path):
00088 return os.path.abspath(os.path.join(path, os.pardir))
00089
00090 def copy_debuginfo(build_path):
00091 ws_path = os.path.join(parent_directory(build_path))
00092 pdb_path = os.path.join(ws_path, 'devel', 'bin', '*.pdb')
00093 install_root = cmake_var.get_value(os.path.join(ws_path, 'config.cmake'), 'INSTALL_ROOT')
00094 install_path = os.path.join(install_root, 'bin')
00095 pdb_files = glob.glob(pdb_path)
00096 print("Install the debug info files...")
00097 for i in pdb_files:
00098 dst_name = os.path.join(install_path, os.path.basename(i))
00099 if os.path.isfile(dst_name) == True:
00100 print("-- Up-to-date: " + dst_name)
00101 else:
00102 print("-- Installing: " + dst_name)
00103 shutil.copy(i, dst_name)
00104