Skip to content

Commit d1ae4ec

Browse files
authored
Merge pull request #37 from renesas-abigail/feat/multi_instance
Feat: multi instance support with doxyfile_prefix
2 parents 0a15f29 + e72b850 commit d1ae4ec

File tree

6 files changed

+123
-11
lines changed

6 files changed

+123
-11
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
runs-on: ${{ matrix.os }}
4848

4949
steps:
50-
- uses: actions/checkout@v4
50+
- uses: actions/checkout@v6
5151
- name: Create .bazelversion file
5252
working-directory: examples
5353
run: echo "${{ matrix.bazel }}" > .bazelversion
@@ -72,7 +72,7 @@ jobs:
7272
runs-on: ${{ matrix.os }}
7373

7474
steps:
75-
- uses: actions/checkout@v4
75+
- uses: actions/checkout@v6
7676
- name: Install doxygen
7777
uses: ssciwr/doxygen-install@v1
7878
with:
@@ -103,7 +103,7 @@ jobs:
103103
subdir: [base]
104104
runs-on: ${{ matrix.os }}
105105
steps:
106-
- uses: actions/checkout@v4
106+
- uses: actions/checkout@v6
107107
- name: Create .bazelversion file
108108
working-directory: examples
109109
run: echo "${{ matrix.bazel }}" > .bazelversion
@@ -157,7 +157,7 @@ jobs:
157157
subdir: [base]
158158
runs-on: ${{ matrix.os }}
159159
steps:
160-
- uses: actions/checkout@v4
160+
- uses: actions/checkout@v6
161161
- name: Create .bazelversion file
162162
working-directory: examples
163163
run: echo "${{ matrix.bazel }}" > .bazelversion
@@ -225,7 +225,7 @@ jobs:
225225
runs-on: ${{ matrix.os }}
226226

