MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / mk_rtconfig

Function mk_rtconfig

tools/env_utility.py:261–317  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

259
260
261def mk_rtconfig(filename):
262 try:
263 config = open(filename, 'r')
264 except:
265 print('open config:%s failed' % filename)
266 return
267
268 rtconfig = open('rtconfig.h', 'w')
269 rtconfig.write('#ifndef RT_CONFIG_H__\n')
270 rtconfig.write('#define RT_CONFIG_H__\n\n')
271
272 empty_line = 1
273
274 for line in config:
275 line = line.lstrip(' ').replace('\n', '').replace('\r', '')
276
277 if len(line) == 0:
278 continue
279
280 if line[0] == '#':
281 if len(line) == 1:
282 if empty_line:
283 continue
284
285 rtconfig.write('\n')
286 empty_line = 1
287 continue
288
289 if line.startswith('# CONFIG_'):
290 line = ' ' + line[9:]
291 else:
292 line = line[1:]
293 rtconfig.write('/*%s */\n' % line)
294
295 empty_line = 0
296 else:
297 empty_line = 0
298 setting = line.split('=')
299 if len(setting) >= 2:
300 if setting[0].startswith('CONFIG_'):
301 setting[0] = setting[0][7:]
302
303 # remove CONFIG_PKG_XX_PATH or CONFIG_PKG_XX_VER
304 if is_pkg_special_config(setting[0]):
305 continue
306
307 if setting[1] == 'y':
308 rtconfig.write('#define %s\n' % setting[0])
309 else:
310 rtconfig.write('#define %s %s\n' % (setting[0], re.findall(r"^.*?=(.*)$", line)[0]))
311
312 if os.path.isfile('rtconfig_project.h'):
313 rtconfig.write('#include "rtconfig_project.h"\n')
314
315 rtconfig.write('\n')
316 rtconfig.write('#endif\n')
317 rtconfig.close()
318

Callers 4

PrepareBuildingFunction · 0.90
menuconfigFunction · 0.85
guiconfigFunction · 0.85
defconfigFunction · 0.85

Calls 3

is_pkg_special_configFunction · 0.85
openFunction · 0.50
writeMethod · 0.45

Tested by

no test coverage detected