Skip to content

Commit 1086f6c

Browse files
committed
[Tools] Fix the buildlib with LOCAL_* options group
1 parent e460034 commit 1086f6c

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

tools/building.py

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -497,44 +497,54 @@ def one_list(l):
497497
lst.append(item)
498498
return lst
499499

500-
objects = one_list(objects)
501-
502-
# remove source files with local flags setting
503-
for group in Projects:
504-
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
505-
for source in group['src']:
506-
for obj in objects:
507-
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
508-
objects.remove(obj)
509-
510-
# re-add the source files to the objects
511-
for group in Projects:
500+
# handle local group
501+
def local_group(group, objects):
512502
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
513503
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
514504
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
515505
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
516506

517507
for source in group['src']:
518-
objects += Env.Object(source, CCFLAGS = CCFLAGS,
519-
CPPPATH = CPPPATH,
520-
CPPDEFINES = CPPDEFINES)
508+
objects.append(Env.Object(source, CCFLAGS = CCFLAGS,
509+
CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES))
510+
511+
return True
512+
513+
return False
514+
515+
objects = one_list(objects)
521516

522517
program = None
523518
# check whether special buildlib option
524519
lib_name = GetOption('buildlib')
525520
if lib_name:
521+
objects = [] # remove all of objects
526522
# build library with special component
527523
for Group in Projects:
528524
if Group['name'] == lib_name:
529525
lib_name = GroupLibName(Group['name'], Env)
530-
objects = Env.Object(Group['src'])
526+
if not local_group(Group, objects):
527+
objects = Env.Object(Group['src'])
528+
531529
program = Env.Library(lib_name, objects)
532530

533531
# add library copy action
534532
Env.BuildLib(lib_name, program)
535533

536534
break
537535
else:
536+
# remove source files with local flags setting
537+
for group in Projects:
538+
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
539+
for source in group['src']:
540+
for obj in objects:
541+
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
542+
objects.remove(obj)
543+
544+
# re-add the source files to the objects
545+
for group in Projects:
546+
local_group(group, objects)
547+
538548
program = Env.Program(target, objects)
539549

540550
EndBuilding(target, program)

0 commit comments

Comments
 (0)