[tools][building.py] 修复加入空列表和空字符串的问题

This commit is contained in:
Meco Man 2021-11-30 00:49:57 -05:00
parent 9c78680f36
commit a78f957ad4
1 changed files with 36 additions and 11 deletions

View File

@ -616,6 +616,17 @@ def MergeGroup(src_group, group):
else: else:
src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS'] src_group['LOCAL_ASFLAGS'] = group['LOCAL_ASFLAGS']
def _PretreatListParameters(target_list):
while '' in target_list: # remove null strings
target_list.remove('')
while ' ' in target_list: # remove ' '
target_list.remove(' ')
if(len(target_list) == 0):
return False # ignore this list, don't add this list to the parameter
return True # permit to add this list to the parameter
def DefineGroup(name, src, depend, **parameters): def DefineGroup(name, src, depend, **parameters):
global Env global Env
if not GetDepend(depend): if not GetDepend(depend):
@ -640,19 +651,29 @@ def DefineGroup(name, src, depend, **parameters):
group['src'] = src group['src'] = src
if 'CCFLAGS' in group: if 'CCFLAGS' in group:
Env.AppendUnique(CCFLAGS = group['CCFLAGS']) target = group['CCFLAGS']
if len(target) > 0:
Env.AppendUnique(CCFLAGS = target)
if 'CPPPATH' in group: if 'CPPPATH' in group:
paths = [] target = group['CPPPATH']
for item in group['CPPPATH']: if _PretreatListParameters(target) == True:
paths.append(os.path.abspath(item)) paths = []
group['CPPPATH'] = paths for item in target:
Env.AppendUnique(CPPPATH = group['CPPPATH']) paths.append(os.path.abspath(item))
target = paths
Env.AppendUnique(CPPPATH = target)
if 'CPPDEFINES' in group: if 'CPPDEFINES' in group:
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES']) target = group['CPPDEFINES']
if _PretreatListParameters(target) == True:
Env.AppendUnique(CPPDEFINES = target)
if 'LINKFLAGS' in group: if 'LINKFLAGS' in group:
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS']) target = group['LINKFLAGS']
if len(target) > 0:
Env.AppendUnique(LINKFLAGS = target)
if 'ASFLAGS' in group: if 'ASFLAGS' in group:
Env.AppendUnique(ASFLAGS = group['ASFLAGS']) target = group['ASFLAGS']
if len(target) > 0:
Env.AppendUnique(ASFLAGS = target)
if 'LOCAL_CPPPATH' in group: if 'LOCAL_CPPPATH' in group:
paths = [] paths = []
for item in group['LOCAL_CPPPATH']: for item in group['LOCAL_CPPPATH']:
@ -675,9 +696,13 @@ def DefineGroup(name, src, depend, **parameters):
os.unlink(fn) os.unlink(fn)
if 'LIBS' in group: if 'LIBS' in group:
Env.AppendUnique(LIBS = group['LIBS']) target = group['LIBS']
if _PretreatListParameters(target) == True:
Env.AppendUnique(LIBS = target)
if 'LIBPATH' in group: if 'LIBPATH' in group:
Env.AppendUnique(LIBPATH = group['LIBPATH']) target = group['LIBPATH']
if _PretreatListParameters(target) == True:
Env.AppendUnique(LIBPATH = target)
# check whether to build group library # check whether to build group library
if 'LIBRARY' in group: if 'LIBRARY' in group: