[Tools] Add genconfig command in scons.
This commit is contained in:
parent
b2057f506a
commit
f08d1f5034
|
@ -258,6 +258,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
and rtconfig.PLATFORM == 'gcc':
|
and rtconfig.PLATFORM == 'gcc':
|
||||||
AddDepend('RT_USING_MINILIBC')
|
AddDepend('RT_USING_MINILIBC')
|
||||||
|
|
||||||
|
AddOption('--genconfig',
|
||||||
|
dest = 'genconfig',
|
||||||
|
action = 'store_true',
|
||||||
|
default = False,
|
||||||
|
help = 'Generate .config from rtconfig.h')
|
||||||
|
if GetOption('genconfig'):
|
||||||
|
from genconf import genconfig
|
||||||
|
genconfig()
|
||||||
|
exit(0)
|
||||||
|
|
||||||
# add comstr option
|
# add comstr option
|
||||||
AddOption('--verbose',
|
AddOption('--verbose',
|
||||||
dest='verbose',
|
dest='verbose',
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
def genconfig() :
|
||||||
|
from SCons.Script import SCons
|
||||||
|
|
||||||
|
PreProcessor = SCons.cpp.PreProcessor()
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = file('rtconfig.h', 'r')
|
||||||
|
contents = f.read()
|
||||||
|
f.close()
|
||||||
|
except :
|
||||||
|
print("Open rtconfig.h file failed.")
|
||||||
|
|
||||||
|
PreProcessor.process_contents(contents)
|
||||||
|
options = PreProcessor.cpp_namespace
|
||||||
|
|
||||||
|
try:
|
||||||
|
f = file('.config', 'w')
|
||||||
|
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.")
|
Loading…
Reference in New Issue