aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/modules
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2021-10-19 14:09:13 -0700
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-10-19 22:06:45 +0000
commitb8a45f3638994299ea9a2e0c8e5df08a35743af3 (patch)
tree93364af2c43048228f862c192c308a089d1c10d4 /cmake/modules
parentcfe33625a07472189a5b17190ca348108c8911cf (diff)
CMake+Docs: Generate man pages all at once.
Asciidoctor lets us generate multiple documents at once, so do so for our man pages. If we're using AsciidoctorJ this minimizes the number of JVM instances we have to spin up. This reduces the build time on my Windows VM here quite a bit, and will hopefully do so on the CI builders. Add a .editorconfig file in cmake/modules.
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/.editorconfig3
-rw-r--r--cmake/modules/FindAsciidoctor.cmake61
2 files changed, 53 insertions, 11 deletions
diff --git a/cmake/modules/.editorconfig b/cmake/modules/.editorconfig
new file mode 100644
index 0000000000..5359b5051d
--- /dev/null
+++ b/cmake/modules/.editorconfig
@@ -0,0 +1,3 @@
+[FindAsciidoctor.cmake]
+indent_style = space
+indent_size = 4
diff --git a/cmake/modules/FindAsciidoctor.cmake b/cmake/modules/FindAsciidoctor.cmake
index b21eac2361..69150a1f32 100644
--- a/cmake/modules/FindAsciidoctor.cmake
+++ b/cmake/modules/FindAsciidoctor.cmake
@@ -33,9 +33,15 @@ if(ASCIIDOCTOR_EXECUTABLE)
set_target_properties(${_target} PROPERTIES
FOLDER "Docbook"
EXCLUDE_FROM_DEFAULT_BUILD True
- )
+ )
endfunction(set_asciidoctor_target_properties)
+ function(set_manpage_target_properties _target)
+ set_target_properties(${_target} PROPERTIES
+ FOLDER "Docs"
+ )
+ endfunction(set_manpage_target_properties)
+
set (_asciidoctor_common_args
# Doesn't work with AsciidoctorJ?
# --failure-level=WARN
@@ -132,24 +138,57 @@ if(ASCIIDOCTOR_EXECUTABLE)
unset(_output_txt)
ENDMACRO()
- # Single page only, for the release notes and man pages.
- MACRO( ASCIIDOCTOR2MAN _asciidocsource _man_section)
- GET_FILENAME_COMPONENT( _source_base_name ${_asciidocsource} NAME_WE )
- set( _output_man ${_source_base_name}.${_man_section} )
+ # Generate one or more ROFF man pages
+ MACRO(ASCIIDOCTOR2ROFFMAN _man_section)
+ set(_input_adoc)
+ set(_output_man)
+ foreach(_src_file ${ARGN})
+ list(APPEND _input_adoc ${_src_file})
+ GET_FILENAME_COMPONENT(_source_base_name ${_src_file} NAME_WE )
+ list(APPEND _output_man ${_source_base_name}.${_man_section} )
+ endforeach()
ADD_CUSTOM_COMMAND(
OUTPUT
${_output_man}
COMMAND ${_asciidoctor_common_command}
--backend manpage
- --out-file ${_output_man}
- ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
+ --destination-dir ${CMAKE_CURRENT_BINARY_DIR}
+ ${_input_adoc}
DEPENDS
- ${CMAKE_CURRENT_SOURCE_DIR}/${_asciidocsource}
- ${ARGN}
+ ${_input_adoc}
+ )
+ add_custom_target(generate_roff_man${_man_section}_pages DEPENDS ${_output_man})
+ set_manpage_target_properties(generate_roff_man${_man_section}_pages)
+ unset(_src_file)
+ unset(_input_adoc)
+ unset(_output_man)
+ ENDMACRO()
+
+ # Generate one or more HTML man pages
+ MACRO(ASCIIDOCTOR2HTMLMAN)
+ set(_input_adoc)
+ set(_output_man)
+ foreach(_src_file ${ARGN})
+ list(APPEND _input_adoc ${_src_file})
+ GET_FILENAME_COMPONENT(_source_base_name ${_src_file} NAME_WE )
+ list(APPEND _output_man ${_source_base_name}.html )
+ endforeach()
+
+ ADD_CUSTOM_COMMAND(
+ OUTPUT
+ ${_output_man}
+ COMMAND ${_asciidoctor_common_command}
+ --backend html
+ --destination-dir ${CMAKE_CURRENT_BINARY_DIR}
+ ${_input_adoc}
+ DEPENDS
+ ${_input_adoc}
)
- add_custom_target(generate_${_output_man} DEPENDS ${_output_man})
- set_asciidoctor_target_properties(generate_${_output_man})
+ add_custom_target(generate_html_man_pages DEPENDS ${_output_man})
+ set_manpage_target_properties(generate_html_man_pages)
+ unset(_src_file)
+ unset(_input_adoc)
unset(_output_man)
ENDMACRO()