2015-11-12 17:27:50 -04:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
"""
|
|
|
|
gbenchmark is a Waf tool for benchmark builds in Ardupilot
|
|
|
|
"""
|
|
|
|
|
|
|
|
from waflib import Build, Context, Task
|
2016-02-17 17:34:48 -04:00
|
|
|
from waflib.Configure import conf
|
2015-11-12 17:27:50 -04:00
|
|
|
from waflib.TaskGen import feature, before_method, after_method
|
2015-12-10 13:50:33 -04:00
|
|
|
from waflib.Errors import WafError
|
2015-11-12 17:27:50 -04:00
|
|
|
|
|
|
|
def configure(cfg):
|
|
|
|
env = cfg.env
|
|
|
|
env.HAS_GBENCHMARK = False
|
|
|
|
|
2015-12-11 14:21:11 -04:00
|
|
|
if env.TOOLCHAIN != 'native':
|
|
|
|
cfg.msg(
|
|
|
|
'Gbenchmark',
|
|
|
|
'cross-compilation currently not supported',
|
|
|
|
color='YELLOW',
|
|
|
|
)
|
|
|
|
return
|
|
|
|
|
2016-02-17 17:34:48 -04:00
|
|
|
cfg.load('cmake')
|
2015-11-12 17:27:50 -04:00
|
|
|
|
2016-02-17 17:34:48 -04:00
|
|
|
env.GBENCHMARK_PREFIX_REL = 'gbenchmark'
|
2015-11-12 17:27:50 -04:00
|
|
|
|
2015-12-10 13:59:00 -04:00
|
|
|
bldnode = cfg.bldnode.make_node(cfg.variant)
|
2016-02-17 17:34:48 -04:00
|
|
|
prefix_node = bldnode.make_node(env.GBENCHMARK_PREFIX_REL)
|
2015-11-12 17:27:50 -04:00
|
|
|
|
|
|
|
env.INCLUDES_GBENCHMARK = [prefix_node.make_node('include').abspath()]
|
|
|
|
env.LIBPATH_GBENCHMARK = [prefix_node.make_node('lib').abspath()]
|
2016-01-14 05:04:33 -04:00
|
|
|
env.LIB_GBENCHMARK = ['benchmark']
|
2015-11-12 17:27:50 -04:00
|
|
|
|
2016-02-05 12:09:21 -04:00
|
|
|
env.append_value('GIT_SUBMODULES', 'gbenchmark')
|
2015-11-12 17:27:50 -04:00
|
|
|
env.HAS_GBENCHMARK = True
|
|
|
|
|
2016-02-17 17:34:48 -04:00
|
|
|
@conf
|
|
|
|
def libbenchmark(bld):
|
|
|
|
prefix_node = bld.bldnode.make_node(bld.env.GBENCHMARK_PREFIX_REL)
|
|
|
|
|
|
|
|
gbenchmark_cmake = bld(
|
|
|
|
features='cmake_configure',
|
|
|
|
cmake_src='modules/gbenchmark',
|
|
|
|
cmake_bld='gbenchmark_build',
|
|
|
|
name='gbenchmark',
|
|
|
|
cmake_vars=dict(
|
|
|
|
CMAKE_BUILD_TYPE='Release',
|
|
|
|
CMAKE_INSTALL_PREFIX=prefix_node.abspath(),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
prefix_node = bld.bldnode.make_node(bld.env.GBENCHMARK_PREFIX_REL)
|
|
|
|
output_paths = (
|
|
|
|
'lib/libbenchmark.a',
|
|
|
|
'include/benchmark/benchmark.h',
|
|
|
|
'include/benchmark/macros.h',
|
|
|
|
'include/benchmark/benchmark_api.h',
|
|
|
|
'include/benchmark/reporter.h',
|
|
|
|
)
|
|
|
|
outputs = [prefix_node.make_node(path) for path in output_paths]
|
|
|
|
gbenchmark_cmake.cmake_build('install', target=outputs)
|
|
|
|
|
2015-11-12 17:27:50 -04:00
|
|
|
|
|
|
|
@feature('gbenchmark')
|
|
|
|
@before_method('process_use')
|
|
|
|
def append_gbenchmark_use(self):
|
|
|
|
self.use = self.to_list(getattr(self, 'use', []))
|
|
|
|
if 'GBENCHMARK' not in self.use:
|
|
|
|
self.use.append('GBENCHMARK')
|
|
|
|
|
|
|
|
@feature('gbenchmark')
|
|
|
|
@after_method('process_source')
|
2016-02-17 17:34:48 -04:00
|
|
|
def wait_for_gbenchmark_install(self):
|
|
|
|
gbenchmark_install = self.bld.get_tgen_by_name('gbenchmark_install')
|
|
|
|
gbenchmark_install.post()
|
2015-11-12 17:27:50 -04:00
|
|
|
|
|
|
|
for task in self.compiled_tasks:
|
2016-02-17 17:34:48 -04:00
|
|
|
task.set_run_after(gbenchmark_install.cmake_build_task)
|
|
|
|
task.dep_nodes.extend(gbenchmark_install.cmake_build_task.outputs)
|