()
| 457 | |
| 458 | |
| 459 | def genconfig(): |
| 460 | from SCons.Script import SCons |
| 461 | |
| 462 | PreProcessor = SCons.cpp.PreProcessor() |
| 463 | |
| 464 | try: |
| 465 | f = open('rtconfig.h', 'r') |
| 466 | contents = f.read() |
| 467 | f.close() |
| 468 | except: |
| 469 | print("Open rtconfig.h file failed.") |
| 470 | |
| 471 | PreProcessor.process_contents(contents) |
| 472 | options = PreProcessor.cpp_namespace |
| 473 | |
| 474 | try: |
| 475 | f = open('.config', 'w') |
| 476 | for opt, value in options.items(): |
| 477 | if type(value) == type(1): |
| 478 | f.write("CONFIG_%s=%d\n" % (opt, value)) |
| 479 | |
| 480 | if type(value) == type('') and value == '': |
| 481 | f.write("CONFIG_%s=y\n" % opt) |
| 482 | elif type(value) == type('str'): |
| 483 | f.write("CONFIG_%s=%s\n" % (opt, value)) |
| 484 | |
| 485 | print("Generate .config done!") |
| 486 | f.close() |
| 487 | except: |
| 488 | print("Generate .config file failed.") |
no test coverage detected