Improve Bazel support: Switch to Bzlmod (#4584)

* Improve Bazel support: Switch to Bzlmod

Signed-off-by: Vertexwahn <julian.amann@tum.de>

* Update documentation

Signed-off-by: Vertexwahn <julian.amann@tum.de>

* Fix spelling

Signed-off-by: Vertexwahn <julian.amann@tum.de>

* Fix snippet filename error

Signed-off-by: Vertexwahn <julian.amann@tum.de>

---------

Signed-off-by: Vertexwahn <julian.amann@tum.de>
This commit is contained in:
Vertexwahn
2025-01-07 18:47:51 +01:00
committed by GitHub
parent 2e50d5b2f3
commit 0cb1241d5e
7 changed files with 43 additions and 15 deletions

View File

@@ -0,0 +1 @@
bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1")

View File

@@ -1,7 +0,0 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "nlohmann_json",
urls = ["https://github.com/nlohmann/json/archive/refs/tags/v3.11.3.tar.gz"],
strip_prefix = "json-3.11.3",
)

View File

@@ -137,16 +137,14 @@ using the subproject directly.
!!! abstract "Summary"
use `http_archive`, `git_repository`, or `local_repository`
use `bazel_dep`, `git_override`, or `local_path_override`
- :octicons-tag-24: Any version, as version is specified in `WORKSPACE` file
- :octicons-tag-24: Any version, that is available via [Bazel Central Registry](https://registry.bazel.build/modules/nlohmann_json)
- :octicons-file-24: File issues at the [library issue tracker](https://github.com/nlohmann/json/issues)
- :octicons-question-24: [Bazel website](https://bazel.build)
This repository provides a [Bazel](https://bazel.build/) `WORKSPACE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this
repository can be referenced by workspace rules such as `http_archive`, `git_repository`, or `local_repository` from
other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g., via
`deps` attribute).
This repository provides a [Bazel](https://bazel.build/) `MODULE.bazel` and a corresponding `BUILD.bazel` file. Therefore, this
repository can be referenced within a `MODULE.bazel` by rules such as `archive_override`, `git_override`, or `local_path_override`. To use the library you need to depend on the target `@nlohmann_json//:json` (i.e., via `deps` attribute).
??? example
@@ -157,7 +155,7 @@ other Bazel workspaces. To use the library you only need to depend on the target
```
```ini title="WORKSPACE"
--8<-- "integration/bazel/WORKSPACE"
--8<-- "integration/bazel/MODULE.bazel"
```
```cpp title="example.cpp"