CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/Tools/ardupilotwaf/gbenchmark.py
Views: 1798
1
# encoding: utf-8
2
3
"""
4
gbenchmark is a Waf tool for benchmark builds in Ardupilot
5
"""
6
7
from waflib import Build, Context, Task
8
from waflib.Configure import conf
9
from waflib.TaskGen import feature, before_method, after_method
10
from waflib.Errors import WafError
11
12
def configure(cfg):
13
env = cfg.env
14
env.HAS_GBENCHMARK = False
15
16
if env.TOOLCHAIN != 'native':
17
cfg.msg(
18
'Gbenchmark',
19
'cross-compilation currently not supported',
20
color='YELLOW',
21
)
22
return
23
24
cfg.load('cmake')
25
26
env.GBENCHMARK_PREFIX_REL = 'gbenchmark'
27
28
bldnode = cfg.bldnode.make_node(cfg.variant)
29
prefix_node = bldnode.make_node(env.GBENCHMARK_PREFIX_REL)
30
31
env.INCLUDES_GBENCHMARK = [prefix_node.make_node('include').abspath()]
32
env.LIBPATH_GBENCHMARK = [prefix_node.make_node('lib').abspath()]
33
env.LIB_GBENCHMARK = ['benchmark']
34
35
env.append_value('GIT_SUBMODULES', 'gbenchmark')
36
env.HAS_GBENCHMARK = True
37
38
@conf
39
def libbenchmark(bld):
40
prefix_node = bld.bldnode.make_node(bld.env.GBENCHMARK_PREFIX_REL)
41
42
gbenchmark = bld.cmake(
43
name='gbenchmark',
44
cmake_src='modules/gbenchmark',
45
cmake_bld='gbenchmark_build',
46
cmake_vars=dict(
47
CMAKE_BUILD_TYPE='Release',
48
CMAKE_INSTALL_PREFIX=prefix_node.abspath(),
49
BENCHMARK_ENABLE_GTEST_TESTS='OFF',
50
BENCHMARK_ENABLE_TESTING='OFF',
51
),
52
)
53
54
prefix_node = bld.bldnode.make_node(bld.env.GBENCHMARK_PREFIX_REL)
55
output_paths = (
56
'lib/libbenchmark.a',
57
'include/benchmark/benchmark.h',
58
)
59
outputs = [prefix_node.make_node(path) for path in output_paths]
60
gbenchmark.build('install', target=outputs)
61
62
@feature('gbenchmark')
63
@before_method('process_use')
64
def append_gbenchmark_use(self):
65
self.use = self.to_list(getattr(self, 'use', []))
66
if 'GBENCHMARK' not in self.use:
67
self.use.append('GBENCHMARK')
68
69
@feature('gbenchmark')
70
@after_method('process_source')
71
def wait_for_gbenchmark_install(self):
72
gbenchmark_install = self.bld.get_tgen_by_name('gbenchmark_install')
73
gbenchmark_install.post()
74
75
for task in self.compiled_tasks:
76
task.set_run_after(gbenchmark_install.cmake_build_task)
77
task.dep_nodes.extend(gbenchmark_install.cmake_build_task.outputs)
78
79