Skip to content

Commit 111cf38

Browse files
Merge ce54db3 into 6ecf8a8
2 parents 6ecf8a8 + ce54db3 commit 111cf38

File tree

9 files changed

+114
-0
lines changed

9 files changed

+114
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ build.ninja
4141
install_manifest.txt
4242
rules.ninja
4343

44+
# bazel output symlinks.
45+
bazel-*
46+
4447
# out-of-source build top-level folders.
4548
build/
4649
_build/

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,22 @@ install:
159159
brew update;
160160
brew install gcc@7;
161161
fi
162+
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
163+
sudo apt-get update -qq;
164+
sudo apt-get install -qq unzip;
165+
wget https://github.com/bazelbuild/bazel/releases/download/0.10.1/bazel-0.10.1-installer-linux-x86_64.sh --output-document bazel-installer.sh;
166+
sudo bash bazel-installer.sh;
167+
fi
168+
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
169+
curl -L -o bazel-installer.sh https://github.com/bazelbuild/bazel/releases/download/0.10.1/bazel-0.10.1-installer-darwin-x86_64.sh;
170+
sudo bash bazel-installer.sh;
171+
fi
162172

163173
script:
164174
- cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_FLAGS="${EXTRA_FLAGS}" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON -DBENCHMARK_BUILD_32_BITS=${BUILD_32_BITS} ..
165175
- make
166176
- ctest -C ${BUILD_TYPE} --output-on-failure
177+
- bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/...
167178

168179
after_success:
169180
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Radoslav Yovchev <radoslav.tm@gmail.com>
3838
Roman Lebedev <lebedev.ri@gmail.com>
3939
Shuo Chen <chenshuo@chenshuo.com>
4040
Steinar H. Gunderson <sgunderson@bigfoot.com>
41+
Stripe, Inc.
4142
Yixuan Qiu <yixuanq@gmail.com>
4243
Yusuke Suzuki <utatane.tea@gmail.com>
4344
Zbigniew Skowron <zbychs@gmail.com>

BUILD.bazel

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
licenses(["notice"])
2+
3+
load("//bazel:have_regex.bzl", "have_regex_copts")
4+
5+
cc_library(
6+
name = "benchmark",
7+
srcs = glob([
8+
"src/*.cc",
9+
"src/*.h",
10+
]),
11+
hdrs = ["include/benchmark/benchmark.h"],
12+
copts = have_regex_copts(),
13+
strip_include_prefix = "include",
14+
visibility = ["//visibility:public"],
15+
)
16+
17+
cc_library(
18+
name = "benchmark_internal_headers",
19+
hdrs = glob(["src/*.h"]),
20+
visibility = ["//test:__pkg__"],
21+
)

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
3838
Jern-Kuan Leong <jernkuan@gmail.com>
3939
JianXiong Zhou <zhoujianxiong2@gmail.com>
4040
Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com>
41+
John Millikin <jmillikin@stripe.com>
4142
Jussi Knuuttila <jussi.knuuttila@gmail.com>
4243
Kai Wolf <kai.wolf@gmail.com>
4344
Kishan Kumar <kumar.kishan@outlook.com>

WORKSPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
2+
3+
git_repository(
4+
name = "com_google_googletest",
5+
commit = "3f0cf6b62ad1eb50d8736538363d3580dd640c3e", # HEAD
6+
remote = "https://github.com/google/googletest",
7+
)

bazel/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package(default_visibility = ["//:__subpackages__"])
2+
3+
config_setting(
4+
name = "have_std_regex",
5+
values = {"define": "google_benchmark.have_regex=std"},
6+
)
7+
8+
config_setting(
9+
name = "have_posix_regex",
10+
values = {"define": "google_benchmark.have_regex=posix"},
11+
)
12+
13+
config_setting(
14+
name = "have_gnu_posix_regex",
15+
values = {"define": "google_benchmark.have_regex=gnu_posix"},
16+
)

bazel/have_regex.bzl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def have_regex_copts():
2+
return select({
3+
"//bazel:have_std_regex": ["-DHAVE_STD_REGEX"],
4+
"//bazel:have_posix_regex": ["-DHAVE_POSIX_REGEX"],
5+
"//bazel:have_gnu_posix_regex": ["-DHAVE_GNU_POSIX_REGEX"],
6+
"//conditions:default": ["-DHAVE_STD_REGEX"],
7+
})

test/BUILD

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
load("//bazel:have_regex.bzl", "have_regex_copts")
2+
3+
NEEDS_GTEST_MAIN = [
4+
"statistics_test.cc",
5+
]
6+
7+
TEST_COPTS = [
8+
"-pedantic",
9+
"-pedantic-errors",
10+
"-std=c++11",
11+
] + have_regex_copts()
12+
13+
TEST_ARGS = ["--benchmark_min_time=0.01"]
14+
15+
cc_library(
16+
name = "output_test_helper",
17+
testonly = 1,
18+
srcs = ["output_test_helper.cc"],
19+
hdrs = ["output_test.h"],
20+
copts = TEST_COPTS,
21+
deps = [
22+
"//:benchmark",
23+
"//:benchmark_internal_headers",
24+
],
25+
)
26+
27+
[cc_test(
28+
name = test_src[:-len(".cc")],
29+
size = "small",
30+
srcs = [test_src],
31+
args = TEST_ARGS + ({
32+
"user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
33+
}).get(test_src, []),
34+
copts = TEST_COPTS + ({
35+
"cxx03_test.cc": ["-std=c++03"],
36+
# Some of the issues with DoNotOptimize only occur when optimization is enabled
37+
"donotoptimize_test.cc": ["-O3"],
38+
}).get(test_src, []),
39+
deps = [
40+
":output_test_helper",
41+
"//:benchmark",
42+
"//:benchmark_internal_headers",
43+
"@com_google_googletest//:gtest",
44+
] + (
45+
["@com_google_googletest//:gtest_main"] if (test_src in NEEDS_GTEST_MAIN) else []
46+
),
47+
) for test_src in glob(["*_test.cc"])]

0 commit comments

Comments
 (0)