Skip to content

Commit

Permalink
docs: add note about Bazel BCR
Browse files Browse the repository at this point in the history
fix: #704
  • Loading branch information
gjasny committed May 26, 2024
1 parent 6f9fbbc commit b253ae9
Showing 1 changed file with 16 additions and 38 deletions.
54 changes: 16 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ on master and for all releases.
In case these instructions don't work for you, looking at
the [GitHub Workflows](.github/workflows) might help.

### via CMake
### With CMake

For CMake builds don't forget to fetch the submodules first. Please note that
[zlib](https://zlib.net/) and [libcurl](https://curl.se/) are not provided by
Expand Down Expand Up @@ -132,47 +132,15 @@ ctest -V
cmake --install .
```

### via Bazel
### With Bazel

Install [bazel](https://www.bazel.io). Bazel makes it easy to add
this repo to your project as a dependency. Just add the following
to your `WORKSPACE`:
Install a recent [bazel](https://www.bazel.io) version with Modules support.
To build and test prometheus-cpp run:

```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
http_archive(
name = "com_github_jupp0r_prometheus_cpp",
strip_prefix = "prometheus-cpp-master",
urls = ["https://github.com/jupp0r/prometheus-cpp/archive/master.zip"],
)

load("@com_github_jupp0r_prometheus_cpp//bazel:repositories.bzl", "prometheus_cpp_repositories")

prometheus_cpp_repositories()
```

Then, you can reference this library in your own `BUILD` file, as
demonstrated with the sample server included in this repository:

```python
cc_binary(
name = "sample_server",
srcs = ["sample_server.cc"],
deps = ["@com_github_jupp0r_prometheus_cpp//pull"],
)
```shell
bazel test //...
```

When you call `prometheus_cpp_repositories()` in your `WORKSPACE` file,
you load the following dependencies, if they do not exist yet, into your project:

* `civetweb` for [Civetweb](https://github.com/civetweb/civetweb)
* `com_google_googletest` for [Google Test](https://github.com/google/googletest)
* `com_github_google_benchmark` for [Google Benchmark](https://github.com/google/benchmark)
* `com_github_curl` for [curl](https://curl.haxx.se/)
* `net_zlib_zlib` for [zlib](http://www.zlib.net/)

The list of dependencies is also available from file [repositories.bzl](bazel/repositories.bzl).

## Packaging

By configuring CPack you can generate an installer like a
Expand Down Expand Up @@ -227,6 +195,16 @@ prometheus-cpp port which has been tested on Linux, macOS, and Windows.
[Conan](https://conan.io/) package manager contains prometheus-cpp package as well
in [ConanCenter](https://conan.io/center/prometheus-cpp) repository

### Bazel

The Bazel Central Registry (BCR
[provides the prometheus-cpp package](https://registry.bazel.build/modules/prometheus-cpp).
Add the following to your `MODULE.bazel` file:

```python
bazel_dep(name = "prometheus-cpp", version = "1.2.4")
```

### Plain Makefiles

When manually linking prometheus-cpp the library order matters. The needed
Expand Down

0 comments on commit b253ae9

Please sign in to comment.