Repository rule for downloading the correct version of doxygen using module extensions.
load("@rules_doxygen//:extensions.bzl", "get_default_canonical_id") get_default_canonical_id(<a href="#get_default_canonical_id-repository_ctx">repository_ctx</a>, <a href="#get_default_canonical_id-urls">urls</a>)
Returns the default canonical id to use for downloads.
Copied from @bazel_tools//tools/build_defs/repo:cache.bzl to avoid a dependency on the whole @bazel_tools package, since its visibility changed from private to public between Bazel 7.0.0 and 8.0.0.
Returns "" (empty string) when Bazel is run with --repo_env=BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0.
e.g.
load("@bazel_tools//tools/build_defs/repo:cache.bzl", "get_default_canonical_id") # ... repository_ctx.download_and_extract( url = urls, integrity = integrity canonical_id = get_default_canonical_id(repository_ctx, urls), ),
PARAMETERS
RETURNS
The canonical ID to use for the download, or an empty string if BAZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID is set to 0.
load("@rules_doxygen//:extensions.bzl", "doxygen_repository") doxygen_repository(<a href="#doxygen_repository-name">name</a>, <a href="#doxygen_repository-build">build</a>, <a href="#doxygen_repository-doxyfile_template">doxyfile_template</a>, <a href="#doxygen_repository-doxygen_bzl">doxygen_bzl</a>, <a href="#doxygen_repository-executables">executables</a>, <a href="#doxygen_repository-platforms">platforms</a>, <a href="#doxygen_repository-repo_mapping">repo_mapping</a>, <a href="#doxygen_repository-sha256s">sha256s</a>, <a href="#doxygen_repository-versions">versions</a>)
Repository rule for doxygen.
It can be provided with a configuration for each of the three platforms (windows, mac, mac-arm, linux, linux-arm) to download the correct version of doxygen only when the configuration matches the current platform. Depending on the version, the behavior will change:
0.0.0, the repository will use the installed version of doxygen, getting the binary from the PATH.[!WARNING]
If version is set to0.0.0, the rules needs doxygen to be installed on your system and the binary (named doxygen) must available in the PATH. Keep in mind that this will break the hermeticity of your build, as it will now depend on the environment.
You can further customize the repository by specifying the doxygen_bzl, build, and doxyfile_template attributes, but the default values should be enough for most use cases.
# Download the os specific version 1.12.0 of doxygen supporting all the indicated platforms doxygen_repository( name = "doxygen", versions = ["1.12.0", "1.12.0", "1.12.0"], sha256s = [ "07f1c92cbbb32816689c725539c0951f92c6371d3d7f66dfa3192cbe88dd3138", "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", "3c42c3f3fb206732b503862d9c9c11978920a8214f223a3950bbf2520be5f647", ] platforms = ["windows", "mac", "linux"], executables = ["", "", ""], ) # Use the system installed version of doxygen on linux and download version 1.11.0 for windows. Use the provided executable on mac-arm doxygen_repository( name = "doxygen", version = ["0.0.0", "1.11.0", ""], sha256s = ["", "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", ""], platforms = ["linux", "windows", "mac-arm"], executables = ["", "", "/path/to/doxygen"], )
ATTRIBUTES
doxygen_extension = use_extension("@rules_doxygen//:extensions.bzl", "doxygen_extension") doxygen_extension.configuration(<a href="#doxygen_extension.configuration-executable">executable</a>, <a href="#doxygen_extension.configuration-platform">platform</a>, <a href="#doxygen_extension.configuration-sha256">sha256</a>, <a href="#doxygen_extension.configuration-version">version</a>) doxygen_extension.repository(<a href="#doxygen_extension.repository-name">name</a>)
Module extension for declaring the doxygen configurations to use.
The resulting repository will have the following targets:
@doxygen//:doxygen.bzl, containing the doxygen macro used to generate the documentation.@doxygen//:Doxyfile.template, default Doxyfile template used to generate the Doxyfile.The extension will create a default configuration for all platforms with the version 1.18.0 of Doxygen. You can override this value with a custom one for each supported platform, i.e. windows, mac, mac-arm, linux and linux-arm.
# MODULE.bazel file bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True) doxygen_extension = use_extension( "@rules_doxygen//:extensions.bzl", "doxygen_extension", dev_dependency = True, ) # Download doxygen version 1.10.0 on linux, default version on all other platforms doxygen_extension.configuration( version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux", ) use_repo(doxygen_extension, "doxygen")
When you do so, you must also provide the SHA256 of the given doxygen archive. If you don't know the SHA256 value, just leave it empty. The build will fail with an error message containing the correct SHA256.
Download from https://github.com/doxygen/doxygen/releases/... failed: class com.google.devtools.build.lib.bazel.repository.downloader.UnrecoverableHttpException Checksum was 2135c1d5bdd6e067b3d0c40a4daac5d63d0fee1b3f4d6ef1e4f092db0d632d5b but wanted 0000000000000000000000000000000000000000000000000000000000000000
[!TIP]
Not indicating the platform will make the configuration apply to the platform it is running on. The build will fail when the download does not match the SHA256 checksum, i.e. when the platform changes. Unless you are using a system-wide doxygen installation, you should always specify the platform.
[!NOTE]
When a version is specified, the extension will download the doxygen binary from the official Doxygen releases. If a binary for the specified platform is not available (e.g., linux-arm, mac-arm), the build may fail. If that happens, you can either:
- Use a different version of doxygen that supports your platform.
- Use a system-wide doxygen installation by setting the version to
0.0.0.- Use a local doxygen executable by providing a label pointing to the doxygen executable in the
executableparameter.
If you set the version to 0.0.0, the doxygen executable will be assumed to be available from the PATH. No download will be performed and bazel will use the installed version of doxygen.
[!WARNING]
Setting the version to0.0.0this will break the hermeticity of your build, as it will now depend on the environment.
You can also provide a label pointing to the doxygen executable you want to use by using the executable parameter in the extension configuration. No download will be performed, and the file indicated by the label will be used as the doxygen executable.
[!NOTE]
versionandexecutableare mutually exclusive. You must provide exactly one of them.
# MODULE.bazel file bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True) doxygen_extension = use_extension( "@rules_doxygen//:extensions.bzl", "doxygen_extension", dev_dependency = True, ) # Using the 1.10.0 version of Doxygen instead of the default one. # Note that che checksum is correct only if the platform is windows. # If the platform is different, the build will fail. doxygen_extension.configuration( version = "1.10.0", sha256 = "2135c1d5bdd6e067b3d0c40a4daac5d63d0fee1b3f4d6ef1e4f092db0d632d5b", ) use_repo(doxygen_extension, "doxygen")
# MODULE.bazel file bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True) doxygen_extension = use_extension( "@rules_doxygen//:extensions.bzl", "doxygen_extension", dev_dependency = True, ) doxygen_extension.configuration( version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux", ) doxygen_extension.configuration( version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux-arm", ) doxygen_extension.configuration( version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac", ) doxygen_extension.configuration( version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac-arm", ) doxygen_extension.configuration( version = "1.11.0", sha256 = "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", platform = "windows", ) use_repo(doxygen_extension, "doxygen")
# MODULE.bazel file bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True) doxygen_extension = use_extension( "@rules_doxygen//:extensions.bzl", "doxygen_extension", dev_dependency = True, ) # Download doxygen version 1.10.0 on linux doxygen_extension.configuration( version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux", ) # Use the local doxygen installation on mac doxygen_extension.configuration( version = "0.0.0", platform = "mac", ) # Use the doxygen provided executable on mac-arm doxygen_extension.configuration( executable = "@my_module//path/to/doxygen:doxygen", platform = "mac-arm", ) # Since no configuration has been provided for them, # all other platforms will fallback to the default version use_repo(doxygen_extension, "doxygen")
TAG CLASSES
Attributes
Attributes