waf: px4: define dynamic environment

We get the flags used by PX4Firmware build system so that we can use foreign
headers properly. Also, we add some defines used by PX4.
This commit is contained in:
Gustavo Jose de Sousa 2016-03-03 15:32:03 -03:00 committed by Lucas De Marchi
parent 95848488e7
commit 79d9bf2f8a

View File

@ -5,13 +5,45 @@
Waf tool for PX4 build
"""
from waflib.TaskGen import before_method, feature
import os
_dynamic_env_data = {}
def _load_dynamic_env_data(bld):
bldnode = bld.bldnode.make_node('modules/PX4Firmware')
for name in ('cxx_flags', 'include_dirs', 'definitions'):
_dynamic_env_data[name] = bldnode.find_node(name).read().split(';')
_dynamic_env_data['DEFINES'] = [
'NUTTX_GIT_VERSION="%s"' % bld.git_submodule_head_hash('PX4NuttX')[:8],
'PX4_GIT_VERSION="%s"' % bld.git_submodule_head_hash('PX4Firmware')[:8],
]
@feature('px4_ap_stlib', 'px4_ap_program')
@before_method('process_source')
def px4_dynamic_env(self):
# The generated files from configuration possibly don't exist if it's just
# a list command (TODO: figure out a better way to address that).
if self.bld.cmd == 'list':
return
if not _dynamic_env_data:
_load_dynamic_env_data(self.bld)
self.env.append_value('INCLUDES', _dynamic_env_data['include_dirs'])
self.env.prepend_value('CXXFLAGS', _dynamic_env_data['cxx_flags'])
self.env.prepend_value('CXXFLAGS', _dynamic_env_data['definitions'])
self.env.append_value('DEFINES', _dynamic_env_data['DEFINES'])
def configure(cfg):
cfg.load('cmake')
env = cfg.env
env.AP_PROGRAM_FEATURES += ['px4_ap_program']
env.AP_STLIB_FEATURES += ['px4_ap_stlib']
def srcpath(path):
return cfg.srcnode.make_node(path).abspath()