Generate c_cpp_properties.json and build/compile_commands.json files
(env)
| 200 | return data |
| 201 | |
| 202 | def GenerateCFiles(env): |
| 203 | """ |
| 204 | Generate c_cpp_properties.json and build/compile_commands.json files |
| 205 | """ |
| 206 | if not os.path.exists('.vscode'): |
| 207 | os.mkdir('.vscode') |
| 208 | |
| 209 | with open('.vscode/c_cpp_properties.json', 'w') as vsc_file: |
| 210 | info = utils.ProjectInfo(env) |
| 211 | |
| 212 | cc = os.path.join(rtconfig.EXEC_PATH, rtconfig.CC) |
| 213 | cc = os.path.abspath(cc).replace('\\', '/') |
| 214 | |
| 215 | config_obj = {} |
| 216 | config_obj['name'] = 'Linux' |
| 217 | config_obj['defines'] = info['CPPDEFINES'] |
| 218 | |
| 219 | intelliSenseMode = 'linux-gcc-arm' |
| 220 | if cc.find('aarch64') != -1: |
| 221 | intelliSenseMode = 'linux-gcc-arm64' |
| 222 | elif cc.find('arm') != -1: |
| 223 | intelliSenseMode = 'linux-gcc-arm' |
| 224 | config_obj['intelliSenseMode'] = intelliSenseMode |
| 225 | config_obj['compilerPath'] = cc |
| 226 | config_obj['cStandard'] = "c99" |
| 227 | config_obj['cppStandard'] = "c++11" |
| 228 | config_obj['compileCommands'] ="build/compile_commands.json" |
| 229 | |
| 230 | # format "a/b," to a/b. remove first quotation mark("),and remove end (",) |
| 231 | includePath = [] |
| 232 | for i in info['CPPPATH']: |
| 233 | if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",': |
| 234 | includePath.append(_make_path_relative(os.getcwd(), i[1:len(i) - 2])) |
| 235 | else: |
| 236 | includePath.append(_make_path_relative(os.getcwd(), i)) |
| 237 | config_obj['includePath'] = includePath |
| 238 | |
| 239 | json_obj = {} |
| 240 | json_obj['configurations'] = [config_obj] |
| 241 | |
| 242 | vsc_file.write(json.dumps(json_obj, ensure_ascii=False, indent=4)) |
| 243 | |
| 244 | """ |
| 245 | Generate vscode.code-workspace files by build/compile_commands.json |
| 246 | """ |
| 247 | if os.path.exists('build/compile_commands.json'): |
| 248 | |
| 249 | command_json_to_workspace(env['RTT_ROOT'],'build/compile_commands.json') |
| 250 | return |
| 251 | """ |
| 252 | Generate vscode.code-workspace files |
| 253 | """ |
| 254 | with open('vscode.code-workspace', 'w') as vsc_space_file: |
| 255 | info = utils.ProjectInfo(env) |
| 256 | path_list = [] |
| 257 | for i in info['CPPPATH']: |
| 258 | if _make_path_relative(os.getcwd(), i)[0] == '.': |
| 259 | if i[0] == '\"' and i[len(i) - 2:len(i)] == '\",': |
no test coverage detected