[tools] Add `--add-rtconfig` args for scons when you want to add macro definitions build time.

This commit is contained in:
朱天龙 (Armink) 2023-04-05 22:34:26 +08:00 committed by guo
parent 6c093ad654
commit f458d63d5f
2 changed files with 18 additions and 0 deletions

View File

@ -319,6 +319,19 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
if rtconfig.PLATFORM in ['gcc'] and str(env['LINKFLAGS']).find('nano.specs') != -1:
env.AppendUnique(CPPDEFINES = ['_REENT_SMALL'])
add_rtconfig = GetOption('add_rtconfig')
if add_rtconfig:
add_rtconfig = add_rtconfig.split(',')
if isinstance(add_rtconfig, list):
for config in add_rtconfig:
if isinstance(config, str):
AddDepend(add_rtconfig)
env.Append(CFLAGS=' -D' + config, CXXFLAGS=' -D' + config, AFLAGS=' -D' + config)
else:
print('add_rtconfig arguements are illegal!')
else:
print('add_rtconfig arguements are illegal!')
if GetOption('genconfig'):
from genconf import genconfig
genconfig()
@ -1051,3 +1064,4 @@ def PackageSConscript(package):
from package import BuildPackage
return BuildPackage(package)

View File

@ -127,6 +127,10 @@ def AddOptions():
action = 'store_true',
default = False,
help = 'Don`t show pyconfig window')
AddOption('--add-rtconfig',
dest = 'add_rtconfig',
type = 'string',
help = 'Add macro definitions and scons depend at build time. It is similar to adding macro definitions in rtconfig.h')
if platform.system() != 'Windows':
AddOption('--menuconfig',
dest = 'menuconfig',