summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2017-01-31 13:22:56 +0000
committerBernard Xiong <[email protected]>2017-01-31 13:22:56 +0000
commita7c4a23c671e746c3a3e85aa905352f70a022d6f (patch)
treec396989f596c328d23c6a0208f0c7a32d4228478 /tools
parent033d254c4da3b074acf6160a9d02e790a8fa9449 (diff)
[tools] add --menuconfig option for scons
Diffstat (limited to 'tools')
-rw-r--r--tools/building.py10
-rw-r--r--tools/menuconfig.py51
2 files changed, 61 insertions, 0 deletions
diff --git a/tools/building.py b/tools/building.py
index 1eca1eaf39..204fd5037f 100644
--- a/tools/building.py
+++ b/tools/building.py
@@ -276,6 +276,16 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
LINKCOMSTR = 'LINK $TARGET'
)
+ AddOption('--menuconfig',
+ dest='menuconfig',
+ action='store_true',
+ default=False,
+ help='do the system configuration')
+
+ if GetOption('menuconfig'):
+ from menuconfig import config
+ config()
+
# we need to seperate the variant_dir for BSPs and the kernels. BSPs could
# have their own components etc. If they point to the same folder, SCons
# would find the wrong source code to compile.
diff --git a/tools/menuconfig.py b/tools/menuconfig.py
new file mode 100644
index 0000000000..ccc4c99e9b
--- /dev/null
+++ b/tools/menuconfig.py
@@ -0,0 +1,51 @@
+import os
+
+# make rtconfig.h from .config
+
+def mk_rtconfig(filename):
+ try:
+ config = file(filename)
+ except:
+ print 'open .config failed'
+ return
+
+ rtconfig = file('rtconfig.h', 'w')
+ rtconfig.write('#ifndef RT_CONFIG_H__\n')
+ rtconfig.write('#define RT_CONFIG_H__\n\n')
+
+ empty_line = 1
+
+ for line in config:
+ line = line.lstrip(' ').replace('\n', '').replace('\r', '')
+
+ if len(line) == 0: continue
+
+ if line[0] == '#':
+ if len(line) == 1:
+ if empty_line:
+ continue
+
+ rtconfig.write('\n')
+ empty_line = 1
+ continue
+
+ rtconfig.write('/*%s */\n' % line[1:])
+ empty_line = 0
+ else:
+ empty_line = 0
+ setting = line.split('=')
+ if len(setting) >= 2:
+ if setting[0].startswith('CONFIG_'):
+ setting[0] = setting[0][7:]
+
+ if setting[1] == 'y':
+ rtconfig.write('#define %s\n' % setting[0])
+ else:
+ rtconfig.write('#define %s %s\n' % (setting[0], setting[1]))
+
+ rtconfig.write('#endif\n')
+ rtconfig.close()
+
+def config():
+ mk_rtconfig('.config')
+