mirror of
https://github.com/google/benchmark.git
synced 2025-02-21 08:40:17 +08:00
* Add pre-commit config and GitHub Actions job Contains the following hooks: * buildifier - for formatting and linting Bazel files. * mypy, ruff, isort, black - for Python typechecking, import hygiene, static analysis, and formatting. The pylint CI job was changed to be a pre-commit CI job, where pre-commit is bootstrapped via Python. Pylint is currently no longer part of the code checks, but can be re-added if requested. The reason to drop was that it does not play nicely with pre-commit, and lots of its functionality and responsibilities are actually covered in ruff. * Add dev extra to pyproject.toml for development installs * Clarify that pre-commit contains only Python and Bazel hooks * Add one-line docstrings to Bazel modules * Apply buildifier pre-commit fixes to Bazel files * Apply pre-commit fixes to Python files * Supply --profile=black to isort to prevent conflicts * Fix nanobind build file formatting * Add tooling configs to `pyproject.toml` In particular, set line length 80 for all Python files. * Reformat all Python files to line length 80, fix return type annotations Also ignores the `tools/compare.py` and `tools/gbench/report.py` files for mypy, since they emit a barrage of errors which we can deal with later. The errors are mostly related to dynamic classmethod definition.
30 lines
859 B
Python
30 lines
859 B
Python
"""
|
|
This file contains some build definitions for C++ extensions used in the Google Benchmark Python bindings.
|
|
"""
|
|
|
|
_SHARED_LIB_SUFFIX = {
|
|
"//conditions:default": ".so",
|
|
"//:windows": ".dll",
|
|
}
|
|
|
|
def py_extension(name, srcs, hdrs = [], copts = [], features = [], deps = []):
|
|
for shared_lib_suffix in _SHARED_LIB_SUFFIX.values():
|
|
shared_lib_name = name + shared_lib_suffix
|
|
native.cc_binary(
|
|
name = shared_lib_name,
|
|
linkshared = True,
|
|
linkstatic = True,
|
|
srcs = srcs + hdrs,
|
|
copts = copts,
|
|
features = features,
|
|
deps = deps,
|
|
)
|
|
|
|
return native.py_library(
|
|
name = name,
|
|
data = select({
|
|
platform: [name + shared_lib_suffix]
|
|
for platform, shared_lib_suffix in _SHARED_LIB_SUFFIX.items()
|
|
}),
|
|
)
|