Commit Graph

15 Commits

Author SHA1 Message Date
mosfet80 ac80572f17
Update nanobind into benchmark_deps.bzl (#1826)
* Update nanobind into benchmark_deps.bzl

* Update benchmark_deps.bzl
2024-07-30 15:05:08 +01:00
Nicholas Junge 754ef08ab9
Upgrade core bazel dependencies (#1711)
Bumps `rules_foreign_cc` to v0.10.1 (October 2023), `bazel_skylib` to
v1.5.0 (November 2023), `rules_python` to v0.27.1 (December 2023).

Also syncs GoogleTest to v1.12.1 (the last C++11 supporting version) to
be the same as in MODULE.bazel.

Since the latest `rules_python` changed its setup calling convention,
that is updated also in the WORKSPACE file.
2023-12-07 15:00:43 +00:00
Nicholas Junge b93f5a5929
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 15:35:37 +00:00
Nicholas Junge e45585a4b8
Change nanobind linkage to response file approach on macOS (#1638)
* Change nanobind linkage to response file approach

This change needs https://github.com/bazelbuild/bazel/pull/18952 to be
merged first. Fixes macOS linkage of GBM's nanobind bindings on macOS by
supplying a linker response file instead of `-undefined dynamic_lookup`.

The latter has since been deprecated on macOS.

* Fix bazel_skylib checksum, bump skylib version in MODULE.bazel

* Bump Bazel to version 6.4.0 for linker response file support
2023-10-24 13:04:12 +01:00
Nicholas Junge 5893034e46
Add Python 3.12 support (#1676)
* Add Python 3.12 support tag

* Bump nanobind to latest stable v1.6.2 tag

* Add PyPI trusted publishing to GitHub workflow, add Python 3.12 wheel builds

Trusted publishing has been available since v1.8.0 of the pypa-publish
action. It enables password-less authentication and wheel uploads from
the wheel upload job.

`cibuildwheel` was bumped to v2.16.2 to allow Python 3.12 wheel builds.

More info on trusted publishing:
https://github.com/marketplace/actions/pypi-publish#trusted-publishing

The Windows distribution was reverted to `latest` in the OS matrix,
since the discovery problem of MSVC was fixed in a Bazel patch release.

* Bump nanobind to stable v1.7.0 tag
2023-10-23 13:04:39 +01:00
Nicholas Junge cb39b7150d
Bump `nanobind` to stable v1.4.0 tag (#1626)
This seems to reduce binding sizes even further, with a wheel size of
175KB on my local machine (macOS 13.4.1).
2023-07-11 09:56:51 +01:00
Shiqing Yan f7547e29cc
Correct libpfm dep for integrators. (#1579) 2023-03-20 09:50:17 +00:00
Dominic Hamon 4b086c26fe make libpfm dep work for integrators 2023-03-16 10:16:23 +00:00
Dominic Hamon 0c34d812e4 use 'new_git_repository' in external deps call to work with older bazel versions 2023-03-16 09:49:12 +00:00
dominic 68aa1903b1
add '@' to correctly reference build file for libpfm (#1575) 2023-03-14 10:18:00 +00:00
Nicholas Junge 23dadfa4a7
Bump nanobind to stable v0.2.0, change linker options (#1565)
Bumps nanobind to v0.2.0, the latest stable version to include all
features needed to create the GBM bindings. Deprecated names in v0.2.0
were migrated to their new counterparts.

Linkopts for macOS were changed to mirror the "endorsed" linker options
used in nanobind's CMake config, which were changed since the last
commit.
2023-03-07 11:22:00 +00:00
Nicholas Junge 80a3c5e4d9
Switch bindings implementation to `nanobind` (#1526)
* End support for Python 3.7, update cibuildwheel and publish actions

Removes Python 3.7 from the support matrix, since it does not support
PEP590 vectorcalls.

Bumps the `cibuildwheel` and `pypa-publish` actions to their latest
available versions respectively.

* Add nanobind to the Bazel dependencies, add a BUILD file

The build file builds nanobind as a static `cc_library`. Currently,
the git SHA points to HEAD, since some necessary features have not
been included in a release yet.

* Delete pybind11 BUILD file

* Switch bindings implementation to nanobind

Switches over the binding tool to `nanobind` from `pybind11`. Most
changes in the build setup itself were drop-in replacements of existing
code changed to nanobind names, no new concepts needed to be
implemented.

Sets the minimum required macOS to 10.14 for full C++17 support. Also,
to avoid ambiguities in Bazel, build for macOS 11 on Mac ARM64.

* Use Bazel select for linker options

Guards against unknown linker option errors by selecting required
linker options for nanobind only on macOS, where they are relevant.

Other changes:
* Bump cibuildwheel action to v2.12.0
* Bump Bazel for aarch64 linux wheels to 6.0.0
* Remove C++17 flag from build files since it is present in setup.py `bazel build` command
* Bump nanobind commit to current HEAD (TBD: Bump to next stable release)

* Unbreak Windows builds of nanobind-based bindings

Guards compiler options behind a new `select` macro choosing between
MSVC and not MSVC.

Other changes:
* Inject the proper C++17 standard cxxopt in the `setup.py` build
command.
* Bump nanobind to current HEAD.
* Make `macos` a benchmark-wide condition, with public visibility to
allow its use in the nanobind BUILD file.

* Fall back to `nb::implicitly_convertible` for Counter construction

Since `benchmark::Counter` only has a constructor for `double`,
the nanobind `nb::init_implicit` template cannot be used. Therefore,
to support implicit construction from ints, we fall back to the
`nb::implicitly_convertible` template instead.
2023-02-06 13:07:17 +00:00
Nicholas Junge dfd2ae520a
Add a `benchmark_deps.bzl` function to Google Benchmark (#1520)
* Add `benchmark_workspace.bzl` function

This commit adds a `benchmark_workspace.bzl` function to Google
Benchmark. It is intended to be used as a means to pull in Google
Benchmark's build dependencies in its own Bazel workspace, as well
as in workspaces of downstream projects.

* Migrate WORKSPACE to use the newly created benchmark_deps.bzl

This commit changes Google Benchmark's own WORKSPACE to use the newly
created `benchmark_deps.bzl` function.
2022-12-19 11:12:32 +00:00
Dominic Hamon df60aeb266
Rely on compiler intrinsics to identify regex engine. (#555)
Having the copts set on a per-target level can lead to ODR violations
in some cases. Avoid this by ensuring the regex engine is picked
through compiler intrinsics in the header directly.
2018-03-23 11:45:15 +00:00
jmillikin-stripe a9beffda0b Add support for building with Bazel. (#533)
* Add myself to CONTRIBUTORS under the corp CLA for Stripe, Inc.

* Add support for building with Bazel.

Limitations compared to existing CMake rules:
* Defaults to using C++11 `<regex>`, with an override via Bazel flag
  `--define` of `google_benchmark.have_regex`. The TravisCI config sets
  the regex implementation to `posix` because it uses ancient compilers.
* Debug vs Opt mode can't be set per test. TravisCI runs all the tests
  in debug mode to satisfy `diagnostics_test`, which depends on `CHECK`
  being live.

* Set Bazel workspace name so other repos can refer to it by stable name.

This is recommended by the Bazel style guide to avoid each dependent
workspace defining its own name for the dependency.
2018-03-08 12:48:46 +00:00