Skip to content

Commit 5edaebc

Browse files
committed
fix: expose instrument-hooks via extension
1 parent 0ebe25f commit 5edaebc

File tree

6 files changed

+65
-37
lines changed

6 files changed

+65
-37
lines changed

MODULE.bazel

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
bazel_dep(name = "rules_cc", version = "0.0.17")
2-
bazel_dep(name = "instrument_hooks", version = "1.0.0")
2+
bazel_dep(name = "platforms", version = "0.0.10")
33

4-
git_override(
5-
module_name = "instrument_hooks",
6-
commit = "42ed74076c697c2f06c5ac81a84ccee983d7f140",
7-
remote = "https://github.com/CodSpeedHQ/instrument-hooks",
8-
)
4+
# Fetch instrument_hooks via module extension (it doesn't have MODULE.bazel)
5+
use_repo(use_extension("//third_party:extensions.bzl", "instrument_hooks"), "instrument_hooks")

core/BUILD

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,6 @@ config_setting(
88
constraint_values = ["@platforms//os:windows"],
99
)
1010

11-
# Instrument-hooks library with warning suppressions
12-
cc_library(
13-
name = "instrument_hooks",
14-
srcs = ["instrument-hooks/dist/core.c"],
15-
hdrs = glob(["instrument-hooks/includes/*.h"]),
16-
includes = ["instrument-hooks/includes"],
17-
copts = select({
18-
":windows": [
19-
"/wd4101", # unreferenced local variable (equivalent to -Wno-unused-variable)
20-
"/wd4189", # local variable is initialized but not referenced (equivalent to -Wno-unused-but-set-variable)
21-
"/wd4100", # unreferenced formal parameter (equivalent to -Wno-unused-parameter)
22-
"/wd4245", # signed/unsigned mismatch
23-
"/wd4132", # const object should be initialized
24-
"/wd4146", # unary minus operator applied to unsigned type
25-
],
26-
"//conditions:default": [
27-
"-Wno-maybe-uninitialized",
28-
"-Wno-unused-variable",
29-
"-Wno-unused-parameter",
30-
"-Wno-unused-but-set-variable",
31-
"-Wno-type-limits",
32-
"-Wno-format",
33-
"-Wno-format-security",
34-
],
35-
}),
36-
visibility = ["//visibility:public"],
37-
)
38-
39-
4011
# Define the codspeed library
4112
cc_library(
4213
name = "codspeed",
@@ -54,7 +25,7 @@ cc_library(
5425
":walltime_mode": ["CODSPEED_ENABLED", "CODSPEED_WALLTIME"],
5526
"//conditions:default": [],
5627
}),
57-
deps = [":instrument_hooks"],
28+
deps = ["@instrument_hooks//:instrument_hooks"],
5829
visibility = ["//visibility:public"],
5930
)
6031

core/instrument-hooks

Submodule instrument-hooks deleted from b1e401a

third_party/BUILD

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This package contains BUILD files and extensions for third-party dependencies
2+
# that don't have their own Bazel configuration
3+
4+
exports_files([
5+
"instrument_hooks.BUILD",
6+
"extensions.bzl",
7+
])

third_party/extensions.bzl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Bazel module extensions for codspeed-cpp dependencies."""
2+
3+
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
4+
5+
def _instrument_hooks_impl(module_ctx):
6+
git_repository(
7+
name = "instrument_hooks",
8+
remote = "https://github.com/CodSpeedHQ/instrument-hooks",
9+
commit = "b1e401a4d031ad308edb22ed59a52253a1ebe924",
10+
build_file = Label("//third_party:instrument_hooks.BUILD"),
11+
)
12+
return module_ctx.extension_metadata(
13+
reproducible = True,
14+
root_module_direct_deps = ["instrument_hooks"],
15+
root_module_direct_dev_deps = [],
16+
)
17+
18+
instrument_hooks = module_extension(
19+
implementation = _instrument_hooks_impl,
20+
)

third_party/instrument_hooks.BUILD

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
load("@rules_cc//cc:defs.bzl", "cc_library")
2+
3+
config_setting(
4+
name = "windows",
5+
constraint_values = ["@platforms//os:windows"],
6+
)
7+
8+
# Instrument-hooks library with warning suppressions
9+
cc_library(
10+
name = "instrument_hooks",
11+
srcs = ["dist/core.c"],
12+
hdrs = glob(["includes/*.h"]),
13+
includes = ["includes"],
14+
copts = select({
15+
":windows": [
16+
"/wd4101", # unreferenced local variable
17+
"/wd4189", # local variable is initialized but not referenced
18+
"/wd4100", # unreferenced formal parameter
19+
"/wd4245", # signed/unsigned mismatch
20+
"/wd4132", # const object should be initialized
21+
"/wd4146", # unary minus operator applied to unsigned type
22+
],
23+
"//conditions:default": [
24+
"-Wno-maybe-uninitialized",
25+
"-Wno-unused-variable",
26+
"-Wno-unused-parameter",
27+
"-Wno-unused-but-set-variable",
28+
"-Wno-type-limits",
29+
"-Wno-format",
30+
"-Wno-format-security",
31+
],
32+
}),
33+
visibility = ["//visibility:public"],
34+
)

0 commit comments

Comments
 (0)