Skip to content

Commit b4e56fe

Browse files
committed
refactor(bazel): move google-benchmark to bzlmod
1 parent 07db06b commit b4e56fe

8 files changed

Lines changed: 39 additions & 46 deletions

File tree

.github/workflows/codspeed.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
name: Run benchmarks
2727
runs-on: ubuntu-22.04
2828
env:
29-
BAZEL_ARGS: --config=benchmark --@codspeed//core:codspeed_mode=instrumentation --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev
29+
BAZEL_ARGS: --config=benchmark --@workerd-google-benchmark//:codspeed_mode=instrumentation --remote_cache=https://bazel:${{ secrets.BAZEL_CACHE_KEY }}@bazel-remote-cache.devprod.cloudflare.dev
3030
steps:
3131
- uses: actions/checkout@v4
3232
with:

WORKSPACE

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,6 @@ load("//:build/rust_toolchains.bzl", "rust_toolchains")
1919

2020
rust_toolchains()
2121

22-
# Tell workerd code where to find google-benchmark with CodSpeed.
23-
#
24-
# We indirect through `@workerd-google-benchmark` to allow dependents to override how and where
25-
# google-benchmark is built, similar to the v8 setup above.
26-
new_local_repository(
27-
name = "workerd-google-benchmark",
28-
build_file_content = """cc_library(
29-
name = "benchmark",
30-
deps = [ "@codspeed//google_benchmark:benchmark" ],
31-
visibility = ["//visibility:public"])
32-
33-
cc_library(
34-
name = "benchmark_main",
35-
deps = [ "@codspeed//google_benchmark:benchmark_main" ],
36-
visibility = ["//visibility:public"])""",
37-
path = "empty",
38-
)
39-
4022
# rust-based lolhtml dependency, including the API header.
4123
# Presented as a separate repository to allow overrides.
4224
new_local_repository(

build/deps/build_deps.jsonc

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@
4949
"file_regex": "^cargo-bazel-x86_64-pc-windows-msvc.exe$",
5050
"file_type": "executable",
5151
"downloaded_file_path": "downloaded.exe"
52-
},
53-
// microbenchmark
54-
{
55-
"name": "codspeed",
56-
"type": "github_release",
57-
"owner": "CodSpeedHQ",
58-
"repo": "codspeed-cpp"
5952
}
6053
]
6154
}

build/deps/gen/build_deps.bzl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ load("@//build/deps:gen/dep_cargo_bazel_linux_x64.bzl", "dep_cargo_bazel_linux_x
55
load("@//build/deps:gen/dep_cargo_bazel_macos_arm64.bzl", "dep_cargo_bazel_macos_arm64")
66
load("@//build/deps:gen/dep_cargo_bazel_macos_x64.bzl", "dep_cargo_bazel_macos_x64")
77
load("@//build/deps:gen/dep_cargo_bazel_win_x64.bzl", "dep_cargo_bazel_win_x64")
8-
load("@//build/deps:gen/dep_codspeed.bzl", "dep_codspeed")
98
load("@//build/deps:gen/dep_rules_rust.bzl", "dep_rules_rust")
109

1110
def deps_gen():
@@ -15,4 +14,4 @@ def deps_gen():
1514
dep_cargo_bazel_macos_x64()
1615
dep_cargo_bazel_macos_arm64()
1716
dep_cargo_bazel_win_x64()
18-
dep_codspeed()
17+

build/deps/gen/dep_codspeed.bzl

Lines changed: 0 additions & 18 deletions
This file was deleted.

build/deps/v8.MODULE.bazel

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,13 @@ local_path_override(
101101
module_name = "workerd-v8",
102102
path = "build/workerd-v8",
103103
)
104+
105+
# Tell workerd code where to find google-benchmark with CodSpeed.
106+
#
107+
# We indirect through `@workerd-google-benchmark` to allow dependents to override how and where
108+
# google-benchmark is built, similar to the v8 setup above.
109+
bazel_dep(name = "workerd-google-benchmark")
110+
local_path_override(
111+
module_name = "workerd-google-benchmark",
112+
path = "build/google-benchmark",
113+
)

build/google-benchmark/BUILD

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cc_library(
2+
name = "benchmark",
3+
deps = [ "@codspeed//google_benchmark:benchmark" ],
4+
visibility = ["//visibility:public"],
5+
)
6+
7+
cc_library(
8+
name = "benchmark_main",
9+
deps = [ "@codspeed//google_benchmark:benchmark_main" ],
10+
visibility = ["//visibility:public"],
11+
)
12+
13+
alias(
14+
name = "codspeed_mode",
15+
actual = "@codspeed//core:codspeed_mode",
16+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module(name = "workerd-google-benchmark")
2+
3+
http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
http_archive(
6+
name = "codspeed",
7+
url = "https://api.github.com/repos/CodSpeedHQ/codspeed-cpp/tarball/v1.2.0",
8+
strip_prefix = "CodSpeedHQ-codspeed-cpp-719c41f",
9+
type = "tgz",
10+
sha256 = "1ced2c2e813313a574f41de9a218f38b53a4114cf7e72ee286801eaba6d8b240",
11+
)

0 commit comments

Comments
 (0)