Skip to content

Commit 900c2f7

Browse files
authored
Merge 39ffb95 into e4ccad7
2 parents e4ccad7 + 39ffb95 commit 900c2f7

File tree

3 files changed

+221
-1
lines changed

3 files changed

+221
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ rules.ninja
4545
build/
4646
_build/
4747

48-
# in-source dependancies
4948
/googletest/
5049

50+
# Bazel directories.
51+
bazel-*

BUILD

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
licenses(['notice'])
2+
package(default_visibility=['//visibility:public'])
3+
4+
benchmark_copts = [
5+
# Choose the regex backend by defining one of the macros below:
6+
# HAVE_GNU_POSIX_REGEX
7+
# HAVE_POSIX_REGEX
8+
# HAVE_STD_REGEX
9+
'-DHAVE_POSIX_REGEX',
10+
'-UNDEBUG',
11+
'-Wall',
12+
'-Wextra',
13+
'-Wfloat-equal',
14+
'-Wshadow',
15+
'-Wstrict-aliasing',
16+
'-Wzero-as-null-pointer-constant',
17+
'-fstrict-aliasing',
18+
'-pedantic',
19+
'-pedantic-errors',
20+
'-std=c++11',
21+
]
22+
23+
gtest_dep = '@com_github_google_googletest//:gtest'
24+
25+
cc_library(
26+
name = 'benchmark',
27+
srcs = [
28+
'src/arraysize.h',
29+
'src/benchmark.cc',
30+
'src/benchmark_api_internal.h',
31+
'src/benchmark_register.cc',
32+
'src/check.h',
33+
'src/colorprint.cc',
34+
'src/colorprint.h',
35+
'src/commandlineflags.cc',
36+
'src/commandlineflags.h',
37+
'src/complexity.cc',
38+
'src/complexity.h',
39+
'src/console_reporter.cc',
40+
'src/counter.cc',
41+
'src/counter.h',
42+
'src/csv_reporter.cc',
43+
'src/cycleclock.h',
44+
'src/internal_macros.h',
45+
'src/json_reporter.cc',
46+
'src/log.h',
47+
'src/mutex.h',
48+
'src/re.h',
49+
'src/reporter.cc',
50+
'src/sleep.cc',
51+
'src/sleep.h',
52+
'src/statistics.cc',
53+
'src/statistics.h',
54+
'src/string_util.cc',
55+
'src/string_util.h',
56+
'src/sysinfo.cc',
57+
'src/timers.cc',
58+
'src/timers.h',
59+
],
60+
hdrs = [
61+
'include/benchmark/benchmark.h',
62+
],
63+
includes = [
64+
'include',
65+
],
66+
copts = benchmark_copts,
67+
linkopts = [
68+
'-lm',
69+
],
70+
)
71+
72+
[cc_test(
73+
name = f,
74+
srcs = [
75+
'test/%s.cc' % f,
76+
],
77+
copts = benchmark_copts,
78+
deps = [
79+
':benchmark',
80+
gtest_dep,
81+
],
82+
testonly = 1,
83+
) for f in [
84+
'basic_test',
85+
'benchmark_test',
86+
'diagnostics_test',
87+
'donotoptimize_test',
88+
'filter_test',
89+
'fixture_test',
90+
'map_test',
91+
'multiple_ranges_test',
92+
'options_test',
93+
'register_benchmark_test',
94+
'skip_with_error_test',
95+
'templated_fixture_test',
96+
]
97+
]
98+
99+
[cc_test(
100+
name = f,
101+
srcs = [
102+
'test/%s.cc' % f,
103+
],
104+
copts = benchmark_copts,
105+
deps = [
106+
':output_test_helper',
107+
gtest_dep,
108+
],
109+
testonly = 1,
110+
) for f in [
111+
'complexity_test',
112+
'reporter_output_test',
113+
'user_counters_tabular_test',
114+
'user_counters_test',
115+
]
116+
]
117+
118+
cc_test(
119+
name = 'cxx03_test',
120+
srcs = [
121+
'test/cxx03_test.cc',
122+
],
123+
copts = [
124+
'-std=c++03',
125+
],
126+
deps = [
127+
':benchmark',
128+
gtest_dep,
129+
],
130+
testonly = 1,
131+
)
132+
133+
cc_library(
134+
name = 'output_test_helper',
135+
visibility = [
136+
'//visibility:__pkg__',
137+
],
138+
srcs = [
139+
'test/output_test_helper.cc',
140+
],
141+
hdrs = [
142+
'test/output_test.h',
143+
],
144+
strip_include_prefix = 'test',
145+
copts = benchmark_copts,
146+
deps = [
147+
':benchmark',
148+
],
149+
testonly = 1,
150+
)

WORKSPACE

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
new_git_repository(
2+
name = 'com_github_google_googletest',
3+
remote = 'https://github.com/google/googletest.git',
4+
tag = 'release-1.8.0',
5+
build_file_content = '''
6+
# This content is copied from
7+
# https://github.com/google/googletest/blob/master/BUILD.bazel
8+
# But because the filename is not BUILD, the git_repository() rule will
9+
# complain.
10+
package(default_visibility = ["//visibility:public"])
11+
12+
licenses(["notice"])
13+
14+
config_setting(
15+
name = "win",
16+
values = {"cpu": "x64_windows_msvc"},
17+
)
18+
19+
# Google Test including Google Mock
20+
cc_library(
21+
name = "gtest",
22+
srcs = glob(
23+
include = [
24+
"googletest/src/*.cc",
25+
"googletest/src/*.h",
26+
"googletest/include/gtest/**/*.h",
27+
"googlemock/src/*.cc",
28+
"googlemock/include/gmock/**/*.h",
29+
],
30+
exclude = [
31+
"googletest/src/gtest-all.cc",
32+
"googletest/src/gtest_main.cc",
33+
"googlemock/src/gmock-all.cc",
34+
"googlemock/src/gmock_main.cc",
35+
],
36+
),
37+
hdrs =glob([
38+
"googletest/include/gtest/*.h",
39+
"googlemock/include/gmock/*.h",
40+
]),
41+
copts = select(
42+
{
43+
":win": [],
44+
"//conditions:default": ["-pthread"],
45+
},
46+
),
47+
includes = [
48+
"googlemock",
49+
"googlemock/include",
50+
"googletest",
51+
"googletest/include",
52+
],
53+
linkopts = select({
54+
":win": [],
55+
"//conditions:default": [
56+
"-pthread",
57+
],
58+
}),
59+
)
60+
61+
cc_library(
62+
name = "gtest_main",
63+
srcs = [
64+
"googlemock/src/gmock_main.cc",
65+
],
66+
deps = ["//:gtest"],
67+
)
68+
''',
69+
)

0 commit comments

Comments
 (0)