Skip to content
Closed
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ rules.ninja
build/
_build/

# in-source dependancies
/googletest/

# Bazel directories.
bazel-*
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,18 @@ install:
brew update;
brew install gcc@7;
fi
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
wget https://github.com/bazelbuild/bazel/releases/download/0.8.1/bazel-0.8.1-installer-linux-x86_64.sh --output-document bazel-installer.sh && sudo bash bazel-installer.sh;
fi
- if [ "${TRAVIS_OS_NAME}" == "osx" ]; then
brew install bazel;
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 //... --test_output=errors

after_success:
- if [ "${BUILD_TYPE}" == "Coverage" -a "${TRAVIS_OS_NAME}" == "linux" ]; then
Expand Down
150 changes: 150 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
licenses(['notice'])
package(default_visibility=['//visibility:public'])

BENCHMARK_COPTS = [
# Choose the regex backend by defining one of the macros below:
# HAVE_GNU_POSIX_REGEX
# HAVE_POSIX_REGEX
# HAVE_STD_REGEX
'-DHAVE_POSIX_REGEX',
'-UNDEBUG',
'-Wall',
'-Wextra',
'-Wfloat-equal',
'-Wshadow',
'-Wstrict-aliasing',
'-Wzero-as-null-pointer-constant',
'-fstrict-aliasing',
'-pedantic',
'-pedantic-errors',
'-std=c++11',
]


GTEST_DEP = '@com_github_google_googletest//:gtest'

cc_library(
name = 'benchmark',
srcs = [
'src/arraysize.h',
'src/benchmark.cc',
'src/benchmark_api_internal.h',
'src/benchmark_register.cc',
'src/check.h',
'src/colorprint.cc',
'src/colorprint.h',
'src/commandlineflags.cc',
'src/commandlineflags.h',
'src/complexity.cc',
'src/complexity.h',
'src/console_reporter.cc',
'src/counter.cc',
'src/counter.h',
'src/csv_reporter.cc',
'src/cycleclock.h',
'src/internal_macros.h',
'src/json_reporter.cc',
'src/log.h',
'src/mutex.h',
'src/re.h',
'src/reporter.cc',
'src/sleep.cc',
'src/sleep.h',
'src/statistics.cc',
'src/statistics.h',
'src/string_util.cc',
'src/string_util.h',
'src/sysinfo.cc',
'src/timers.cc',
'src/timers.h',
],
hdrs = [
'include/benchmark/benchmark.h',
],
includes = [
'include',
],
copts = BENCHMARK_COPTS,
linkopts = [
'-lm',
'-pthread',
],
)

[cc_test(
name = f,
srcs = [
'test/%s.cc' % f,
],
copts = BENCHMARK_COPTS,
deps = [
':benchmark',
],
testonly = 1,
) for f in [
'basic_test',
'benchmark_test',
'diagnostics_test',
'donotoptimize_test',
'filter_test',
'fixture_test',
'map_test',
'multiple_ranges_test',
'options_test',
'register_benchmark_test',
'skip_with_error_test',
'templated_fixture_test',
]
]

[cc_test(
name = f,
srcs = [
'test/%s.cc' % f,
],
copts = BENCHMARK_COPTS,
deps = [
':output_test_helper',
GTEST_DEP,
],
testonly = 1,
) for f in [
'complexity_test',
'reporter_output_test',
'user_counters_tabular_test',
'user_counters_test',
]
]

cc_test(
name = 'cxx03_test',
srcs = [
'test/cxx03_test.cc',
],
copts = [
'-std=c++03',
],
deps = [
':benchmark',
],
testonly = 1,
)

cc_library(
name = 'output_test_helper',
visibility = [
'//visibility:__pkg__',
],
srcs = [
'test/output_test_helper.cc',
],
hdrs = [
'test/output_test.h',
],
strip_include_prefix = 'test',
copts = BENCHMARK_COPTS,
deps = [
':benchmark',
],
testonly = 1,
)
7 changes: 7 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
git_repository(
name = 'com_github_google_googletest',
# TODO: Use googletest/googltest.git once the following PR is committed:
# https://github.com/google/googletest/pull/1212
remote = 'https://github.com/qzmfranklin/googletest.git',
commit = 'a7bd3725f08fe38374544bbf8f03699fc0d32a0b'
)