mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 13:00:36 +08:00
07c98d5a44
Follow up of #1725. `defines` propagates to reverse dependencies, while `local_defines` don't. If we use `defines` then there's risk of ODR violation: Suppose a user have a cc_library foo that depends on bar and benchmark: cc_library(name = "foo", deps = [":bar", "@com_github_google_benchmark//:benchmark"]) And bar has a class that has LFS-dependant ABI: cc_library(name = "foo") class Bar { off_t member; }; Bar would be compiled without LFS, but linked to foo when assuming LFS is enabled. So we limit LFS to within the library only. benchmark does not have LFS dependant public ABIs so it should be fine.
97 lines
2.2 KiB
Python
97 lines
2.2 KiB
Python
licenses(["notice"])
|
|
|
|
config_setting(
|
|
name = "qnx",
|
|
constraint_values = ["@platforms//os:qnx"],
|
|
values = {
|
|
"cpu": "x64_qnx",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "windows",
|
|
constraint_values = ["@platforms//os:windows"],
|
|
values = {
|
|
"cpu": "x64_windows",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "macos",
|
|
constraint_values = ["@platforms//os:macos"],
|
|
visibility = ["//visibility:public"],
|
|
)
|
|
|
|
config_setting(
|
|
name = "perfcounters",
|
|
define_values = {
|
|
"pfm": "1",
|
|
},
|
|
visibility = [":__subpackages__"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark",
|
|
srcs = glob(
|
|
[
|
|
"src/*.cc",
|
|
"src/*.h",
|
|
],
|
|
exclude = ["src/benchmark_main.cc"],
|
|
),
|
|
hdrs = [
|
|
"include/benchmark/benchmark.h",
|
|
"include/benchmark/export.h",
|
|
],
|
|
copts = select({
|
|
":windows": [],
|
|
"//conditions:default": ["-Werror=old-style-cast"],
|
|
}),
|
|
defines = [
|
|
"BENCHMARK_STATIC_DEFINE",
|
|
] + select({
|
|
":perfcounters": ["HAVE_LIBPFM"],
|
|
"//conditions:default": [],
|
|
}),
|
|
linkopts = select({
|
|
":windows": ["-DEFAULTLIB:shlwapi.lib"],
|
|
"//conditions:default": ["-pthread"],
|
|
}),
|
|
# Only static linking is allowed; no .so will be produced.
|
|
# Using `defines` (i.e. not `local_defines`) means that no
|
|
# dependent rules need to bother about defining the macro.
|
|
linkstatic = True,
|
|
local_defines = [
|
|
# Turn on Large-file Support
|
|
"_FILE_OFFSET_BITS=64",
|
|
"_LARGEFILE64_SOURCE",
|
|
"_LARGEFILE_SOURCE",
|
|
],
|
|
strip_include_prefix = "include",
|
|
visibility = ["//visibility:public"],
|
|
deps = select({
|
|
":perfcounters": ["@libpfm"],
|
|
"//conditions:default": [],
|
|
}),
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark_main",
|
|
srcs = ["src/benchmark_main.cc"],
|
|
hdrs = [
|
|
"include/benchmark/benchmark.h",
|
|
"include/benchmark/export.h",
|
|
],
|
|
strip_include_prefix = "include",
|
|
visibility = ["//visibility:public"],
|
|
deps = [":benchmark"],
|
|
)
|
|
|
|
cc_library(
|
|
name = "benchmark_internal_headers",
|
|
hdrs = glob(["src/*.h"]),
|
|
visibility = ["//test:__pkg__"],
|
|
)
|