(env, target, script)
| 346 | print("Timeout reached or too many empty lines, exiting log monitoring thread.") |
| 347 | break |
| 348 | def MDK5Project(env, target, script): |
| 349 | |
| 350 | if os.path.isfile('template.uvprojx') is False: |
| 351 | print ('Warning: The template project file [template.uvprojx] not found!') |
| 352 | return |
| 353 | |
| 354 | template_tree = etree.parse('template.uvprojx') |
| 355 | |
| 356 | MDK45Project(env, template_tree, target, script) |
| 357 | |
| 358 | # remove project.uvopt file |
| 359 | project_uvopt = os.path.abspath(target).replace('uvprojx', 'uvoptx') |
| 360 | if os.path.isfile(project_uvopt): |
| 361 | os.unlink(project_uvopt) |
| 362 | # copy uvopt file |
| 363 | if os.path.exists('template.uvoptx'): |
| 364 | import shutil |
| 365 | shutil.copy2('template.uvoptx', '{}.uvoptx'.format(os.path.splitext(target)[0])) |
| 366 | # build with UV4.exe |
| 367 | |
| 368 | if shutil.which('UV4.exe') is not None: |
| 369 | target_name = template_tree.find('Targets/Target/TargetName') |
| 370 | print('target_name:', target_name.text) |
| 371 | log_file_path = 'keil.log' |
| 372 | if os.path.exists(log_file_path): |
| 373 | os.remove(log_file_path) |
| 374 | log_thread = threading.Thread(target=monitor_log_file, args=(log_file_path,)) |
| 375 | log_thread.start() |
| 376 | cmd = 'UV4.exe -b project.uvprojx -q -j0 -t '+ target_name.text +' -o '+log_file_path |
| 377 | print('Start to build keil project') |
| 378 | print(cmd) |
| 379 | os.system(cmd) |
| 380 | else: |
| 381 | print('UV4.exe is not available, please check your keil installation') |
| 382 | |
| 383 | def MDK2Project(env, target, script): |
| 384 | template = open(os.path.join(os.path.dirname(__file__), 'template.Uv2'), 'r') |
no test coverage detected