From a78f957ad4cb54b7cc12c276c39ab0b9e5d0114b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 30 Nov 2021 00:49:57 -0500 Subject: [PATCH] =?UTF-8?q?[tools][building.py]=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=E7=A9=BA=E5=88=97=E8=A1=A8=E5=92=8C=E7=A9=BA?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/building.py | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/tools/building.py b/tools/building.py index e078c1626c..10641c11a9 100644 --- a/tools/building.py +++ b/tools/building.py @@ -616,6 +616,17 @@ def MergeGroup(src_group, group): else: 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): global Env if not GetDepend(depend): @@ -640,19 +651,29 @@ def DefineGroup(name, src, depend, **parameters): group['src'] = src if 'CCFLAGS' in group: - Env.AppendUnique(CCFLAGS = group['CCFLAGS']) + target = group['CCFLAGS'] + if len(target) > 0: + Env.AppendUnique(CCFLAGS = target) if 'CPPPATH' in group: - paths = [] - for item in group['CPPPATH']: - paths.append(os.path.abspath(item)) - group['CPPPATH'] = paths - Env.AppendUnique(CPPPATH = group['CPPPATH']) + target = group['CPPPATH'] + if _PretreatListParameters(target) == True: + paths = [] + for item in target: + paths.append(os.path.abspath(item)) + target = paths + Env.AppendUnique(CPPPATH = target) if 'CPPDEFINES' in group: - Env.AppendUnique(CPPDEFINES = group['CPPDEFINES']) + target = group['CPPDEFINES'] + if _PretreatListParameters(target) == True: + Env.AppendUnique(CPPDEFINES = target) if 'LINKFLAGS' in group: - Env.AppendUnique(LINKFLAGS = group['LINKFLAGS']) + target = group['LINKFLAGS'] + if len(target) > 0: + Env.AppendUnique(LINKFLAGS = target) 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: paths = [] for item in group['LOCAL_CPPPATH']: @@ -675,9 +696,13 @@ def DefineGroup(name, src, depend, **parameters): os.unlink(fn) if 'LIBS' in group: - Env.AppendUnique(LIBS = group['LIBS']) + target = group['LIBS'] + if _PretreatListParameters(target) == True: + Env.AppendUnique(LIBS = target) 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 if 'LIBRARY' in group: