(env, target, script)
| 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') |
| 385 | lines = template.readlines() |
| 386 | |
| 387 | project = open(target, "w") |
| 388 | project_path = os.path.dirname(os.path.abspath(target)) |
| 389 | |
| 390 | line_index = 5 |
| 391 | # write group |
| 392 | for group in script: |
| 393 | lines.insert(line_index, 'Group (%s)\r\n' % group['name']) |
| 394 | line_index += 1 |
| 395 | |
| 396 | lines.insert(line_index, '\r\n') |
| 397 | line_index += 1 |
| 398 | |
| 399 | # write file |
| 400 | |
| 401 | ProjectFiles = [] |
| 402 | CPPPATH = [] |
| 403 | CPPDEFINES = env.get('CPPDEFINES', []) |
| 404 | LINKFLAGS = '' |
| 405 | CFLAGS = '' |
| 406 | |
| 407 | # number of groups |
| 408 | group_index = 1 |
| 409 | for group in script: |
| 410 | # print group['name'] |
| 411 | |
| 412 | # get each include path |
| 413 | if 'CPPPATH' in group and group['CPPPATH']: |
| 414 | if CPPPATH: |
| 415 | CPPPATH += group['CPPPATH'] |
| 416 | else: |
| 417 | CPPPATH += group['CPPPATH'] |
| 418 | |
| 419 | # get each group's link flags |
| 420 | if 'LINKFLAGS' in group and group['LINKFLAGS']: |
| 421 | if LINKFLAGS: |
| 422 | LINKFLAGS += ' ' + group['LINKFLAGS'] |
| 423 | else: |
| 424 | LINKFLAGS += group['LINKFLAGS'] |
| 425 | |
| 426 | # generate file items |
| 427 | for node in group['src']: |
| 428 | fn = node.rfile() |
| 429 | name = fn.name |
| 430 | path = os.path.dirname(fn.abspath) |
| 431 | basename = os.path.basename(path) |
| 432 | path = _make_path_relative(project_path, path) |
| 433 | path = os.path.join(path, name) |
| 434 | if ProjectFiles.count(name): |
| 435 | name = basename + '_' + name |
| 436 | ProjectFiles.append(name) |
| 437 | lines.insert(line_index, 'File %d,%d,<%s><%s>\r\n' |
| 438 | % (group_index, _get_filetype(name), path, name)) |
| 439 | line_index += 1 |
| 440 |
no test coverage detected