Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ build.ninja
install_manifest.txt
rules.ninja

# bazel output symlinks.
bazel-*

# out-of-source build top-level folders.
build/
_build/
Expand Down
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,22 @@ install:
brew update;
brew install gcc@7;
fi
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
sudo apt-get update -qq;
sudo apt-get install -qq unzip;
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;
sudo bash bazel-installer.sh;
fi
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
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;
sudo bash bazel-installer.sh;
fi

script:
- 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} ..
- make
- ctest -C ${BUILD_TYPE} --output-on-failure
- bazel test -c dbg --define google_benchmark.have_regex=posix --announce_rc --verbose_failures --test_output=errors --keep_going //test/...

after_success:
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Radoslav Yovchev <radoslav.tm@gmail.com>
Roman Lebedev <lebedev.ri@gmail.com>
Shuo Chen <chenshuo@chenshuo.com>
Steinar H. Gunderson <sgunderson@bigfoot.com>
Stripe, Inc.
Yixuan Qiu <yixuanq@gmail.com>
Yusuke Suzuki <utatane.tea@gmail.com>
Zbigniew Skowron <zbychs@gmail.com>
21 changes: 21 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
licenses(["notice"])

load("//bazel:have_regex.bzl", "have_regex_copts")

cc_library(
name = "benchmark",
srcs = glob([
"src/*.cc",
"src/*.h",
]),
hdrs = ["include/benchmark/benchmark.h"],
copts = have_regex_copts(),
strip_include_prefix = "include",
visibility = ["//visibility:public"],
)

cc_library(
name = "benchmark_internal_headers",
hdrs = glob(["src/*.h"]),
visibility = ["//test:__pkg__"],
)
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Ismael Jimenez Martinez <ismael.jimenez.martinez@gmail.com>
Jern-Kuan Leong <jernkuan@gmail.com>
JianXiong Zhou <zhoujianxiong2@gmail.com>
Joao Paulo Magalhaes <joaoppmagalhaes@gmail.com>
John Millikin <jmillikin@stripe.com>
Jussi Knuuttila <jussi.knuuttila@gmail.com>
Kai Wolf <kai.wolf@gmail.com>
Kishan Kumar <kumar.kishan@outlook.com>
Expand Down
9 changes: 9 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
workspace(name = "com_github_google_benchmark")

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per bazel, it may be worth changing this to http_archive: https://docs.bazel.build/versions/master/be/workspace.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this as git_repository, because the auto-generated tarballs created by GitHub don't have stable checksums. See tensorflow/tensorflow#12979 and bazelbuild/bazel#3737 for some examples of GitHub breaking builds by tweaking their tarball builder.

http_repository does work well for GitHub "release" tarballs uploaded by maintainers, such as the Protobuf releases. Googletest doesn't have any of those, though.

name = "com_google_googletest",
commit = "3f0cf6b62ad1eb50d8736538363d3580dd640c3e", # HEAD
remote = "https://github.com/google/googletest",
)
16 changes: 16 additions & 0 deletions bazel/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package(default_visibility = ["//:__subpackages__"])

config_setting(
name = "have_std_regex",
values = {"define": "google_benchmark.have_regex=std"},
)

config_setting(
name = "have_posix_regex",
values = {"define": "google_benchmark.have_regex=posix"},
)

config_setting(
name = "have_gnu_posix_regex",
values = {"define": "google_benchmark.have_regex=gnu_posix"},
)
7 changes: 7 additions & 0 deletions bazel/have_regex.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def have_regex_copts():
return select({
"//bazel:have_std_regex": ["-DHAVE_STD_REGEX"],
"//bazel:have_posix_regex": ["-DHAVE_POSIX_REGEX"],
"//bazel:have_gnu_posix_regex": ["-DHAVE_GNU_POSIX_REGEX"],
"//conditions:default": ["-DHAVE_STD_REGEX"],
})
47 changes: 47 additions & 0 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
load("//bazel:have_regex.bzl", "have_regex_copts")

NEEDS_GTEST_MAIN = [
"statistics_test.cc",
]

TEST_COPTS = [
"-pedantic",
"-pedantic-errors",
"-std=c++11",
] + have_regex_copts()

TEST_ARGS = ["--benchmark_min_time=0.01"]

cc_library(
name = "output_test_helper",
testonly = 1,
srcs = ["output_test_helper.cc"],
hdrs = ["output_test.h"],
copts = TEST_COPTS,
deps = [
"//:benchmark",
"//:benchmark_internal_headers",
],
)

[cc_test(
name = test_src[:-len(".cc")],
size = "small",
srcs = [test_src],
args = TEST_ARGS + ({
"user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
}).get(test_src, []),
copts = TEST_COPTS + ({
"cxx03_test.cc": ["-std=c++03"],
# Some of the issues with DoNotOptimize only occur when optimization is enabled
"donotoptimize_test.cc": ["-O3"],
}).get(test_src, []),
deps = [
":output_test_helper",
"//:benchmark",
"//:benchmark_internal_headers",
"@com_google_googletest//:gtest",
] + (
["@com_google_googletest//:gtest_main"] if (test_src in NEEDS_GTEST_MAIN) else []
),
) for test_src in glob(["*_test.cc"])]