Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions cmds/cmd_menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@

import os
import platform
import re
from vars import Import, Export

# judge if it's CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER

def is_pkg_special_config(config_str):
''' judge if it's CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER'''

if type(config_str) == type('a'):
if config_str.startswith("PKG_") and (config_str.endswith('_PATH') or config_str.endswith('_VER')):
return True
return False


def mk_rtconfig(filename):
"""make rtconfig.h from .config."""

try:
config = file(filename)
config = open(filename, 'r')
except:
print 'open .config failed'
print('open config:%s failed' % filename)
return

rtconfig = file('rtconfig.h', 'w')
rtconfig = open('rtconfig.h', 'w')
rtconfig.write('#ifndef RT_CONFIG_H__\n')
rtconfig.write('#define RT_CONFIG_H__\n\n')

Expand All @@ -67,7 +68,6 @@ def mk_rtconfig(filename):
empty_line = 1
continue

#comment_line = line[1:]
if line.startswith('# CONFIG_'):
line = ' ' + line[9:]
else:
Expand All @@ -78,29 +78,18 @@ def mk_rtconfig(filename):
else:
empty_line = 0
setting = line.split('=')
if len(setting) == 2:
if len(setting) >= 2:
if setting[0].startswith('CONFIG_'):
setting[0] = setting[0][7:]

# remove CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER
if is_pkg_special_config(setting[0]):
continue

if setting[1] == 'y':
rtconfig.write('#define %s\n' % setting[0])
else:
rtconfig.write('#define %s %s\n' %
(setting[0], setting[1]))

elif len(setting) > 2:
alt_data = line[len(setting[0]) + 1:]

if setting[0].startswith('CONFIG_'):
setting[0] = setting[0][7:]

if is_pkg_special_config(setting[0]):
continue

rtconfig.write('#define %s %s\n' % (setting[0], alt_data))
rtconfig.write('#define %s %s\n' % (setting[0], re.findall(r"^.*?=(.*)$",line)[0]))

if os.path.isfile('rtconfig_project.h'):
rtconfig.write('#include "rtconfig_project.h"\n')
Expand Down