Skip to content

Commit

Permalink
Merge pull request #131 from BernardXiong/target_fn
Browse files Browse the repository at this point in the history
Add TARGET_FILE for config header file output
  • Loading branch information
BernardXiong authored Jun 19, 2020
2 parents 58e5e76 + 0d7796f commit c4c9c7d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmds/cmd_menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,34 @@ def is_pkg_special_config(config_str):
return True
return False

def get_target_file(filename):
try:
config = open(filename, "r")
except:
print('open config:%s failed' % filename)
return None

for line in config:
line = line.lstrip(' ').replace('\n', '').replace('\r', '')

if len(line) == 0: continue

if line[0] == '#':
continue
else:
setting = line.split('=')
if len(setting) >= 2:
if setting[0].startswith('CONFIG_TARGET_FILE'):
target_fn = re.findall(r"^.*?=(.*)$",line)[0]
if target_fn.startswith('"'):
target_fn = target_fn.replace('"', '')

if target_fn == '':
return None
else:
return target_fn

return 'rtconfig.h'

def mk_rtconfig(filename):
try:
Expand All @@ -49,6 +77,10 @@ def mk_rtconfig(filename):
print('open config:%s failed' % filename)
return

target_fn = get_target_file(filename)
if target_fn == None:
return

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

0 comments on commit c4c9c7d

Please sign in to comment.