| 1 |
""" |
| 2 |
This file contains some build definitions for C++ extensions used in the Google Benchmark Python bindings. |
| 3 |
""" |
| 4 |
|
| 5 |
load("//third_party/bazel_rules/rules_cc/cc:cc_binary.bzl", "cc_binary") |
| 6 |
|
| 7 |
_SHARED_LIB_SUFFIX = { |
| 8 |
"//conditions:default": ".so", |
| 9 |
"//:windows": ".dll", |
| 10 |
} |
| 11 |
|
| 12 |
def py_extension(name, srcs, hdrs = [], copts = [], features = [], deps = []): |
| 13 |
for shared_lib_suffix in _SHARED_LIB_SUFFIX.values(): |
| 14 |
shared_lib_name = name + shared_lib_suffix |
| 15 |
cc_binary( |
| 16 |
name = shared_lib_name, |
| 17 |
linkshared = True, |
| 18 |
linkstatic = True, |
| 19 |
srcs = srcs + hdrs, |
| 20 |
copts = copts, |
| 21 |
features = features, |
| 22 |
deps = deps, |
| 23 |
) |
| 24 |
|
| 25 |
return native.py_library( |
| 26 |
name = name, |
| 27 |
data = select({ |
| 28 |
platform: [name + shared_lib_suffix] |
| 29 |
for platform, shared_lib_suffix in _SHARED_LIB_SUFFIX.items() |
| 30 |
}), |
| 31 |
) |