All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ccache: add packageconfig docs option
@ 2021-05-04 11:39 Bastian Krause
  0 siblings, 0 replies; only message in thread
From: Bastian Krause @ 2021-05-04 11:39 UTC (permalink / raw)
  To: openembedded-core; +Cc: Konrad Weihmann, Bastian Krause

Before, ccache's configure stage built HTML documentation and man pages
depending on if asciidoc is installed. This patch makes it configurable.

Pass the new cmake option BUILD_DOCS along and add the asciidoc
dependency if necessary.

This fixes an issue when ccache's configure stage found asciidoc/a2x on
the system outside of the sysroot (e.g. installed via 'apt install
asciidoc'). ccache would then decide to build docs and manual pages, but
would fail during compilation: the system's a2x could not find the
system's asciidoc because it did not reside in the set PATH.

By enabling/disabling docs/man page generation explicitly and adding
asciidoc to DEPENDS as necessary, this is no longer an issue.

Signed-off-by: Bastian Krause <bst@pengutronix.de>
---
Changes since (implicit) v1:
- fixed patch's "Upstream-Status" ("Submitted" instead of "Pending"),
  thanks to Konrad Weihmann <kweihmann@outlook.com>
---
 ...w-disabling-docs-man-page-generation.patch | 161 ++++++++++++++++++
 meta/recipes-devtools/ccache/ccache_4.2.1.bb  |   6 +-
 2 files changed, 166 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-devtools/ccache/ccache/0001-doc-allow-disabling-docs-man-page-generation.patch

diff --git a/meta/recipes-devtools/ccache/ccache/0001-doc-allow-disabling-docs-man-page-generation.patch b/meta/recipes-devtools/ccache/ccache/0001-doc-allow-disabling-docs-man-page-generation.patch
new file mode 100644
index 0000000000..51ca0e82f6
--- /dev/null
+++ b/meta/recipes-devtools/ccache/ccache/0001-doc-allow-disabling-docs-man-page-generation.patch
@@ -0,0 +1,161 @@
+From aebabafe085dd1b84027a1e31e5566c82528bd62 Mon Sep 17 00:00:00 2001
+From: Bastian Krause <bst@pengutronix.de>
+Date: Tue, 4 May 2021 11:41:56 +0200
+Subject: [PATCH] doc: allow disabling docs/man page generation
+
+The assumption that HTML documentation and manual pages should be
+generated if the required tools (asciidoc) are present is not always
+true. So add a cmake option that allows disabling the docs/man page
+generation. The default is to generate docs/man pages like before.
+
+Origin: https://github.com/ccache/ccache/pull/844
+Upstream-Status: Submitted
+Signed-off-by: Bastian Krause <bst@pengutronix.de>
+---
+ doc/CMakeLists.txt | 128 +++++++++++++++++++++++----------------------
+ 1 file changed, 66 insertions(+), 62 deletions(-)
+
+diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
+index c5ce224d..74b7831b 100644
+--- a/doc/CMakeLists.txt
++++ b/doc/CMakeLists.txt
+@@ -1,70 +1,74 @@
++option(BUILD_DOCS "Indicates whether HTML documentation and manual pages should be built or not" ON)
++
+ find_program(ASCIIDOC_EXE asciidoc)
+ mark_as_advanced(ASCIIDOC_EXE) # Don't show in CMake UIs
+ 
+-if(NOT ASCIIDOC_EXE)
+-  message(WARNING "Could not find asciidoc; documentation will not be generated")
+-else()
+-  #
+-  # HTML documentation
+-  #
+-  function(generate_html adoc_file)
+-    get_filename_component(base_name "${adoc_file}" NAME_WE)
+-    set(html_file "${base_name}.html")
+-    add_custom_command(
+-      OUTPUT "${html_file}"
+-      COMMAND
+-        ${ASCIIDOC_EXE}
+-          -o "${html_file}"
+-          -a revnumber="${CCACHE_VERSION}"
+-          -a toc
+-          -b xhtml11
+-          "${CMAKE_SOURCE_DIR}/${adoc_file}"
+-      MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/${adoc_file}"
+-    )
+-    set(html_files "${html_files}" "${html_file}" PARENT_SCOPE)
+-  endfunction()
++if (BUILD_DOCS)
++  if(NOT ASCIIDOC_EXE)
++    message(WARNING "Could not find asciidoc; documentation will not be generated")
++  else()
++    #
++    # HTML documentation
++    #
++    function(generate_html adoc_file)
++      get_filename_component(base_name "${adoc_file}" NAME_WE)
++      set(html_file "${base_name}.html")
++      add_custom_command(
++        OUTPUT "${html_file}"
++        COMMAND
++          ${ASCIIDOC_EXE}
++            -o "${html_file}"
++            -a revnumber="${CCACHE_VERSION}"
++            -a toc
++            -b xhtml11
++            "${CMAKE_SOURCE_DIR}/${adoc_file}"
++        MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/${adoc_file}"
++      )
++      set(html_files "${html_files}" "${html_file}" PARENT_SCOPE)
++    endfunction()
+ 
+-  generate_html(LICENSE.adoc)
+-  generate_html(doc/AUTHORS.adoc)
+-  generate_html(doc/MANUAL.adoc)
+-  generate_html(doc/NEWS.adoc)
++    generate_html(LICENSE.adoc)
++    generate_html(doc/AUTHORS.adoc)
++    generate_html(doc/MANUAL.adoc)
++    generate_html(doc/NEWS.adoc)
+ 
+-  add_custom_target(doc-html DEPENDS "${html_files}")
+-  set(doc_files "${html_files}")
++    add_custom_target(doc-html DEPENDS "${html_files}")
++    set(doc_files "${html_files}")
+ 
+-  #
+-  # Man page
+-  #
+-  find_program(A2X_EXE a2x)
+-  mark_as_advanced(A2X_EXE) # Don't show in CMake UIs
+-  if(NOT A2X_EXE)
+-    message(WARNING "Could not find a2x; man page will not be generated")
+-  else()
+-    # MANUAL.adoc -> MANUAL.xml -> man page
+-    add_custom_command(
+-      OUTPUT MANUAL.xml
+-      COMMAND
+-        ${ASCIIDOC_EXE}
+-          -o -
+-          -a revnumber=${CCACHE_VERSION}
+-          -d manpage
+-          -b docbook "${CMAKE_SOURCE_DIR}/doc/MANUAL.adoc"
+-        | perl -pe 's!<literal>\(.*?\)</literal>!<emphasis role="strong">\\1</emphasis>!g'
+-            >MANUAL.xml
+-      MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/doc/MANUAL.adoc"
+-    )
+-    add_custom_command(
+-      OUTPUT ccache.1
+-      COMMAND ${A2X_EXE} --doctype manpage --format manpage MANUAL.xml
+-      MAIN_DEPENDENCY MANUAL.xml
+-    )
+-    add_custom_target(doc-man-page DEPENDS ccache.1)
+-    install(
+-      FILES "${CMAKE_CURRENT_BINARY_DIR}/ccache.1"
+-      DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
+-    )
+-    set(doc_files "${doc_files}" ccache.1)
+-  endif()
++    #
++    # Man page
++    #
++    find_program(A2X_EXE a2x)
++    mark_as_advanced(A2X_EXE) # Don't show in CMake UIs
++    if(NOT A2X_EXE)
++      message(WARNING "Could not find a2x; man page will not be generated")
++    else()
++      # MANUAL.adoc -> MANUAL.xml -> man page
++      add_custom_command(
++        OUTPUT MANUAL.xml
++        COMMAND
++          ${ASCIIDOC_EXE}
++            -o -
++            -a revnumber=${CCACHE_VERSION}
++            -d manpage
++            -b docbook "${CMAKE_SOURCE_DIR}/doc/MANUAL.adoc"
++          | perl -pe 's!<literal>\(.*?\)</literal>!<emphasis role="strong">\\1</emphasis>!g'
++              >MANUAL.xml
++        MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/doc/MANUAL.adoc"
++      )
++      add_custom_command(
++        OUTPUT ccache.1
++        COMMAND ${A2X_EXE} --doctype manpage --format manpage MANUAL.xml
++        MAIN_DEPENDENCY MANUAL.xml
++      )
++      add_custom_target(doc-man-page DEPENDS ccache.1)
++      install(
++        FILES "${CMAKE_CURRENT_BINARY_DIR}/ccache.1"
++        DESTINATION "${CMAKE_INSTALL_MANDIR}/man1"
++      )
++      set(doc_files "${doc_files}" ccache.1)
++    endif()
+ 
+-  add_custom_target(doc ALL DEPENDS "${doc_files}")
++    add_custom_target(doc ALL DEPENDS "${doc_files}")
++  endif()
+ endif()
+-- 
+2.29.2
+
diff --git a/meta/recipes-devtools/ccache/ccache_4.2.1.bb b/meta/recipes-devtools/ccache/ccache_4.2.1.bb
index 90b9c6181f..8dd5893d68 100644
--- a/meta/recipes-devtools/ccache/ccache_4.2.1.bb
+++ b/meta/recipes-devtools/ccache/ccache_4.2.1.bb
@@ -11,7 +11,9 @@ LIC_FILES_CHKSUM = "file://LICENSE.adoc;md5=698a26b57e513d678e1e7727bf56395b"
 
 DEPENDS = "zstd"
 
-SRC_URI = "https://github.com/ccache/ccache/releases/download/v${PV}/${BP}.tar.gz"
+SRC_URI = "https://github.com/ccache/ccache/releases/download/v${PV}/${BP}.tar.gz \
+           file://0001-doc-allow-disabling-docs-man-page-generation.patch \
+	   "
 SRC_URI[sha256sum] = "320d2b17d2f76393e5d4bb28c8dee5ca783248e9cd23dff0654694d60f8a4b62"
 
 UPSTREAM_CHECK_URI = "https://github.com/ccache/ccache/releases/"
@@ -21,3 +23,5 @@ inherit cmake
 PATCHTOOL = "patch"
 
 BBCLASSEXTEND = "native nativesdk"
+
+PACKAGECONFIG[docs] = "-DBUILD_DOCS=ON,-DBUILD_DOCS=OFF,asciidoc"
-- 
2.29.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-04 11:39 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-04 11:39 [PATCH v2] ccache: add packageconfig docs option Bastian Krause

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.