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 urllib2
00040
00041
00042
00043
00044
00045
00046 STABLE = 0
00047 UNSTABLE = 1
00048
00049 toplevel_cmake_url = {
00050 UNSTABLE : 'https://raw.github.com/ros-windows/catkin/groovy-devel/cmake/toplevel.cmake',
00051 STABLE : 'https://raw.github.com/ros-windows/catkin/groovy-devel/cmake/toplevel.cmake',
00052
00053 }
00054
00055
00056
00057
00058
00059 def generate_setup_bat_text():
00060
00061 text = """
00062 REM This is a file auto-generated to assist in a usable win-ros
00063 REM command line environment.
00064 """
00065 home_drive = os.environ['HOMEDRIVE']
00066 program_files = home_drive + r'\Program Files'
00067 program_files_x86 = home_drive + r'\Program Files (x86)'
00068 windows_sdk_env = program_files + r'\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd';
00069 visual_studio_ten_env = program_files + r'\Microsoft Visual Studio 10.0\VC\vcvarsall.bat';
00070 visual_studio_ten_env_x86 = program_files_x86 + r'\Microsoft Visual Studio 10.0\VC\vcvarsall.bat';
00071 wordpad_path = program_files + r'\Windows NT\Accessories\wordpad.exe';
00072 wordpad_path_x86 = program_files_x86 + r'\Windows NT\Accessories\wordpad.exe';
00073 notepp_path = program_files + r'\Notepad++\notepad++.exe';
00074 notepp_path_x86 = program_files_x86 + r'\Notepad++\notepad++.exe';
00075
00076 text += "\n"
00077 text += "@REM Utility variables\n"
00078 if os.path.isfile(wordpad_path):
00079 text += '@doskey wordpad="'+wordpad_path+'" $1\n'
00080 else:
00081 text += '@doskey wordpad="'+wordpad_path_x86+'" $1\n'
00082 if os.path.isfile(notepp_path):
00083 text += '@doskey notepp="'+notepp_path+'" $1\n'
00084 elif os.path.isfile(notepp_path_x86):
00085 text += '@doskey notepp="'+notepp_path_x86+'" $1\n'
00086 else:
00087 text += '@REM doskey notepp="'+notepp_path+'" $1\n'
00088 text += "\n"
00089 if os.path.isfile(windows_sdk_env):
00090 text += "@REM Environment settings for Windows SDK\n"
00091 text += '@call "' + windows_sdk_env + '" /x86 /Release\n'
00092 text += "@REM The sdk is the default generator for winros,\n"
00093 text += "@REM To use visual studio, uncomment one of the following.\n"
00094 text += '@REM "' + visual_studio_ten_env + '" x86\n'
00095 text += '@REM "' + visual_studio_ten_env_x86 + '" x86\n'
00096 elif os.path.isfile(visual_studio_ten_env):
00097 text += "@REM Environment settings for Visual Studio\n"
00098 text += '@call "' + visual_studio_ten_env + '" x86\n'
00099 text += '@REM call "' + windows_sdk_env + '" /x86 /Release\n'
00100 elif os.path.isfile(visual_studio_ten_env_x86):
00101 text += "@REM Environment settings for Visual Studio\n"
00102 text += '@call "' + visual_studio_ten_env_x86 + '" x86\n'
00103 text += '@REM call "' + windows_sdk_env + '" /x86 /Release\n'
00104 else:
00105 text += "@REM Could not find windows sdk or visual studio, please\n"
00106 text += "@REM install and configure by hand [Windows SDK/Visual Studio]\n"
00107 text += '@REM call "' + windows_sdk_env + '" /x86 /Release\n'
00108 text += '@REM "' + visual_studio_ten_env + '" x86\n'
00109 text += '@REM "' + visual_studio_ten_env_x86 + '" x86\n'
00110 text += '@REM Colours are a god awful ugly canary yellow or vomit green\n'
00111 text += '@color 7\n'
00112 text += "\n"
00113 return text
00114
00115
00116
00117
00118
00119
00120 def write_setup_bat(base_path):
00121 text = generate_setup_bat_text()
00122 setup_path = os.path.join(base_path, 'setup.bat')
00123 with open(setup_path, 'w') as f:
00124 f.write(text)
00125
00126
00127 def write_toplevel_cmake(base_path, distro = STABLE):
00128
00129 u = urllib2.urlopen( toplevel_cmake_url[distro] )
00130 local_file = open(os.path.join(base_path, 'CMakeLists.txt'), 'w')
00131 local_file.write(u.read())
00132 local_file.close()
00133
00134
00135 def is_invalid_workspace(src_path):
00136 '''
00137 Checks for source directory and source CMakeLists.txt.
00138
00139 @return Error string if not valid, otherwise None
00140 '''
00141 error_str = None
00142 if not os.path.isdir(src_path):
00143 error_str = "[no %s]"% src_path
00144 if not os.path.isfile(os.path.join(src_path, 'CMakeLists.txt')):
00145
00146 error_str = "[no %s/CMakeLists.txt]"% src_path
00147 if error_str:
00148 return "+++ invalid workspace %s. Create a source workspace with 'winros_init_workspace'."%error_str
00149 return None