Skip to content

Commit

Permalink
Merge branch 'google:main' into benchmark_list_tests-work-with-benchm…
Browse files Browse the repository at this point in the history
…ark-format=json-google#1642
  • Loading branch information
varshneydevansh authored May 12, 2024
2 parents b8ad5ac + bc946b9 commit f4832c3
Show file tree
Hide file tree
Showing 33 changed files with 232 additions and 264 deletions.
1 change: 0 additions & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
Checks: 'clang-analyzer-*,readability-redundant-*,performance-*'
WarningsAsErrors: 'clang-analyzer-*,readability-redundant-*,performance-*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
User: user
9 changes: 4 additions & 5 deletions .github/install_bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ if ! bazel version; then
if [ "$arch" == "aarch64" ]; then
arch="arm64"
fi
echo "Installing wget and downloading $arch Bazel binary from GitHub releases."
yum install -y wget
wget "https://github.com/bazelbuild/bazel/releases/download/6.4.0/bazel-6.4.0-linux-$arch" -O /usr/local/bin/bazel
chmod +x /usr/local/bin/bazel
echo "Downloading $arch Bazel binary from GitHub releases."
curl -L -o $HOME/bin/bazel --create-dirs "https://github.com/bazelbuild/bazel/releases/download/7.1.1/bazel-7.1.1-linux-$arch"
chmod +x $HOME/bin/bazel
else
# bazel is installed for the correct architecture
# Bazel is installed for the correct architecture
exit 0
fi
50 changes: 31 additions & 19 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Python 3.11
- name: Install Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: 3.12
- run: python -m pip install build
- name: Build sdist
run: python -m build --sdist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: dist
name: dist-sdist
path: dist/*.tar.gz

build_wheels:
name: Build Google Benchmark wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest, macos-13, macos-14, windows-latest]

steps:
- name: Check out Google Benchmark
Expand All @@ -47,32 +47,44 @@ jobs:
platforms: all

- name: Build wheels on ${{ matrix.os }} using cibuildwheel
uses: pypa/cibuildwheel@v2.16.2
uses: pypa/cibuildwheel@v2.17
env:
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-*'
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: "*-musllinux_*"
CIBW_TEST_SKIP: "*-macosx_arm64"
CIBW_ARCHS_LINUX: x86_64 aarch64
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_ARCHS_WINDOWS: AMD64
CIBW_TEST_SKIP: "cp38-macosx_*:arm64"
CIBW_ARCHS_LINUX: auto64 aarch64
CIBW_ARCHS_WINDOWS: auto64
CIBW_BEFORE_ALL_LINUX: bash .github/install_bazel.sh
# Grab the rootless Bazel installation inside the container.
CIBW_ENVIRONMENT_LINUX: PATH=$PATH:$HOME/bin
CIBW_TEST_COMMAND: python {project}/bindings/python/google_benchmark/example.py

- name: Upload Google Benchmark ${{ matrix.os }} wheels
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-${{ matrix.os }}
path: wheelhouse/*.whl

merge_wheels:
name: Merge all built wheels into one artifact
runs-on: ubuntu-latest
needs: build_wheels
steps:
- name: Merge wheels
uses: actions/upload-artifact/merge@v4
with:
name: dist
pattern: dist-*
delete-merged: true

pypi_upload:
name: Publish google-benchmark wheels to PyPI
needs: [build_sdist, build_wheels]
needs: [merge_wheels]
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: dist
path: dist
- uses: pypa/[email protected]
- uses: actions/download-artifact@v4
with:
path: dist
- uses: pypa/gh-action-pypi-publish@v1
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repos:
types_or: [ python, pyi ]
args: [ "--ignore-missing-imports", "--scripts-are-modules" ]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.13
rev: v0.3.1
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
Expand Down
19 changes: 18 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
licenses(["notice"])

COPTS = [
"-pedantic",
"-pedantic-errors",
"-std=c++11",
"-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",
]

config_setting(
name = "qnx",
constraint_values = ["@platforms//os:qnx"],
Expand Down Expand Up @@ -47,7 +64,7 @@ cc_library(
],
copts = select({
":windows": [],
"//conditions:default": ["-Werror=old-style-cast"],
"//conditions:default": COPTS,
}),
defines = [
"BENCHMARK_STATIC_DEFINE",
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ else()
add_cxx_compiler_flag(-Wshadow)
add_cxx_compiler_flag(-Wfloat-equal)
add_cxx_compiler_flag(-Wold-style-cast)
add_cxx_compiler_flag(-Wconversion)
if(BENCHMARK_ENABLE_WERROR)
add_cxx_compiler_flag(-Werror)
endif()
Expand Down
13 changes: 11 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ module(
)

bazel_dep(name = "bazel_skylib", version = "1.5.0")
bazel_dep(name = "platforms", version = "0.0.7")
bazel_dep(name = "platforms", version = "0.0.8")
bazel_dep(name = "rules_foreign_cc", version = "0.10.1")
bazel_dep(name = "rules_cc", version = "0.0.9")

bazel_dep(name = "rules_python", version = "0.27.1", dev_dependency = True)
bazel_dep(name = "rules_python", version = "0.31.0", dev_dependency = True)
bazel_dep(name = "googletest", version = "1.12.1", dev_dependency = True, repo_name = "com_google_googletest")

bazel_dep(name = "libpfm", version = "4.11.0")
Expand All @@ -19,7 +19,14 @@ bazel_dep(name = "libpfm", version = "4.11.0")
# of relying on the changing default version from rules_python.

python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
python.toolchain(python_version = "3.8")
python.toolchain(python_version = "3.9")
python.toolchain(python_version = "3.10")
python.toolchain(python_version = "3.11")
python.toolchain(
is_default = True,
python_version = "3.12",
)

pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip", dev_dependency = True)
pip.parse(
Expand All @@ -30,3 +37,5 @@ pip.parse(
use_repo(pip, "tools_pip_deps")

# -- bazel_dep definitions -- #

bazel_dep(name = "nanobind_bazel", version = "1.0.0", dev_dependency = True)
6 changes: 0 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,3 @@ pip_parse(
load("@tools_pip_deps//:requirements.bzl", "install_deps")

install_deps()

new_local_repository(
name = "python_headers",
build_file = "@//bindings/python:python_headers.BUILD",
path = "<PYTHON_INCLUDE_PATH>", # May be overwritten by setup.py.
)
3 changes: 0 additions & 3 deletions bindings/python/BUILD

This file was deleted.

29 changes: 0 additions & 29 deletions bindings/python/build_defs.bzl

This file was deleted.

18 changes: 3 additions & 15 deletions bindings/python/google_benchmark/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("//bindings/python:build_defs.bzl", "py_extension")
load("@nanobind_bazel//:build_defs.bzl", "nanobind_extension")

py_library(
name = "google_benchmark",
Expand All @@ -9,22 +9,10 @@ py_library(
],
)

py_extension(
nanobind_extension(
name = "_benchmark",
srcs = ["benchmark.cc"],
copts = [
"-fexceptions",
"-fno-strict-aliasing",
],
features = [
"-use_header_modules",
"-parse_headers",
],
deps = [
"//:benchmark",
"@nanobind",
"@python_headers",
],
deps = ["//:benchmark"],
)

py_test(
Expand Down
1 change: 1 addition & 0 deletions bindings/python/google_benchmark/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def my_benchmark(state):
if __name__ == '__main__':
benchmark.main()
"""

import atexit

from absl import app
Expand Down
59 changes: 0 additions & 59 deletions bindings/python/nanobind.BUILD

This file was deleted.

10 changes: 0 additions & 10 deletions bindings/python/python_headers.BUILD

This file was deleted.

7 changes: 7 additions & 0 deletions cmake/benchmark_main.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@

Name: @PROJECT_NAME@
Description: Google microbenchmark framework (with main() function)
Version: @VERSION@
Requires: benchmark
Libs: -L${libdir} -lbenchmark_main
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ src = ["bindings/python"]
line-length = 80
target-version = "py311"

[tool.ruff.lint]
# Enable pycodestyle (`E`, `W`), Pyflakes (`F`), and isort (`I`) codes by default.
select = ["E", "F", "I", "W"]
ignore = [
"E501", # line too long
]

[tool.ruff.isort]
[tool.ruff.lint.isort]
combine-as-imports = true
Loading

0 comments on commit f4832c3

Please sign in to comment.