1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
from devtools.yamaker import fileutil
from devtools.yamaker.modules import GLOBAL, Linkable, Py3Program, Recursable, Recurse, Switch
from devtools.yamaker.project import CMakeNinjaNixProject
def post_install(self):
fileutil.re_sub_dir(f"{self.dstdir}/test", "TEST_BENCHMARK_LIBRARY_HAS_NO_ASSERTIONS", "NDEBUG")
fileutil.copy([f"{self.srcdir}/tools/compare.py", f"{self.srcdir}/tools/gbench"], f"{self.dstdir}/tools/compare")
with self.yamakes["."] as benchmark:
idx = benchmark.CFLAGS.index("-DBENCHMARK_STATIC_DEFINE")
benchmark.CFLAGS[idx] = GLOBAL("-DBENCHMARK_STATIC_DEFINE")
benchmark.CFLAGS.remove("-DBENCHMARK_HAS_PTHREAD_AFFINITY")
benchmark.after(
"CFLAGS",
Switch(
OS_LINUX=Linkable(CFLAGS=["-DBENCHMARK_HAS_PTHREAD_AFFINITY"]),
),
)
benchmark.RECURSE.add("tools")
with self.yamakes["test"] as benchmark_gtest:
benchmark_gtest.module = "GTEST"
# fmt: off
benchmark_gtest.PEERDIR = [
peerdir
for peerdir in benchmark_gtest.PEERDIR
if not peerdir.startswith("contrib/restricted/googletest")
]
# fmt: on
self.yamakes["tools"] = Recurse()
with self.yamakes["tools"] as tools:
# google/benchmark contrib is built for wide range of platforms by devtools checks
# but python/numpy/scipy are supported only for subset of platforms.
# So here we have such complex condition to enable recurse only for supported platforms.
tools.after(
"RECURSE",
Switch(
{
"NOT USE_STL_SYSTEM": Switch(
{
"NOT USE_SYSTEM_PYTHON OR NOT _SYSTEM_PYTHON27": Switch(
{
"OS_LINIX OR OS_DARWIN OR OS_WINDOWS": Switch(
{"ARCH_X86_64 OR ARCH_ARM64": Recursable(RECURSE={"compare"})}
)
}
)
}
)
}
),
)
self.yamakes["tools/compare"] = self.module(
Py3Program,
LICENSE=[self.license],
PY_SRCS=[
"TOP_LEVEL",
"compare.py",
"gbench/__init__.py",
"gbench/report.py",
"gbench/util.py",
],
PY_MAIN="compare",
PEERDIR=["contrib/python/numpy", "contrib/python/scipy"],
NO_LINT=True,
)
benchmark = CMakeNinjaNixProject(
owners=["bulatman", "g:cpp-contrib"],
arcdir="contrib/restricted/google/benchmark",
license="Apache-2.0",
nixattr="gbenchmark",
addincl_global={".": {"./include"}},
disable_includes=[
"emscripten.h",
"kstat.h",
"qurt.h",
"perfmon/",
"sys/syspage.h",
],
flags=[
# Adds -DBENCHMARK_STATIC_DEFINE preprocessor flag which fixed MSVC build
"-DBUILD_SHARED_LIBS=OFF",
# Otherwise the tests do not use assert.
"-DCMAKE_BUILD_TYPE=Debug",
"-DBENCHMARK_HAS_CXX03_FLAG=NO",
"-DBENCHMARK_USE_BUNDLED_GTEST=OFF",
],
install_targets={
"benchmark",
"benchmark_gtest",
"benchmark_name_gtest",
"commandlineflags_gtest",
"statistics_gtest",
"string_util_gtest",
},
put={
"benchmark": ".",
"benchmark_gtest": "test",
},
put_with={
"benchmark_gtest": [
"benchmark_name_gtest",
"commandlineflags_gtest",
"statistics_gtest",
"string_util_gtest",
]
},
post_install=post_install,
)
|