227227
steps:
228-
- uses: actions/checkout@v4
228+
- uses: actions/checkout@v6
229229
- name: Create .bazelversion file
230230
working-directory: examples
231231
run: echo "${{ matrix.bazel }}" > .bazelversion
@@ -241,3 +241,36 @@ jobs:
241241
- name: Check doxygen version in produced index.html
242242
run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/submodules/${{ matrix.subdir }}/bazel-bin/html/index.html
243243
shell: bash
244+
245+
nested:
246+
strategy:
247+
matrix:
248+
os: [ubuntu-latest, windows-latest, macos-latest]
249+
bazel: [7.0.0, 8.0.0, rolling]
250+
runs-on: ${{ matrix.os }}
251+
252+
steps:
253+
- uses: actions/checkout@v6
254+
- name: Create .bazelversion file
255+
working-directory: examples
256+
run: echo "${{ matrix.bazel }}" > .bazelversion
257+
shell: bash
258+
- name: Build nested
259+
run: bazel build //nested:doxygen_a //nested:doxygen_b
260+
working-directory: examples/nested
261+
- name: Check output (a)
262+
uses: andstor/file-existence-action@v3
263+
with:
264+
files: examples/bazel-bin/nested/a/html/index.html
265+
fail: true
266+
- name: Check output (b)
267+
uses: andstor/file-existence-action@v3
268+
with:
269+
files: examples/bazel-bin/nested/b/html/index.html
270+
fail: true
271+
- name: Check doxygen version in produced index.html (a)
272+
run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/a/html/index.html
273+
shell: bash
274+
- name: Check doxygen version in produced index.html (b)
275+
run: grep "Doxygen $DEFAULT_DOXYGEN_VERSION" examples/bazel-bin/nested/b/html/index.html
276+
shell: bash

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.6.1]
9+
10+
### Added
11+
12+
- `doxyfile_prefix` parameter to optionally allow configuring the directory into which the `Doxyfile` is emitted [#35](https://github.com/TendTo/rules_doxygen/issues/35) (thanks to @renesas-abigail)
13+
814
## [2.6.0]
915

1016
### Changed

docs/doxygen_doc.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ A provider to collect source files transitively from the target and its dependen
2828
<pre>
2929
load("@doxygen//:doxygen.bzl", "doxygen")
3030

31-
doxygen(<a href="#doxygen-name">name</a>, <a href="#doxygen-srcs">srcs</a>, <a href="#doxygen-deps">deps</a>, <a href="#doxygen-executable">executable</a>, <a href="#doxygen-dot_executable">dot_executable</a>, <a href="#doxygen-configurations">configurations</a>, <a href="#doxygen-doxyfile_template">doxyfile_template</a>,
32-
<a href="#doxygen-doxygen_extra_args">doxygen_extra_args</a>, <a href="#doxygen-use_default_shell_env">use_default_shell_env</a>, <a href="#doxygen-env">env</a>, <a href="#doxygen-tools">tools</a>, <a href="#doxygen-outs">outs</a>, <a href="#doxygen-doxyfile_encoding">doxyfile_encoding</a>, <a href="#doxygen-project_name">project_name</a>,
33-
<a href="#doxygen-project_number">project_number</a>, <a href="#doxygen-project_brief">project_brief</a>, <a href="#doxygen-project_logo">project_logo</a>, <a href="#doxygen-project_icon">project_icon</a>, <a href="#doxygen-create_subdirs">create_subdirs</a>,
34-
<a href="#doxygen-create_subdirs_level">create_subdirs_level</a>, <a href="#doxygen-allow_unicode_names">allow_unicode_names</a>, <a href="#doxygen-output_language">output_language</a>, <a href="#doxygen-brief_member_desc">brief_member_desc</a>, <a href="#doxygen-repeat_brief">repeat_brief</a>,
35-
<a href="#doxygen-abbreviate_brief">abbreviate_brief</a>, <a href="#doxygen-always_detailed_sec">always_detailed_sec</a>, <a href="#doxygen-inline_inherited_memb">inline_inherited_memb</a>, <a href="#doxygen-full_path_names">full_path_names</a>,
31+
doxygen(<a href="#doxygen-name">name</a>, <a href="#doxygen-srcs">srcs</a>, <a href="#doxygen-deps">deps</a>, <a href="#doxygen-executable">executable</a>, <a href="#doxygen-dot_executable">dot_executable</a>, <a href="#doxygen-configurations">configurations</a>, <a href="#doxygen-doxyfile_prefix">doxyfile_prefix</a>,
32+
<a href="#doxygen-doxyfile_template">doxyfile_template</a>, <a href="#doxygen-doxygen_extra_args">doxygen_extra_args</a>, <a href="#doxygen-use_default_shell_env">use_default_shell_env</a>, <a href="#doxygen-env">env</a>, <a href="#doxygen-tools">tools</a>, <a href="#doxygen-outs">outs</a>,
33+
<a href="#doxygen-doxyfile_encoding">doxyfile_encoding</a>, <a href="#doxygen-project_name">project_name</a>, <a href="#doxygen-project_number">project_number</a>, <a href="#doxygen-project_brief">project_brief</a>, <a href="#doxygen-project_logo">project_logo</a>, <a href="#doxygen-project_icon">project_icon</a>,
34+
<a href="#doxygen-create_subdirs">create_subdirs</a>, <a href="#doxygen-create_subdirs_level">create_subdirs_level</a>, <a href="#doxygen-allow_unicode_names">allow_unicode_names</a>, <a href="#doxygen-output_language">output_language</a>, <a href="#doxygen-brief_member_desc">brief_member_desc</a>,
35+
<a href="#doxygen-repeat_brief">repeat_brief</a>, <a href="#doxygen-abbreviate_brief">abbreviate_brief</a>, <a href="#doxygen-always_detailed_sec">always_detailed_sec</a>, <a href="#doxygen-inline_inherited_memb">inline_inherited_memb</a>, <a href="#doxygen-full_path_names">full_path_names</a>,
3636
<a href="#doxygen-strip_from_path">strip_from_path</a>, <a href="#doxygen-strip_from_inc_path">strip_from_inc_path</a>, <a href="#doxygen-short_names">short_names</a>, <a href="#doxygen-javadoc_autobrief">javadoc_autobrief</a>, <a href="#doxygen-javadoc_banner">javadoc_banner</a>,
3737
<a href="#doxygen-qt_autobrief">qt_autobrief</a>, <a href="#doxygen-multiline_cpp_is_brief">multiline_cpp_is_brief</a>, <a href="#doxygen-python_docstring">python_docstring</a>, <a href="#doxygen-inherit_docs">inherit_docs</a>, <a href="#doxygen-separate_member_pages">separate_member_pages</a>,
3838
<a href="#doxygen-tab_size">tab_size</a>, <a href="#doxygen-aliases">aliases</a>, <a href="#doxygen-optimize_output_for_c">optimize_output_for_c</a>, <a href="#doxygen-optimize_output_java">optimize_output_java</a>, <a href="#doxygen-optimize_for_fortran">optimize_for_fortran</a>,
@@ -270,6 +270,7 @@ doxygen(
270270
| <a id="doxygen-executable"></a>executable | Label of the doxygen executable. | `None` |
271271
| <a id="doxygen-dot_executable"></a>dot_executable | Label of the doxygen executable. Make sure it is also added to the `srcs` of the macro | `None` |
272272
| <a id="doxygen-configurations"></a>configurations | List of additional configuration parameters to pass to Doxygen. | `None` |
273+
| <a id="doxygen-doxyfile_prefix"></a>doxyfile_prefix | Prefix to add to the Doxyfile path. | `""` |
273274
| <a id="doxygen-doxyfile_template"></a>doxyfile_template | The template file to use to generate the Doxyfile. The following substitutions are available:<br> - `# {{INPUT}}`: Subpackage directory in the sandbox.<br> - `# {{ADDITIONAL PARAMETERS}}`: Additional parameters given in the `configurations` attribute.<br> - `# {{OUTPUT DIRECTORY}}`: The directory provided in the `outs` attribute.<br> - `{{OUTDIR}}`: The output directory where the generated documentation will be placed. Can be used anywhere in the Doxyfile, usually to generate additional output files, like tag files. | `None` |
274275
| <a id="doxygen-doxygen_extra_args"></a>doxygen_extra_args | Extra arguments to pass to the doxygen executable. | `[]` |
275276
| <a id="doxygen-use_default_shell_env"></a>use_default_shell_env | Whether to use the default shell environment when running doxygen. | `False` |

doxygen/doxygen.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ collect_files_aspect = aspect(
5555
)
5656

5757
def _doxygen_impl(ctx):
58-
doxyfile = ctx.actions.declare_file("Doxyfile")
58+
doxyfile_prefix = ctx.attr.doxyfile_prefix
59+
doxyfile = ctx.actions.declare_file("%s/Doxyfile" % doxyfile_prefix if doxyfile_prefix else "Doxyfile")
5960

6061
output_group_info = {}
6162
outs = []
@@ -143,6 +144,7 @@ doxygen(
143144
"deps": attr.label_list(aspects = [collect_files_aspect], doc = "List of dependencies targets whose files present in the 'src', 'hdrs' and 'data' attributes will be collected to generate the documentation. Transitive dependencies are also taken into account. Since we are only considering the source files and not the outputs, these targets **will not** be built"),
144145
"configurations": attr.string_list(doc = "Additional configuration parameters to append to the Doxyfile. For example, to set the project name, use `PROJECT_NAME = example`."),
145146
"outs": attr.string_list(default = ["html"], allow_empty = False, doc = """Output folders to keep. If only the html outputs is of interest, the default value will do. Otherwise, a list of folders to keep is expected (e.g. `["html", "latex"]`)."""),
147+
"doxyfile_prefix" : attr.string(doc = "Prefix to add to the Doxyfile path.", default= ""),
146148
"doxyfile_template": attr.label(
147149
allow_single_file = True,
148150
default = Label(":Doxyfile.template"),
@@ -207,6 +209,7 @@ def doxygen(
207209
executable = None,
208210
dot_executable = None,
209211
configurations = None,
212+
doxyfile_prefix = "",
210213
doxyfile_template = None,
211214
doxygen_extra_args = [],
212215
use_default_shell_env = False,
@@ -697,6 +700,7 @@ def doxygen(
697700
executable: Label of the doxygen executable.
698701
dot_executable: Label of the doxygen executable. Make sure it is also added to the `srcs` of the macro
699702
configurations: List of additional configuration parameters to pass to Doxygen.
703+
doxyfile_prefix: Prefix to add to the Doxyfile path.
700704
doxyfile_template: The template file to use to generate the Doxyfile.
701705
The following substitutions are available:<br>
702706
- `# {{INPUT}}`: Subpackage directory in the sandbox.<br>
@@ -1342,6 +1346,7 @@ def doxygen(
13421346
srcs = srcs,
13431347
deps = deps,
13441348
outs = outs,
1349+
doxyfile_prefix = doxyfile_prefix,
13451350
configurations = configurations,
13461351
doxygen_extra_args = doxygen_extra_args,
13471352
executable = executable,

examples/nested/BUILD.bazel

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,32 @@ doxygen(
1616
project_brief = "Example project for doxygen",
1717
project_name = "nested",
1818
)
19+
20+
doxygen(
21+
name = "doxygen_a",
22+
srcs = ["//nested/lib_a:sources"],
23+
outs = [
24+
"a/html",
25+
"a/tags",
26+
],
27+
doxyfile_prefix = "a",
28+
project_brief = "Example project for doxygen, library A",
29+
project_name = "nested",
30+
generate_tagfile = "$(OUTDIR)/tags/tagfile.xml",
31+
)
32+
33+
doxygen(
34+
name = "doxygen_b",
35+
srcs = glob([
36+
"lib_b/*.h",
37+
"lib_b/*.cpp",
38+
]),
39+
outs = [
40+
"b/html",
41+
"b/tags",
42+
],
43+
doxyfile_prefix = "b",
44+
project_brief = "Example project for doxygen, library B",
45+
project_name = "nested",
46+
generate_tagfile = "$(OUTDIR)/tags/tagfile.xml",
47+
)

examples/nested/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,41 @@ doxygen(
7777
project_name = "nested",
7878
)
7979
```
80+
81+
## Handling multiple doxygen rules in the same folder
82+
83+
Having multiple `doxygen` rules in the same folder is supported, but requires some extra configuration.
84+
By default, all rules would create a `Doxyfile` in the same location, causing a conflict.
85+
The same applies to the output `html` folder.
86+
To avoid this, remember to specify different `doxyfile_prefix` and `outs` for each rule:
87+
88+
```bzl
89+
doxygen(
90+
name = "doxygen_a",
91+
srcs = ["//nested/lib_a:sources"],
92+
outs = [
93+
"a/html",
94+
"a/tags",
95+
],
96+
doxyfile_prefix = "a",
97+
project_brief = "Example project for doxygen, library A",
98+
project_name = "nested",
99+
generate_tagfile = "$(OUTDIR)/tags/tagfile.xml",
100+
)
101+
102+
doxygen(
103+
name = "doxygen_b",
104+
srcs = glob([
105+
"lib_b/*.h",
106+
"lib_b/*.cpp",
107+
]),
108+
outs = [
109+
"b/html",
110+
"b/tags",
111+
],
112+
doxyfile_prefix = "b",
113+
project_brief = "Example project for doxygen, library B",
114+
project_name = "nested",
115+
generate_tagfile = "$(OUTDIR)/tags/tagfile.xml",
116+
)
117+
```

0 commit comments

Comments
 (0)