[Tools] Add LOCAL_* options for group definition
This commit is contained in:
parent
8b7d2fb5c1
commit
f5217d6a9c
|
@ -20,6 +20,8 @@
|
||||||
# Change Logs:
|
# Change Logs:
|
||||||
# Date Author Notes
|
# Date Author Notes
|
||||||
# 2015-01-20 Bernard Add copyright information
|
# 2015-01-20 Bernard Add copyright information
|
||||||
|
# 2015-07-25 Bernard Add LOCAL_CCFLAGS/LOCAL_CPPPATH/LOCAL_CPPDEFINES for
|
||||||
|
# group definition.
|
||||||
#
|
#
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
@ -112,6 +114,8 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
|
|
||||||
# add program path
|
# add program path
|
||||||
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||||
|
# add rtconfig.h path
|
||||||
|
env.Append(CPPPATH = [str(Dir('#').abspath)])
|
||||||
|
|
||||||
# add library build action
|
# add library build action
|
||||||
act = SCons.Action.Action(BuildLibInstallAction, 'Install compiled library... $TARGET')
|
act = SCons.Action.Action(BuildLibInstallAction, 'Install compiled library... $TARGET')
|
||||||
|
@ -186,7 +190,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
AddOption('--target',
|
AddOption('--target',
|
||||||
dest='target',
|
dest='target',
|
||||||
type='string',
|
type='string',
|
||||||
help='set target project: mdk/iar/vs/ua')
|
help='set target project: mdk/mdk4/iar/vs/ua')
|
||||||
|
|
||||||
#{target_name:(CROSS_TOOL, PLATFORM)}
|
#{target_name:(CROSS_TOOL, PLATFORM)}
|
||||||
tgt_dict = {'mdk':('keil', 'armcc'),
|
tgt_dict = {'mdk':('keil', 'armcc'),
|
||||||
|
@ -220,7 +224,7 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [
|
||||||
AddOption('--verbose',
|
AddOption('--verbose',
|
||||||
dest='verbose',
|
dest='verbose',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
default=False,
|
default=True,
|
||||||
help='print verbose information during build')
|
help='print verbose information during build')
|
||||||
|
|
||||||
if not GetOption('verbose'):
|
if not GetOption('verbose'):
|
||||||
|
@ -333,6 +337,24 @@ def MergeGroup(src_group, group):
|
||||||
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
src_group['CPPDEFINES'] = src_group['CPPDEFINES'] + group['CPPDEFINES']
|
||||||
else:
|
else:
|
||||||
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
src_group['CPPDEFINES'] = group['CPPDEFINES']
|
||||||
|
|
||||||
|
# for local CCFLAGS/CPPPATH/CPPDEFINES
|
||||||
|
if group.has_key('LOCAL_CCFLAGS'):
|
||||||
|
if src_group.has_key('LOCAL_CCFLAGS'):
|
||||||
|
src_group['LOCAL_CCFLAGS'] = src_group['LOCAL_CCFLAGS'] + group['LOCAL_CCFLAGS']
|
||||||
|
else:
|
||||||
|
src_group['LOCAL_CCFLAGS'] = group['LOCAL_CCFLAGS']
|
||||||
|
if group.has_key('LOCAL_CPPPATH'):
|
||||||
|
if src_group.has_key('LOCAL_CPPPATH'):
|
||||||
|
src_group['LOCAL_CPPPATH'] = src_group['LOCAL_CPPPATH'] + group['LOCAL_CPPPATH']
|
||||||
|
else:
|
||||||
|
src_group['LOCAL_CPPPATH'] = group['LOCAL_CPPPATH']
|
||||||
|
if group.has_key('LOCAL_CPPDEFINES'):
|
||||||
|
if src_group.has_key('LOCAL_CPPDEFINES'):
|
||||||
|
src_group['LOCAL_CPPDEFINES'] = src_group['LOCAL_CPPDEFINES'] + group['LOCAL_CPPDEFINES']
|
||||||
|
else:
|
||||||
|
src_group['LOCAL_CPPDEFINES'] = group['LOCAL_CPPDEFINES']
|
||||||
|
|
||||||
if group.has_key('LINKFLAGS'):
|
if group.has_key('LINKFLAGS'):
|
||||||
if src_group.has_key('LINKFLAGS'):
|
if src_group.has_key('LINKFLAGS'):
|
||||||
src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
|
src_group['LINKFLAGS'] = src_group['LINKFLAGS'] + group['LINKFLAGS']
|
||||||
|
@ -371,13 +393,13 @@ def DefineGroup(name, src, depend, **parameters):
|
||||||
group['src'] = src
|
group['src'] = src
|
||||||
|
|
||||||
if group.has_key('CCFLAGS'):
|
if group.has_key('CCFLAGS'):
|
||||||
Env.Append(CCFLAGS = group['CCFLAGS'])
|
Env.AppendUnique(CCFLAGS = group['CCFLAGS'])
|
||||||
if group.has_key('CPPPATH'):
|
if group.has_key('CPPPATH'):
|
||||||
Env.Append(CPPPATH = group['CPPPATH'])
|
Env.AppendUnique(CPPPATH = group['CPPPATH'])
|
||||||
if group.has_key('CPPDEFINES'):
|
if group.has_key('CPPDEFINES'):
|
||||||
Env.Append(CPPDEFINES = group['CPPDEFINES'])
|
Env.AppendUnique(CPPDEFINES = group['CPPDEFINES'])
|
||||||
if group.has_key('LINKFLAGS'):
|
if group.has_key('LINKFLAGS'):
|
||||||
Env.Append(LINKFLAGS = group['LINKFLAGS'])
|
Env.AppendUnique(LINKFLAGS = group['LINKFLAGS'])
|
||||||
|
|
||||||
# check whether to clean up library
|
# check whether to clean up library
|
||||||
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
if GetOption('cleanlib') and os.path.exists(os.path.join(group['path'], GroupLibFullName(name, Env))):
|
||||||
|
@ -394,13 +416,15 @@ def DefineGroup(name, src, depend, **parameters):
|
||||||
else : group['LIBPATH'] = [GetCurrentDir()]
|
else : group['LIBPATH'] = [GetCurrentDir()]
|
||||||
|
|
||||||
if group.has_key('LIBS'):
|
if group.has_key('LIBS'):
|
||||||
Env.Append(LIBS = group['LIBS'])
|
Env.AppendUnique(LIBS = group['LIBS'])
|
||||||
if group.has_key('LIBPATH'):
|
if group.has_key('LIBPATH'):
|
||||||
Env.Append(LIBPATH = group['LIBPATH'])
|
Env.AppendUnique(LIBPATH = group['LIBPATH'])
|
||||||
|
|
||||||
|
# check whether to build group library
|
||||||
if group.has_key('LIBRARY'):
|
if group.has_key('LIBRARY'):
|
||||||
objs = Env.Library(name, group['src'])
|
objs = Env.Library(name, group['src'])
|
||||||
else:
|
else:
|
||||||
|
# only add source
|
||||||
objs = group['src']
|
objs = group['src']
|
||||||
|
|
||||||
# merge group
|
# merge group
|
||||||
|
@ -456,6 +480,26 @@ def BuildLibInstallAction(target, source, env):
|
||||||
break
|
break
|
||||||
|
|
||||||
def DoBuilding(target, objects):
|
def DoBuilding(target, objects):
|
||||||
|
# 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'):
|
||||||
|
for source in group['src']:
|
||||||
|
for obj in objects:
|
||||||
|
if source.abspath == obj.abspath or (len(obj.sources) > 0 and source.abspath == obj.sources[0].abspath):
|
||||||
|
objects.remove(obj)
|
||||||
|
|
||||||
|
# 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', [''])
|
||||||
|
|
||||||
|
for source in group['src']:
|
||||||
|
objects += Env.Object(source, CCFLAGS = CCFLAGS,
|
||||||
|
CPPPATH = CPPPATH,
|
||||||
|
CPPDEFINES = CPPDEFINES)
|
||||||
|
|
||||||
program = None
|
program = None
|
||||||
# check whether special buildlib option
|
# check whether special buildlib option
|
||||||
lib_name = GetOption('buildlib')
|
lib_name = GetOption('buildlib')
|
||||||
|
@ -500,7 +544,6 @@ def EndBuilding(target, program = None):
|
||||||
else:
|
else:
|
||||||
print 'No template project file found.'
|
print 'No template project file found.'
|
||||||
|
|
||||||
|
|
||||||
if GetOption('target') == 'mdk4':
|
if GetOption('target') == 'mdk4':
|
||||||
from keil import MDK4Project
|
from keil import MDK4Project
|
||||||
MDK4Project('project.uvproj', Projects)
|
MDK4Project('project.uvproj', Projects)
|
||||||
|
|
Loading…
Reference in New Issue