Skip to content

Commit

Permalink
Merge pull request #9 from TendTo/feat/support-arm-binaries
Browse files Browse the repository at this point in the history
feat: support arm platforms and custom binaries
  • Loading branch information
TendTo authored Nov 27, 2024
2 parents d029a88 + f45c72b commit 4b3b411
Show file tree
Hide file tree
Showing 8 changed files with 358 additions and 126 deletions.
100 changes: 91 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
with:
files: "examples/bazel-bin/${{ matrix.subdir }}/html/index.html"
fail: true
- name: Check doxygen version in produced index.html
run: grep 'Doxygen 1.12.0' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash

tests-system-installation:
strategy:
Expand All @@ -36,11 +39,13 @@ jobs:
- uses: actions/checkout@v4
- name: Install doxygen
uses: ssciwr/doxygen-install@v1
with:
version: "1.9.7"
- name: Enable use of system doxygen by decommenting the module extension line
uses: richardrigutins/replace-in-files@v2
with:
search-text: '# doxygen_extension.version(version = "0.0.0")'
replacement-text: doxygen_extension.version(version = "0.0.0")
search-text: '# doxygen_extension.configuration(version = "0.0.0")'
replacement-text: doxygen_extension.configuration(version = "0.0.0")
files: examples/MODULE.bazel
- name: Build ${{ matrix.subdir }}
run: bazel build //${{ matrix.subdir }}:doxygen
Expand All @@ -50,12 +55,15 @@ jobs:
with:
files: "examples/bazel-bin/${{ matrix.subdir }}/html/index.html"
fail: true
- name: Check doxygen version in produced index.html
run: grep 'Doxygen 1.9.7' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash

