diff options
| author | bernard <[email protected]> | 2017-11-02 16:57:17 +0800 |
|---|---|---|
| committer | bernard <[email protected]> | 2017-11-02 16:57:17 +0800 |
| commit | f08d1f503408b9eab9ce440828639915b7db7520 (patch) | |
| tree | 2b60d7a158c68b2b53bf5cdb780985e13fc42f3c /tools/genconf.py | |
| parent | b2057f506a09e2adef81fc77efd697d16ae14bec (diff) | |
[Tools] Add genconfig command in scons.
Diffstat (limited to 'tools/genconf.py')
| -rw-r--r-- | tools/genconf.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/genconf.py b/tools/genconf.py new file mode 100644 index 0000000000..de8681e1f8 --- /dev/null +++ b/tools/genconf.py @@ -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.") |
