2017-11-02 16:57:17 +08:00
|
|
|
import os
|
|
|
|
|
|
|
|
def genconfig() :
|
|
|
|
from SCons.Script import SCons
|
|
|
|
|
|
|
|
PreProcessor = SCons.cpp.PreProcessor()
|
|
|
|
|
|
|
|
try:
|
2018-11-10 18:29:08 +08:00
|
|
|
f = open('rtconfig.h', 'r')
|
2017-11-02 16:57:17 +08:00
|
|
|
contents = f.read()
|
|
|
|
f.close()
|
|
|
|
except :
|
|
|
|
print("Open rtconfig.h file failed.")
|
|
|
|
|
|
|
|
PreProcessor.process_contents(contents)
|
|
|
|
options = PreProcessor.cpp_namespace
|
|
|
|
|
|
|
|
try:
|
2018-11-10 18:29:08 +08:00
|
|
|
f = open('.config', 'w')
|
2017-11-02 16:57:17 +08:00
|
|
|
for (opt, value) in options.items():
|
|
|
|
if type(value) == type(1):
|
|
|
|
f.write("CONFIG_%s=%d\n" % (opt, value))
|
|
|
|
|
|
|
|
if type(value) == type('') and value == '':
|
|
|
|
f.write("CONFIG_%s=y\n" % opt)
|
|
|
|
elif type(value) == type('str'):
|
|
|
|
f.write("CONFIG_%s=%s\n" % (opt, value))
|
|
|
|
|
|
|
|
print("Generate .config done!")
|
|
|
|
f.close()
|
|
|
|
except:
|
|
|
|
print("Generate .config file failed.")
|