tests-multiple-installations:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
subdir: [base, kwargs, doxyfile, latex, nested, custom, awesome]
subdir: [base]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand All @@ -64,21 +72,92 @@ jobs:
- name: Enable use of windows doxygen by decommenting the module extension line
uses: richardrigutins/replace-in-files@v2
with:
search-text: '# doxygen_extension.version(version = "1.11.0", sha256 = "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", platform = "windows")'
replacement-text: doxygen_extension.version(version = "1.11.0", sha256 = "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", platform = "windows")
search-text: '# doxygen_extension.configuration(version = "1.11.0", sha256 = "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", platform = "windows")'
replacement-text: doxygen_extension.configuration(version = "1.11.0", sha256 = "478fc9897d00ca181835d248a4d3e5c83c26a32d1c7571f4321ddb0f2e97459f", platform = "windows")
files: examples/MODULE.bazel
- name: Enable use of mac doxygen by decommenting the module extension line
uses: richardrigutins/replace-in-files@v2
with:
search-text: '# doxygen_extension.version(version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac")'
replacement-text: doxygen_extension.version(version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac")
search-text: '# doxygen_extension.configuration(version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac")'
replacement-text: doxygen_extension.configuration(version = "1.12.0", sha256 = "6ace7dde967d41f4e293d034a67eb2c7edd61318491ee3131112173a77344001", platform = "mac")
files: examples/MODULE.bazel
- name: Enable use linux doxygen by decommenting the module extension line
uses: richardrigutins/replace-in-files@v2
with:
search-text: '# doxygen_extension.version(version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux")'
replacement-text: doxygen_extension.version(version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux")
search-text: '# doxygen_extension.configuration(version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux")'
replacement-text: doxygen_extension.configuration(version = "1.10.0", sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747", platform = "linux")
files: examples/MODULE.bazel
- name: Build ${{ matrix.subdir }}
run: bazel build //${{ matrix.subdir }}:doxygen
working-directory: examples
- name: Check output
uses: andstor/file-existence-action@v3
with:
files: "examples/bazel-bin/${{ matrix.subdir }}/html/index.html"
fail: true
- name: Check doxygen version in produced index.html (windows)
if: matrix.os == 'windows-latest'
run: grep 'Doxygen 1.11.0' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash
- name: Check doxygen version in produced index.html (mac)
if: matrix.os == 'macos-latest'
run: grep 'Doxygen 1.12.0' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash
- name: Check doxygen version in produced index.html (linux)
if: matrix.os == 'ubuntu-latest'
run: grep 'Doxygen 1.10.0' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash

tests-local-executable:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
subdir: [base]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Install doxygen
uses: ssciwr/doxygen-install@v1
with:
version: "1.10.0"

- name: Copy binary to examples folder (windows)
if: matrix.os == 'windows-latest'
run: cp $(Get-Command doxygen).Source examples/doxygen.exe
- name: Copy binary to examples folder (mac, linux)
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: cp $(which doxygen) examples/doxygen

- name: Enable use of local doxygen by decommenting the module extension line (windows)
uses: richardrigutins/replace-in-files@v2
if: matrix.os == 'windows-latest'
with:
search-text: '# doxygen_extension.configuration(executable = "@//:doxygen")'
replacement-text: doxygen_extension.configuration(executable = "@//:doxygen.exe")
files: examples/MODULE.bazel
- name: Export doxygen binary (windows)
uses: richardrigutins/replace-in-files@v2
if: matrix.os == 'windows-latest'
with:
search-text: '# exports_files(["doxygen"])'
replacement-text: exports_files(["doxygen.exe"])
files: examples/BUILD.bazel

- name: Enable use of local doxygen by decommenting the module extension line (mac, linux)
uses: richardrigutins/replace-in-files@v2
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
with:
search-text: '# doxygen_extension.configuration(executable = "@//:doxygen")'
replacement-text: doxygen_extension.configuration(executable = "@//:doxygen")
files: examples/MODULE.bazel
- name: Export doxygen binary (mac, linux)
uses: richardrigutins/replace-in-files@v2
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
with:
search-text: '# exports_files(["doxygen"])'
replacement-text: exports_files(["doxygen"])
files: examples/BUILD.bazel

- name: Build ${{ matrix.subdir }}
run: bazel build //${{ matrix.subdir }}:doxygen
working-directory: examples
Expand All @@ -87,3 +166,6 @@ jobs:
with:
files: "examples/bazel-bin/${{ matrix.subdir }}/html/index.html"
fail: true
- name: Check doxygen version in produced index.html
run: grep 'Doxygen 1.10.0' examples/bazel-bin/${{ matrix.subdir }}/html/index.html
shell: bash
17 changes: 15 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Support hermetic build for `macos` platform (thanks to @kaycebasques)
- Support hermetic build for `mac` platform (thanks to @kaycebasques, @wyverald, @tpudlik, @rickeylev)
- Support for platform-specific configurations in the extension rule

### Changed
Expand All @@ -78,6 +78,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor of internal repository and extension rules
- Updated documentation

## [2.0.0]

### Added

- Platform `mac-silicon` to support the Apple silicon macs (thanks to @kaycebasques, @wyverald, @tpudlik, @rickeylev)
- Allow executable configuration in the `doxygen` extension rule (thanks to @kaycebasques, @wyverald, @tpudlik, @rickeylev)

### Changed

- Module extension tag renamed from `version` to `configuration` **BREAKING CHANGE**
- Updated documentation

## [NEXT.VERSION]

[1.0.0]: https://github.com/TendTo/rules_doxygen/tree/1.0.0
Expand All @@ -87,4 +99,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[1.1.3]: https://github.com/TendTo/rules_doxygen/compare/1.1.2...1.1.3
[1.2.0]: https://github.com/TendTo/rules_doxygen/compare/1.1.3...1.2.0
[1.3.0]: https://github.com/TendTo/rules_doxygen/compare/1.2.0...1.3.0
[NEXT.VERSION]: https://github.com/TendTo/rules_doxygen/compare/1.3.0...HEAD
[2.0.0]: https://github.com/TendTo/rules_doxygen/compare/1.3.0...2.0.0
[NEXT.VERSION]: https://github.com/TendTo/rules_doxygen/compare/2.0.0...HEAD
2 changes: 1 addition & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""rules_doxygen module"""
module(name = "rules_doxygen", version = "1.3.0", compatibility_level = 1)
module(name = "rules_doxygen", version = "2.0.0", compatibility_level = 2)

bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "stardoc", version = "0.7.1", dev_dependency = True)
59 changes: 38 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Doxygen rules for Bazel

[![Bazel Central Repository](https://img.shields.io/badge/BCR-1.3.0-%230C713A?logo=bazel)](https://registry.bazel.build/modules/rules_doxygen)
[![Bazel Central Repository](https://img.shields.io/badge/BCR-2.0.0-%230C713A?logo=bazel)](https://registry.bazel.build/modules/rules_doxygen)
[![CI](https://github.com/TendTo/rules_doxygen/actions/workflows/ci.yml/badge.svg)](https://github.com/TendTo/rules_doxygen/actions/workflows/ci.yml)

This repository contains a [Starlark](https://github.com/bazelbuild/starlark) implementation of [Doxygen](https://www.doxygen.nl/) rules in [Bazel](https://bazel.build/).
Expand All @@ -12,27 +12,25 @@ Add the following to your _MODULE.bazel_:
```bzl
# MODULE.bazel file

bazel_dep(name = "rules_doxygen", version = "1.3.0", dev_dependency = True)
bazel_dep(name = "rules_doxygen", version = "2.0.0", dev_dependency = True)
```

If you don't want to depend on the [Bazel package registry](https://bazel.build/external/bazelbuild/rules_pkg) or you want to use a not-yet-published version of this module, you can use an archive override by adding the following lines below the `bazel_dep` rule in your _MODULE.bazel_ file:
If you don't want to depend on the [Bazel package registry](https://bazel.build/external/bazelbuild/rules_pkg) or need a not-yet-published version of this module, you can use a `git_override` by adding the following lines below `bazel_dep` in your _MODULE.bazel_ file:

```bzl
# MODULE.bazel file

bazel_dep(name = "rules_doxygen", version = "1.3.0", dev_dependency = True)
archive_override(
bazel_dep(name = "rules_doxygen", version = "2.0.0", dev_dependency = True)
git_override(
module_name = "rules_doxygen",
urls = "https://github.com/TendTo/rules_doxygen/archive/refs/heads/main.tar.gz",
strip_prefix = "rules_doxygen-main",
# The SHA256 checksum of the archive file, based on the rules' version
# integrity = "sha256-0SCaZuAerluoDs6HXMb0Bj9FttZVieM4+Dpd9gnMM+o=", # Example
commit = "aacc1c856c350a89a0fa9c43b9318a248d5f1781", # Commit hash you want to use
remote = "https://github.com/TendTo/rules_doxygen.git",
)
```

### Doxygen version selection

To select a doxygen version to use, use the `doxygen_extension` module extension below the `bazel_dep` rule in your MODULE.bazel file.
To add the `@doxygen` repository to your module, use `doxygen_extension` under `bazel_dep` in your MODULE.bazel file.

```bzl
# MODULE.bazel file
Expand All @@ -43,8 +41,8 @@ doxygen_extension = use_extension("@rules_doxygen//:extensions.bzl", "doxygen_ex
use_repo(doxygen_extension, "doxygen")
```

By default, version `1.12.0` of Doxygen is used.
You can override this value with a custom one for each supported platform, i.e. _windows_, _mac_ and _linux_.
The extension will create a default configuration for all platforms with the version `1.12.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_.

```bzl
# MODULE.bazel file
Expand All @@ -54,7 +52,7 @@ bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True)
doxygen_extension = use_extension("@rules_doxygen//:extensions.bzl", "doxygen_extension")

# Download doxygen version 1.10.0 on linux, default version on all other platforms
doxygen_extension.version(
doxygen_extension.configuration(
version = "1.10.0",
sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747",
platform = "linux",
Expand All @@ -63,24 +61,37 @@ doxygen_extension.version(
use_repo(doxygen_extension, "doxygen")
```

When you do so, you must also provide the SHA256 of the given doxygen installation.
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.

```bash
Download from https://github.com/doxygen/doxygen/releases/download/Release_1_10_0/doxygen-1.10.0.windows.x64.bin.zip 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.
#### System-wide doxygen installation

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 to `0.0.0` this will break the hermeticity of your build, as it will now depend on the environment.
> [!Tip]
> Not indicating the platform will make the configuration apply to the platform it is running on.
> The build will fail when the downloaded file 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.
#### Using a local doxygen executable

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]
> `version` and `executable` are mutually exclusive.
> You must provide exactly one of them.
#### Example

Different strategies can be combined in the same file, one for each platform, as shown below:

Expand All @@ -92,17 +103,23 @@ bazel_dep(name = "rules_doxygen", version = "...", dev_dependency = True)
doxygen_extension = use_extension("@rules_doxygen//:extensions.bzl", "doxygen_extension")

# Download doxygen version 1.10.0 on linux
doxygen_extension.version(
doxygen_extension.configuration(
version = "1.10.0",
sha256 = "dcfc9aa4cc05aef1f0407817612ad9e9201d9bf2ce67cecf95a024bba7d39747",
platform = "linux",
)
# Use the local doxygen installation on mac
doxygen_extension.version(
doxygen_extension.configuration(
version = "0.0.0",
platform = "mac",
)
# Since no configuration has been provided, windows will fallback to the default version
# 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")
```
Expand Down
Loading

0 comments on commit 4b3b411

Please sign in to comment.