[Tools] Fix the buildlib with LOCAL_* options group

This commit is contained in:
Bernard Xiong 2015-10-14 11:07:42 +08:00
parent e460034a97
commit 1086f6cfa0
1 changed files with 26 additions and 16 deletions

View File

@ -497,8 +497,42 @@ def DoBuilding(target, objects):
lst.append(item)
return lst
# handle local group
def local_group(group, objects):
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
for source in group['src']:
objects.append(Env.Object(source, CCFLAGS = CCFLAGS,
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES))
return True
return False
objects = one_list(objects)
program = None
# check whether special buildlib option
lib_name = GetOption('buildlib')
if lib_name:
objects = [] # remove all of objects
# build library with special component
for Group in Projects:
if Group['name'] == lib_name:
lib_name = GroupLibName(Group['name'], Env)
if not local_group(Group, objects):
objects = Env.Object(Group['src'])
program = Env.Library(lib_name, objects)
# add library copy action
Env.BuildLib(lib_name, program)
break
else:
# remove source files with local flags setting
for group in Projects:
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
@ -509,32 +543,8 @@ def DoBuilding(target, objects):
# re-add the source files to the objects
for group in Projects:
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
local_group(group, objects)
for source in group['src']:
objects += Env.Object(source, CCFLAGS = CCFLAGS,
CPPPATH = CPPPATH,
CPPDEFINES = CPPDEFINES)
program = None
# check whether special buildlib option
lib_name = GetOption('buildlib')
if lib_name:
# build library with special component
for Group in Projects:
if Group['name'] == lib_name:
lib_name = GroupLibName(Group['name'], Env)
objects = Env.Object(Group['src'])
program = Env.Library(lib_name, objects)
# add library copy action
Env.BuildLib(lib_name, program)
break
else:
program = Env.Program(target, objects)
EndBuilding(target, program)