1licenses(["notice"]) 2 3COPTS = [ 4 "-pedantic", 5 "-pedantic-errors", 6 "-std=c++14", 7 "-Wall", 8 "-Wconversion", 9 "-Wextra", 10 "-Wshadow", 11 # "-Wshorten-64-to-32", 12 "-Wfloat-equal", 13 "-fstrict-aliasing", 14 ## assert() are used a lot in tests upstream, which may be optimised out leading to 15 ## unused-variable warning. 16 "-Wno-unused-variable", 17 "-Werror=old-style-cast", 18] 19 20config_setting( 21 name = "qnx", 22 constraint_values = ["@platforms//os:qnx"], 23 values = { 24 "cpu": "x64_qnx", 25 }, 26 visibility = [":__subpackages__"], 27) 28 29config_setting( 30 name = "windows", 31 constraint_values = ["@platforms//os:windows"], 32 values = { 33 "cpu": "x64_windows", 34 }, 35 visibility = [":__subpackages__"], 36) 37 38config_setting( 39 name = "macos", 40 constraint_values = ["@platforms//os:macos"], 41 visibility = ["//visibility:public"], 42) 43 44config_setting( 45 name = "perfcounters", 46 define_values = { 47 "pfm": "1", 48 }, 49 visibility = [":__subpackages__"], 50) 51 52cc_library( 53 name = "benchmark", 54 srcs = glob( 55 [ 56 "src/*.cc", 57 "src/*.h", 58 ], 59 exclude = ["src/benchmark_main.cc"], 60 ), 61 hdrs = [ 62 "include/benchmark/benchmark.h", 63 "include/benchmark/export.h", 64 ], 65 copts = select({ 66 ":windows": [], 67 "//conditions:default": COPTS, 68 }), 69 defines = [ 70 "BENCHMARK_STATIC_DEFINE", 71 "BENCHMARK_VERSION=\\\"" + (module_version() if module_version() != None else "") + "\\\"", 72 ] + select({ 73 ":perfcounters": ["HAVE_LIBPFM"], 74 "//conditions:default": [], 75 }), 76 includes = ["include"], 77 linkopts = select({ 78 ":windows": ["-DEFAULTLIB:shlwapi.lib"], 79 "//conditions:default": ["-pthread"], 80 }), 81 # Only static linking is allowed; no .so will be produced. 82 # Using `defines` (i.e. not `local_defines`) means that no 83 # dependent rules need to bother about defining the macro. 84 linkstatic = True, 85 local_defines = [ 86 # Turn on Large-file Support 87 "_FILE_OFFSET_BITS=64", 88 "_LARGEFILE64_SOURCE", 89 "_LARGEFILE_SOURCE", 90 ], 91 visibility = ["//visibility:public"], 92 deps = select({ 93 ":perfcounters": ["@libpfm"], 94 "//conditions:default": [], 95 }), 96) 97 98cc_library( 99 name = "benchmark_main", 100 srcs = ["src/benchmark_main.cc"], 101 hdrs = [ 102 "include/benchmark/benchmark.h", 103 "include/benchmark/export.h", 104 ], 105 includes = ["include"], 106 visibility = ["//visibility:public"], 107 deps = [":benchmark"], 108) 109 110cc_library( 111 name = "benchmark_internal_headers", 112 hdrs = glob(["src/*.h"]), 113 visibility = ["//test:__pkg__"], 114) 115