2018-03-08 20:48:46 +08:00
|
|
|
licenses(["notice"])
|
|
|
|
|
2024-03-07 20:19:56 +08:00
|
|
|
COPTS = [
|
|
|
|
"-pedantic",
|
|
|
|
"-pedantic-errors",
|
2024-11-13 21:06:48 +08:00
|
|
|
"-std=c++17",
|
2024-03-07 20:19:56 +08:00
|
|
|
"-Wall",
|
|
|
|
"-Wconversion",
|
|
|
|
"-Wextra",
|
|
|
|
"-Wshadow",
|
|
|
|
# "-Wshorten-64-to-32",
|
|
|
|
"-Wfloat-equal",
|
|
|
|
"-fstrict-aliasing",
|
|
|
|
## assert() are used a lot in tests upstream, which may be optimised out leading to
|
|
|
|
## unused-variable warning.
|
|
|
|
"-Wno-unused-variable",
|
|
|
|
"-Werror=old-style-cast",
|
|
|
|
]
|
|
|
|
|
2018-05-01 22:24:38 +08:00
|
|
|
config_setting(
|
|
|
|
name = "windows",
|
2021-06-28 20:46:08 +08:00
|
|
|
constraint_values = ["@platforms//os:windows"],
|
2018-05-01 22:24:38 +08:00
|
|
|
visibility = [":__subpackages__"],
|
|
|
|
)
|
|
|
|
|
2022-10-31 19:03:59 +08:00
|
|
|
config_setting(
|
|
|
|
name = "perfcounters",
|
|
|
|
define_values = {
|
|
|
|
"pfm": "1",
|
|
|
|
},
|
|
|
|
visibility = [":__subpackages__"],
|
|
|
|
)
|
|
|
|
|
2021-01-05 17:54:04 +08:00
|
|
|
cc_library(
|
|
|
|
name = "benchmark",
|
2018-05-25 18:18:58 +08:00
|
|
|
srcs = glob(
|
|
|
|
[
|
|
|
|
"src/*.cc",
|
|
|
|
"src/*.h",
|
|
|
|
],
|
|
|
|
exclude = ["src/benchmark_main.cc"],
|
|
|
|
),
|
2022-02-14 18:48:53 +08:00
|
|
|
hdrs = [
|
|
|
|
"include/benchmark/benchmark.h",
|
2022-07-26 16:00:49 +08:00
|
|
|
"include/benchmark/export.h",
|
2022-02-14 18:48:53 +08:00
|
|
|
],
|
2023-06-22 06:35:44 +08:00
|
|
|
copts = select({
|
|
|
|
":windows": [],
|
2024-03-07 20:19:56 +08:00
|
|
|
"//conditions:default": COPTS,
|
2023-06-22 06:35:44 +08:00
|
|
|
}),
|
2022-10-31 19:03:59 +08:00
|
|
|
defines = [
|
|
|
|
"BENCHMARK_STATIC_DEFINE",
|
2024-01-29 21:48:04 +08:00
|
|
|
"BENCHMARK_VERSION=\\\"" + (module_version() if module_version() != None else "") + "\\\"",
|
2022-10-31 19:03:59 +08:00
|
|
|
] + select({
|
|
|
|
":perfcounters": ["HAVE_LIBPFM"],
|
|
|
|
"//conditions:default": [],
|
|
|
|
}),
|
2024-06-17 16:38:32 +08:00
|
|
|
includes = ["include"],
|
Add pre-commit config and GitHub Actions job (#1688)
* 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.
2023-10-30 23:35:37 +08:00
|
|
|
linkopts = select({
|
|
|
|
":windows": ["-DEFAULTLIB:shlwapi.lib"],
|
|
|
|
"//conditions:default": ["-pthread"],
|
|
|
|
}),
|
|
|
|
# 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,
|
2024-01-05 18:27:12 +08:00
|
|
|
local_defines = [
|
|
|
|
# Turn on Large-file Support
|
|
|
|
"_FILE_OFFSET_BITS=64",
|
|
|
|
"_LARGEFILE64_SOURCE",
|
|
|
|
"_LARGEFILE_SOURCE",
|
|
|
|
],
|
Add pre-commit config and GitHub Actions job (#1688)
* 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.
2023-10-30 23:35:37 +08:00
|
|
|
visibility = ["//visibility:public"],
|
2022-10-31 19:03:59 +08:00
|
|
|
deps = select({
|
Add pre-commit config and GitHub Actions job (#1688)
* 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.
2023-10-30 23:35:37 +08:00
|
|
|
":perfcounters": ["@libpfm"],
|
2022-10-31 19:03:59 +08:00
|
|
|
"//conditions:default": [],
|
|
|
|
}),
|
2018-03-08 20:48:46 +08:00
|
|
|
)
|
|
|
|
|
2018-05-25 18:18:58 +08:00
|
|
|
cc_library(
|
|
|
|
name = "benchmark_main",
|
|
|
|
srcs = ["src/benchmark_main.cc"],
|
Add pre-commit config and GitHub Actions job (#1688)
* 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.
2023-10-30 23:35:37 +08:00
|
|
|
hdrs = [
|
|
|
|
"include/benchmark/benchmark.h",
|
|
|
|
"include/benchmark/export.h",
|
|
|
|
],
|
2024-06-17 16:38:32 +08:00
|
|
|
includes = ["include"],
|
2018-05-25 18:18:58 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [":benchmark"],
|
|
|
|
)
|
|
|
|
|
2018-03-08 20:48:46 +08:00
|
|
|
cc_library(
|
|
|
|
name = "benchmark_internal_headers",
|
|
|
|
hdrs = glob(["src/*.h"]),
|
|
|
|
visibility = ["//test:__pkg__"],
|
|
|
|
)
|