waf: allow setup of double precision for some cpp files

This commit is contained in:
Andrew Tridgell 2020-08-27 13:06:36 +10:00
parent 6a8680d31d
commit 24425b4155
2 changed files with 25 additions and 0 deletions

View File

@ -205,12 +205,34 @@ class ap_library_check_headers(Task.Task):
def keyword(self):
return 'Checking included headers'
def double_precision_check(tasks):
'''check for tasks marked as double precision'''
for t in tasks:
if len(t.inputs) == 1:
# get a list of tasks we need to change to be double precision
double_tasks = []
for library in t.env.DOUBLE_PRECISION_SOURCES.keys():
for s in t.env.DOUBLE_PRECISION_SOURCES[library]:
double_tasks.append([library, s])
src = str(t.inputs[0]).split('/')[-2:]
if src in double_tasks:
single_precision_option='-fsingle-precision-constant'
t.env.CXXFLAGS = t.env.CXXFLAGS[:]
if single_precision_option in t.env.CXXFLAGS:
t.env.CXXFLAGS.remove(single_precision_option)
t.env.CXXFLAGS.append("-DALLOW_DOUBLE_MATH_FUNCTIONS")
@feature('ap_library_object')
@after_method('process_source')
def ap_library_register_for_check(self):
if not hasattr(self, 'compiled_tasks'):
return
double_precision_check(self.compiled_tasks)
if not self.env.ENABLE_HEADER_CHECKS:
return
@ -221,3 +243,4 @@ def ap_library_register_for_check(self):
def configure(cfg):
cfg.env.AP_LIBRARIES_OBJECTS_KW = dict()
cfg.env.AP_LIB_EXTRA_SOURCES = dict()
cfg.env.DOUBLE_PRECISION_SOURCES = dict()

View File

@ -328,6 +328,8 @@ def configure(cfg):
cfg.end_msg('enabled')
cfg.recurse('libraries/AP_Scripting')
cfg.recurse('libraries/AP_GPS')
cfg.start_msg('Scripting runtime checks')
if cfg.options.scripting_checks:
cfg.end_msg('enabled')