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:
parent
2e50d5b2f3
commit
0cb1241d5e
3
.gitignore
vendored
3
.gitignore
vendored
@ -44,3 +44,6 @@
|
|||||||
/.build
|
/.build
|
||||||
|
|
||||||
/tools/astyle/venv/
|
/tools/astyle/venv/
|
||||||
|
|
||||||
|
# Bazel-related
|
||||||
|
MODULE.bazel.lock
|
||||||
|
|||||||
27
BUILD.bazel
27
BUILD.bazel
@ -1,3 +1,20 @@
|
|||||||
|
load("@rules_cc//cc:cc_library.bzl", "cc_library")
|
||||||
|
load("@rules_license//rules:license.bzl", "license")
|
||||||
|
|
||||||
|
package(
|
||||||
|
default_applicable_licenses = [":license"],
|
||||||
|
)
|
||||||
|
|
||||||
|
exports_files([
|
||||||
|
"LICENSE.MIT",
|
||||||
|
])
|
||||||
|
|
||||||
|
license(
|
||||||
|
name = "license",
|
||||||
|
license_kinds = ["@rules_license//licenses/spdx:MIT"],
|
||||||
|
license_text = "LICENSE.MIT",
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "json",
|
name = "json",
|
||||||
hdrs = [
|
hdrs = [
|
||||||
@ -40,6 +57,7 @@ cc_library(
|
|||||||
"include/nlohmann/detail/output/serializer.hpp",
|
"include/nlohmann/detail/output/serializer.hpp",
|
||||||
"include/nlohmann/detail/string_concat.hpp",
|
"include/nlohmann/detail/string_concat.hpp",
|
||||||
"include/nlohmann/detail/string_escape.hpp",
|
"include/nlohmann/detail/string_escape.hpp",
|
||||||
|
"include/nlohmann/detail/string_utils.hpp",
|
||||||
"include/nlohmann/detail/value_t.hpp",
|
"include/nlohmann/detail/value_t.hpp",
|
||||||
"include/nlohmann/json.hpp",
|
"include/nlohmann/json.hpp",
|
||||||
"include/nlohmann/json_fwd.hpp",
|
"include/nlohmann/json_fwd.hpp",
|
||||||
@ -50,3 +68,12 @@ cc_library(
|
|||||||
includes = ["include"],
|
includes = ["include"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "singleheader-json",
|
||||||
|
hdrs = [
|
||||||
|
"single_include/nlohmann/json.hpp",
|
||||||
|
],
|
||||||
|
includes = ["single_include"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|||||||
7
MODULE.bazel
Normal file
7
MODULE.bazel
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
module(
|
||||||
|
name = "nlohmann_json",
|
||||||
|
compatibility_level = 1,
|
||||||
|
)
|
||||||
|
|
||||||
|
bazel_dep(name = "rules_cc", version = "0.0.17")
|
||||||
|
bazel_dep(name = "rules_license", version = "1.0.0")
|
||||||
@ -1 +0,0 @@
|
|||||||
workspace(name = "nlohmann_json")
|
|
||||||
1
docs/mkdocs/docs/integration/bazel/MODULE.bazel
Normal file
1
docs/mkdocs/docs/integration/bazel/MODULE.bazel
Normal file
@ -0,0 +1 @@
|
|||||||
|
bazel_dep(name = "nlohmann_json", version = "3.11.3.bcr.1")
|
||||||
@ -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",
|
|
||||||
)
|
|
||||||
@ -137,16 +137,14 @@ using the subproject directly.
|
|||||||
|
|
||||||
!!! abstract "Summary"
|
!!! 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-file-24: File issues at the [library issue tracker](https://github.com/nlohmann/json/issues)
|
||||||
- :octicons-question-24: [Bazel website](https://bazel.build)
|
- :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
|
This repository provides a [Bazel](https://bazel.build/) `MODULE.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
|
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).
|
||||||
other Bazel workspaces. To use the library you only need to depend on the target `@nlohmann_json//:json` (e.g., via
|
|
||||||
`deps` attribute).
|
|
||||||
|
|
||||||
??? example
|
??? example
|
||||||
|
|
||||||
@ -157,7 +155,7 @@ other Bazel workspaces. To use the library you only need to depend on the target
|
|||||||
```
|
```
|
||||||
|
|
||||||
```ini title="WORKSPACE"
|
```ini title="WORKSPACE"
|
||||||
--8<-- "integration/bazel/WORKSPACE"
|
--8<-- "integration/bazel/MODULE.bazel"
|
||||||
```
|
```
|
||||||
|
|
||||||
```cpp title="example.cpp"
|
```cpp title="example.cpp"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user