1licenses(["notice"]) 2 3config_setting( 4 name = "qnx", 5 constraint_values = ["@platforms//os:qnx"], 6 values = { 7 "cpu": "x64_qnx", 8 }, 9 visibility = [":__subpackages__"], 10) 11 12config_setting( 13 name = "windows", 14 constraint_values = ["@platforms//os:windows"], 15 values = { 16 "cpu": "x64_windows", 17 }, 18 visibility = [":__subpackages__"], 19) 20 21config_setting( 22 name = "macos", 23 constraint_values = ["@platforms//os:macos"], 24 visibility = ["//visibility:public"], 25) 26 27config_setting( 28 name = "perfcounters", 29 define_values = { 30 "pfm": "1", 31 }, 32 visibility = [":__subpackages__"], 33) 34 35cc_library( 36 name = "benchmark", 37 srcs = glob( 38 [ 39 "src/*.cc", 40 "src/*.h", 41 ], 42 exclude = ["src/benchmark_main.cc"], 43 ), 44 hdrs = [ 45 "include/benchmark/benchmark.h", 46 "include/benchmark/export.h", 47 ], 48 linkopts = select({ 49 ":windows": ["-DEFAULTLIB:shlwapi.lib"], 50 "//conditions:default": ["-pthread"], 51 }), 52 copts = select({ 53 ":windows": [], 54 "//conditions:default": ["-Werror=old-style-cast"], 55 }), 56 strip_include_prefix = "include", 57 visibility = ["//visibility:public"], 58 # Only static linking is allowed; no .so will be produced. 59 # Using `defines` (i.e. not `local_defines`) means that no 60 # dependent rules need to bother about defining the macro. 61 linkstatic = True, 62 defines = [ 63 "BENCHMARK_STATIC_DEFINE", 64 ] + select({ 65 ":perfcounters": ["HAVE_LIBPFM"], 66 "//conditions:default": [], 67 }), 68 deps = select({ 69 ":perfcounters": ["@libpfm//:libpfm"], 70 "//conditions:default": [], 71 }), 72) 73 74cc_library( 75 name = "benchmark_main", 76 srcs = ["src/benchmark_main.cc"], 77 hdrs = ["include/benchmark/benchmark.h", "include/benchmark/export.h"], 78 strip_include_prefix = "include", 79 visibility = ["//visibility:public"], 80 deps = [":benchmark"], 81) 82 83cc_library( 84 name = "benchmark_internal_headers", 85 hdrs = glob(["src/*.h"]), 86 visibility = ["//test:__pkg__"], 87) 88