waf: allow hwdef.dat to override build optimization

This commit is contained in:
Andrew Tridgell 2019-02-14 23:07:12 +11:00
parent 77d4e1f796
commit 3c9646dfef
2 changed files with 13 additions and 2 deletions

View File

@ -406,7 +406,6 @@ class chibios(Board):
'-Werror=unused-but-set-variable', '-Werror=unused-but-set-variable',
'-Wno-missing-field-initializers', '-Wno-missing-field-initializers',
'-Wno-trigraphs', '-Wno-trigraphs',
'-Os',
'-fno-strict-aliasing', '-fno-strict-aliasing',
'-fomit-frame-pointer', '-fomit-frame-pointer',
'-falign-functions=16', '-falign-functions=16',
@ -435,7 +434,6 @@ class chibios(Board):
bldnode = cfg.bldnode.make_node(self.name) bldnode = cfg.bldnode.make_node(self.name)
env.BUILDROOT = bldnode.make_node('').abspath() env.BUILDROOT = bldnode.make_node('').abspath()
env.LINKFLAGS = cfg.env.CPU_FLAGS + [ env.LINKFLAGS = cfg.env.CPU_FLAGS + [
'-Os',
'-fomit-frame-pointer', '-fomit-frame-pointer',
'-falign-functions=16', '-falign-functions=16',
'-ffunction-sections', '-ffunction-sections',

View File

@ -233,6 +233,18 @@ def load_env_vars(env):
if env.ENABLE_ASSERTS: if env.ENABLE_ASSERTS:
env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes' env.CHIBIOS_BUILD_FLAGS += ' ENABLE_ASSERTS=yes'
def setup_optimization(env):
'''setup optimization flags for build'''
if env.DEBUG:
OPTIMIZE = "-Og"
elif env.OPTIMIZE:
OPTIMIZE = env.OPTIMIZE
else:
OPTIMIZE = "-Os"
env.CFLAGS += [ OPTIMIZE ]
env.CXXFLAGS += [ OPTIMIZE ]
env.CHIBIOS_BUILD_FLAGS += ' USE_COPT=%s' % OPTIMIZE
def configure(cfg): def configure(cfg):
cfg.find_program('make', var='MAKE') cfg.find_program('make', var='MAKE')
#cfg.objcopy = cfg.find_program('%s-%s'%(cfg.env.TOOLCHAIN,'objcopy'), var='OBJCOPY', mandatory=True) #cfg.objcopy = cfg.find_program('%s-%s'%(cfg.env.TOOLCHAIN,'objcopy'), var='OBJCOPY', mandatory=True)
@ -305,6 +317,7 @@ def configure(cfg):
load_env_vars(cfg.env) load_env_vars(cfg.env)
if env.HAL_WITH_UAVCAN: if env.HAL_WITH_UAVCAN:
setup_can_build(cfg) setup_can_build(cfg)
setup_optimization(cfg.env)
def pre_build(bld): def pre_build(bld):
'''pre-build hook to change dynamic sources''' '''pre-build hook to change dynamic sources'''