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: 0 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
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"],
)
Expand Down
16 changes: 0 additions & 16 deletions bazel/BUILD

This file was deleted.

7 changes: 0 additions & 7 deletions bazel/have_regex.bzl

This file was deleted.

1 change: 1 addition & 0 deletions src/internal_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#elif defined(_WIN32)
#define BENCHMARK_OS_WINDOWS 1
#elif defined(__APPLE__)
#define BENCHMARK_OS_APPLE 1
#include "TargetConditionals.h"
#if defined(TARGET_OS_MAC)
#define BENCHMARK_OS_MACOSX 1
Expand Down
24 changes: 18 additions & 6 deletions src/re.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,31 @@

#include "internal_macros.h"

#if !defined(HAVE_STD_REGEX) && \
!defined(HAVE_GNU_POSIX_REGEX) && \
!defined(HAVE_POSIX_REGEX)
// No explicit regex selection; detect based on builtin hints.
#if defined(BENCHMARK_OS_LINUX) || defined(BENCHMARK_OS_APPLE)
#define HAVE_POSIX_REGEX 1
#elif __cplusplus >= 199711L
#define HAVE_STD_REGEX 1
#endif
#endif

// Prefer C regex libraries when compiling w/o exceptions so that we can
// correctly report errors.
#if defined(BENCHMARK_HAS_NO_EXCEPTIONS) && defined(HAVE_STD_REGEX) && \
#if defined(BENCHMARK_HAS_NO_EXCEPTIONS) && \
defined(BENCHMARK_HAVE_STD_REGEX) && \
(defined(HAVE_GNU_POSIX_REGEX) || defined(HAVE_POSIX_REGEX))
#undef HAVE_STD_REGEX
#undef HAVE_STD_REGEX
#endif

#if defined(HAVE_STD_REGEX)
#include <regex>
#include <regex>
#elif defined(HAVE_GNU_POSIX_REGEX)
#include <gnuregex.h>
#include <gnuregex.h>
#elif defined(HAVE_POSIX_REGEX)
#include <regex.h>
#include <regex.h>
#else
#error No regular expression backend was found!
#endif
Expand Down Expand Up @@ -64,7 +76,7 @@ class Regex {
#elif defined(HAVE_POSIX_REGEX) || defined(HAVE_GNU_POSIX_REGEX)
regex_t re_;
#else
#error No regular expression backend implementation available
#error No regular expression backend implementation available
#endif
};

Expand Down
4 changes: 1 addition & 3 deletions test/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
load("//bazel:have_regex.bzl", "have_regex_copts")

NEEDS_GTEST_MAIN = [
"statistics_test.cc",
]
Expand All @@ -8,7 +6,7 @@ TEST_COPTS = [
"-pedantic",
"-pedantic-errors",
"-std=c++11",
] + have_regex_copts()
]

TEST_ARGS = ["--benchmark_min_time=0.01"]

Expand Down