Skip to content

Commit

Permalink
build(bazel): use Bazel modules
Browse files Browse the repository at this point in the history
Issue: #225 #507 #513 #581
Closes: #616
  • Loading branch information
gjasny committed Feb 1, 2023
1 parent e9ae295 commit bb21a73
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/bazel-ci.yml
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Test with SSL
run: bazel test --config=ssl ${{ matrix.bazel_args }} --test_output=all //...

- name: Build with SSL and bzlmod
run: bazel build --enable_bzlmod --config=ssl ${{ matrix.bazel_args }} //...

- name: Build
run: bazel build //...

Expand Down
19 changes: 19 additions & 0 deletions MODULE.bazel
@@ -0,0 +1,19 @@
module(
name = "prometheus-cpp",
version = "1.1.0",
repo_name = "com_github_jupp0r_prometheus_cpp",
)

data_deps_ext = use_extension("//bazel:repositories.bzl", "data_deps_ext")
use_repo(
data_deps_ext,
"civetweb",
"com_github_curl",
"com_github_google_benchmark",
)

bazel_dep(name = "boringssl", version = "0.0.0-20211025-d4f1ab9")
bazel_dep(name = "googletest", version = "1.12.1", dev_dependency = True, repo_name = "com_google_googletest")
bazel_dep(name = "platforms", version = "0.0.6", dev_dependency = True)
bazel_dep(name = "rules_cc", version = "0.0.4", dev_dependency = True)
bazel_dep(name = "zlib", version = "1.2.13")
2 changes: 2 additions & 0 deletions WORKSPACE.bzlmod
@@ -0,0 +1,2 @@
# When Bzlmod is enabled, this file replaces the content of the original WORKSPACE
# and makes sure no WORKSPACE prefix or suffix are added when Bzlmod is enabled.
9 changes: 8 additions & 1 deletion bazel/repositories.bzl
Expand Up @@ -47,7 +47,7 @@ def prometheus_cpp_repositories():

maybe(
http_archive,
name = "net_zlib_zlib",
name = "zlib",
sha256 = "b3a24de97a8fdbc835b9833169501030b8977031bcb54b3b3ac13740f846ab30",
strip_prefix = "zlib-1.2.13",
urls = [
Expand All @@ -70,3 +70,10 @@ def prometheus_cpp_repositories():
"https://github.com/google/boringssl/archive/b9232f9e27e5668bc0414879dcdedb2a59ea75f2.tar.gz",
],
)

def _data_deps_extension_impl(ctx):
prometheus_cpp_repositories()

data_deps_ext = module_extension(
implementation = _data_deps_extension_impl,
)
2 changes: 1 addition & 1 deletion bazel/zlib.BUILD
Expand Up @@ -3,7 +3,7 @@
licenses(["notice"]) # BSD/MIT-like license (for zlib)

cc_library(
name = "z",
name = "zlib",
srcs = glob(["*.c"]),
hdrs = glob(["*.h"]),
# Use -Dverbose=-1 to turn off zlib's trace logging. (bazelbuild/bazel#3280)
Expand Down
2 changes: 1 addition & 1 deletion pull/BUILD.bazel
Expand Up @@ -23,7 +23,7 @@ cc_library(
deps = [
"//core",
"@civetweb",
"@net_zlib_zlib//:z",
"@zlib",
],
)

Expand Down

0 comments on commit bb21a73

Please sign in to comment.