From 6a894bd555fb1216df73e472ce48c9e742363ce7 Mon Sep 17 00:00:00 2001 From: Paul Wankadia Date: Thu, 17 Mar 2022 19:47:45 +1100 Subject: [PATCH] Build `//:benchmark` as a static library only. (#1373) If someone or something ever needs the dynamic library as a Bazel build artifact, we can figure that out for them then, but right now, there is no strong reason to be wrangling various `export.h`-controlling macros. Fixes #1372. --- BUILD.bazel | 9 +++++---- bindings/python/build_defs.bzl | 1 - 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index 4bf5bfc5..1dca996d 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -55,10 +55,11 @@ cc_library( ":windows": [], "//conditions:default": posix_copts, }), - local_defines = select({ - ":windows": ["benchmark_EXPORTS"], - "//conditions:default": [], - }), + # 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, + defines = ["BENCHMARK_STATIC_DEFINE"], ) cc_library( diff --git a/bindings/python/build_defs.bzl b/bindings/python/build_defs.bzl index ffe0d9e2..009820af 100644 --- a/bindings/python/build_defs.bzl +++ b/bindings/python/build_defs.bzl @@ -14,7 +14,6 @@ def py_extension(name, srcs, hdrs = [], copts = [], features = [], deps = []): copts = copts, features = features, deps = deps, - local_defines = ["BENCHMARK_STATIC_DEFINE"], ) return native.py_library(