Skip to content

Commit 5c4f0fb

Browse files
promethus bazel not working becuase of cgo something
1 parent 76af89e commit 5c4f0fb

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

WORKSPACE.bazel

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -456,16 +456,33 @@ go_repository(
456456
go_repository(
457457
name = "com_github_prometheus_client_golang",
458458
importpath = "github.com/prometheus/client_golang",
459-
sum = "h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=", # Sum for v1.22.0
459+
sum = "h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=",
460460
version = "v1.22.0",
461461
# Add Gazelle arguments to exclude the Cgo-related files
462462
# This might prevent Gazelle from setting cgo = True for the library
463-
build_extra_args = [
464-
"-exclude=prometheus/process_collector_mem_cgo_darwin.go",
465-
"-exclude=prometheus/process_collector_mem_cgo_darwin.c",
466-
],
463+
# build_extra_args = [
464+
# "-exclude=prometheus/process_collector_mem_cgo_darwin.go",
465+
# "-exclude=prometheus/process_collector_mem_cgo_darwin.c",
466+
# ],
467+
#patches = ["patches/prometheus_cgo.patch"],
467468
)
468469

470+
# http_archive(
471+
# name = "com_github_prometheus_client_golang",
472+
# sha256 = "9ec5f0f04f0c9736619ce2c38e89802293be0b7060088ca6f8eeef10d07bf8a9",
473+
# strip_prefix = "client_golang-1.22.0",
474+
# urls = ["https://github.com/prometheus/client_golang/archive/refs/tags/v1.22.0.tar.gz"],
475+
# patch_cmds = [
476+
# "echo '--- Debugging patch_cmds ---'",
477+
# "echo 'Current directory:'",
478+
# "pwd",
479+
# "echo 'Listing root directory:'",
480+
# "ls -al",
481+
# # Use sed to replace 'cgo = True,' with 'cgo = False,' in the root BUILD.bazel file.
482+
# "sed -i 's/cgo = True,/cgo = False,/g' prometheus/BUILD.bazel" ,
483+
# ],
484+
# )
485+
469486
go_repository(
470487
name = "com_github_prometheus_client_model",
471488
importpath = "github.com/prometheus/client_model",

patches/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# .bazel/patches/BUILD.bazel
2+
package(default_visibility = ["//visibility:public"])
3+
4+
exports_files(["prometheus_cgo.patch"])

patches/prometheus_cgo.patch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--- a/prometheus/BUILD.bazel
2+
+++ b/prometheus/BUILD.bazel
3+
@@ -38,7 +38,7 @@
4+
"vec.go",
5+
"wrap.go",
6+
],
7+
- cgo = True,
8+
+ cgo = False,
9+
importpath = "github.com/prometheus/client_golang/prometheus",
10+
visibility = ["//visibility:public"],
11+
deps = [
12+

0 commit comments

Comments
 (0)