Skip to content

Commit cfd101a

Browse files
committed
[Tools] Fix the buildlib with LOCAL_* options group
1 parent 1bebbec commit cfd101a

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

Diff for: tools/building.py

+32-17
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ def PrepareModuleBuilding(env, root_directory, bsp_directory):
267267
global Env
268268
global Rtt_Root
269269

270+
# patch for win32 spawn
271+
if env['PLATFORM'] == 'win32':
272+
win32_spawn = Win32Spawn()
273+
win32_spawn.env = env
274+
env['SPAWN'] = win32_spawn.spawn
275+
270276
Env = env
271277
Rtt_Root = root_directory
272278

@@ -491,44 +497,54 @@ def one_list(l):
491497
lst.append(item)
492498
return lst
493499

494-
objects = one_list(objects)
495-
496-
# remove source files with local flags setting
497-
for group in Projects:
498-
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
499-
for source in group['src']:
500-
for obj in objects:
501-
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
502-
objects.remove(obj)
503-
504-
# re-add the source files to the objects
505-
for group in Projects:
500+
# handle local group
501+
def local_group(group, objects):
506502
if group.has_key('LOCAL_CCFLAGS') or group.has_key('LOCAL_CPPPATH') or group.has_key('LOCAL_CPPDEFINES'):
507503
CCFLAGS = Env.get('CCFLAGS', '') + group.get('LOCAL_CCFLAGS', '')
508504
CPPPATH = Env.get('CPPPATH', ['']) + group.get('LOCAL_CPPPATH', [''])
509505
CPPDEFINES = Env.get('CPPDEFINES', ['']) + group.get('LOCAL_CPPDEFINES', [''])
510506

511507
for source in group['src']:
512-
objects += Env.Object(source, CCFLAGS = CCFLAGS,
513-
CPPPATH = CPPPATH,
514-
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)
515516

516517
program = None
517518
# check whether special buildlib option
518519
lib_name = GetOption('buildlib')
519520
if lib_name:
521+
objects = [] # remove all of objects
520522
# build library with special component
521523
for Group in Projects:
522524
if Group['name'] == lib_name:
523525
lib_name = GroupLibName(Group['name'], Env)
524-
objects = Env.Object(Group['src'])
526+
if not local_group(Group, objects):
527+
objects = Env.Object(Group['src'])
528+
525529
program = Env.Library(lib_name, objects)
526530

527531
# add library copy action
528532
Env.BuildLib(lib_name, program)
529533

530534
break
531535
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+
532548
program = Env.Program(target, objects)
533549

534550
EndBuilding(target, program)
@@ -557,7 +573,6 @@ def EndBuilding(target, program = None):
557573
else:
558574
print 'No template project file found.'
559575

560-
561576
if GetOption('target') == 'mdk4':
562577
from keil import MDK4Project
563578
MDK4Project('project.uvproj', Projects)

0 commit comments

Comments
 (0)